Bug 70605 - First stack frame when evaluating a script is missing
Summary: First stack frame when evaluating a script is missing
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://poshnet.ch/stack_test.html
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-21 07:16 PDT by Michael Schneider
Modified: 2011-10-21 07:16 PDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Schneider 2011-10-21 07:16:14 PDT
To reproduce
1) Open Safari on http://poshnet.ch/stack_test.html. It contains the script
   
   function foo()  {
     console.trace();
   }
   console.trace();
   foo();

2) Open the console

observe: the output is
 console.trace()
   (anonymous function)
 console.trace()
  foo

Note that the second trace is missing the bottom frame, the anonymous evaluate script. This is very confusing as it looks as if the browser invoked foo directly. Chrome shows the (anonymous function) stack frame in both cases.

This seems to be due to ScriptCallStackFactory.cpp:73

        if (function)
            functionName = asFunction(function)->name(exec);
        else {
            // Caller is unknown, but if frames is empty we should still add the frame, because
            // something called us, and gave us arguments.
            if (!frames.isEmpty())
                break;
        }

where anonymous frames (such as the script eval) are dropped if other stack frames are on top of it. What is the exact purpose of that "if"? If we can change that, ie. drop the else, I'm more than happy to provide a patch.