mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-18 06:45:33 +00:00
Bug 1435483 part 5. Add an infallible "filename" getter on nsIStackFrame. r=qdot
MozReview-Commit-ID: D3uuehuDqOB
This commit is contained in:
parent
796faaaf13
commit
02f7baafc0
@ -267,7 +267,8 @@ NS_IMETHODIMP
|
||||
Exception::GetFilename(JSContext* aCx, nsAString& aFilename)
|
||||
{
|
||||
if (mLocation) {
|
||||
return mLocation->GetFilename(aCx, aFilename);
|
||||
mLocation->GetFilename(aCx, aFilename);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
aFilename.Truncate();
|
||||
|
@ -354,11 +354,18 @@ GetValueIfNotCached(JSContext* aCx, const JS::Heap<JSObject*>& aStack,
|
||||
aPropGetter(aCx, stack, aValue, JS::SavedFrameSelfHosted::Exclude);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetFilename(JSContext* aCx, nsAString& aFilename)
|
||||
NS_IMETHODIMP JSStackFrame::GetFilenameXPCOM(JSContext* aCx, nsAString& aFilename)
|
||||
{
|
||||
GetFilename(aCx, aFilename);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
JSStackFrame::GetFilename(JSContext* aCx, nsAString& aFilename)
|
||||
{
|
||||
if (!mStack) {
|
||||
aFilename.Truncate();
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Rooted<JSString*> filename(aCx);
|
||||
@ -368,14 +375,14 @@ NS_IMETHODIMP JSStackFrame::GetFilename(JSContext* aCx, nsAString& aFilename)
|
||||
&canCache, &useCachedValue, &filename);
|
||||
if (useCachedValue) {
|
||||
aFilename = mFilename;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoJSString str;
|
||||
if (!str.init(aCx, filename)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
aFilename.Truncate();
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
aFilename = str;
|
||||
|
||||
@ -383,8 +390,6 @@ NS_IMETHODIMP JSStackFrame::GetFilename(JSContext* aCx, nsAString& aFilename)
|
||||
mFilename = str;
|
||||
mFilenameInitialized = true;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetName(JSContext* aCx, nsAString& aFunction)
|
||||
@ -649,15 +654,14 @@ NS_IMETHODIMP JSStackFrame::ToString(JSContext* aCx, nsACString& _retval)
|
||||
_retval.Truncate();
|
||||
|
||||
nsString filename;
|
||||
nsresult rv = GetFilename(aCx, filename);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
GetFilename(aCx, filename);
|
||||
|
||||
if (filename.IsEmpty()) {
|
||||
filename.AssignLiteral("<unknown filename>");
|
||||
}
|
||||
|
||||
nsString funname;
|
||||
rv = GetName(aCx, funname);
|
||||
nsresult rv = GetName(aCx, funname);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (funname.IsEmpty()) {
|
||||
|
@ -1159,11 +1159,10 @@ StackFrameToStackEntry(JSContext* aCx, nsIStackFrame* aStackFrame,
|
||||
{
|
||||
MOZ_ASSERT(aStackFrame);
|
||||
|
||||
nsresult rv = aStackFrame->GetFilename(aCx, aStackEntry.mFilename);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aStackFrame->GetFilename(aCx, aStackEntry.mFilename);
|
||||
|
||||
int32_t lineNumber;
|
||||
rv = aStackFrame->GetLineNumber(aCx, &lineNumber);
|
||||
nsresult rv = aStackFrame->GetLineNumber(aCx, &lineNumber);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aStackEntry.mLineNumber = lineNumber;
|
||||
@ -2694,14 +2693,13 @@ Console::MaybeExecuteDumpFunctionForTrace(JSContext* aCx, nsIStackFrame* aStack)
|
||||
|
||||
while (stack) {
|
||||
nsAutoString filename;
|
||||
nsresult rv = stack->GetFilename(aCx, filename);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
stack->GetFilename(aCx, filename);
|
||||
|
||||
message.Append(filename);
|
||||
message.AppendLiteral(" ");
|
||||
|
||||
int32_t lineNumber;
|
||||
rv = stack->GetLineNumber(aCx, &lineNumber);
|
||||
nsresult rv = stack->GetLineNumber(aCx, &lineNumber);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
message.AppendInt(lineNumber);
|
||||
|
@ -997,11 +997,11 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
||||
xpc_exception->
|
||||
GetLocation(getter_AddRefs(location));
|
||||
if (location) {
|
||||
// Get line number w/o checking; 0 is ok.
|
||||
// Get line number.
|
||||
location->GetLineNumber(cx, &lineNumber);
|
||||
|
||||
// get a filename.
|
||||
rv = location->GetFilename(cx, sourceName);
|
||||
location->GetFilename(cx, sourceName);
|
||||
}
|
||||
|
||||
rv = scriptError->InitWithWindowID(NS_ConvertUTF8toUTF16(newMessage),
|
||||
|
@ -53,7 +53,7 @@ SandboxLogJSStack(void)
|
||||
|
||||
// Don't stop unwinding if an attribute can't be read.
|
||||
fileName.SetIsVoid(true);
|
||||
Unused << frame->GetFilename(cx, fileName);
|
||||
frame->GetFilename(cx, fileName);
|
||||
lineNumber = 0;
|
||||
Unused << frame->GetLineNumber(cx, &lineNumber);
|
||||
funName.SetIsVoid(true);
|
||||
|
@ -6,14 +6,14 @@
|
||||
/*
|
||||
* Interfaces for representing cross-language exceptions and stack traces.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[ptr] native JSContext(JSContext);
|
||||
|
||||
[scriptable, builtinclass, uuid(28bfb2a2-5ea6-4738-918b-049dc4d51f0b)]
|
||||
interface nsIStackFrame : nsISupports
|
||||
{
|
||||
[implicit_jscontext]
|
||||
[implicit_jscontext, binaryname(FilenameXPCOM)]
|
||||
readonly attribute AString filename;
|
||||
[implicit_jscontext]
|
||||
readonly attribute AString name;
|
||||
@ -42,6 +42,10 @@ interface nsIStackFrame : nsISupports
|
||||
|
||||
[implicit_jscontext]
|
||||
AUTF8String toString();
|
||||
|
||||
// Infallible things to be called from C++.
|
||||
[notxpcom, nostdcall]
|
||||
void getFilename(in JSContext aCx, out AString aFilename);
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(4371b5bf-6845-487f-8d9d-3f1e4a9badd2)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user