<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>21262</bug_id>
          
          <creation_ts>2008-09-30 18:19:46 -0700</creation_ts>
          <short_desc>JavaScript Debugger doesn&apos;t play nice with functions created with eval/(new Function())</short_desc>
          <delta_ts>2014-12-11 16:55:53 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector (Deprecated)</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://280slides.com</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="boucher">rboucher</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aroben</cc>
    
    <cc>burg</cc>
    
    <cc>emacemac7</cc>
    
    <cc>ggaren</cc>
    
    <cc>kmccullough</cc>
    
    <cc>pmuellr</cc>
    
    <cc>tom</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>93483</commentid>
    <comment_count>0</comment_count>
    <who name="boucher">rboucher</who>
    <bug_when>2008-09-30 18:19:46 -0700</bug_when>
    <thetext>In Objective-J, we load all your code using XMLHTTPRequests.  This has the advantage of letting us do import statements asynchronously, and not having to worry about &lt;script&gt; tag placements.

In a desire to work well with the inspector, we specify a function name for each function that we create, in the style of:

$ClassName__methodName_withUnderscores_forColons_

These are correctly displayed in stack traces in the web inspector debugger.  Unfortunately, finding code, either to set a breakpoint on it, or to examine the various methods in a stack trace, is difficult.

When we get the result of the import XHR, we evaluate it with new Function(theCode) (see line 156 of evaluate.js if you&apos;re interested). In the inspector, this results in a &quot;(program)&quot; entry in the source list.  Needless to say, a hundred or so of these isn&apos;t very useful. Thankfully, the code search mechanism will search and find inside these files, so we can set breakpoints where we need to.  

When we encounter a stack trace, though, clicking on one of these methods in the stack does not bring up the corresponding code.  The line numbers are correct, but it just doesn&apos;t jump.  This means manually searching to find the function, and then scanning for the right line, an annoying process. Clicking on more traditionally imported code, like objj_msgSend, does the right thing and jumps to that definition.

So, in summary, I&apos;m talking about two issues,

1) eval&apos;d code has no associated name in the file list

2) functions defined in eval&apos;d code don&apos;t jump to their definitions when clicked in the stack trace

The second one seems like something that should be relatively easy to fix, the first is more interesting.  What I&apos;d like is a mechanism for specifying the name associated with this block of code. For example, some special api in eval and new Function that would allow us to attach a name manually, since we know the name of the file the code was imported from.

I&apos;m open to other suggestions, but there doesn&apos;t seem to be any reasonable way to try to automatically determine the information, and I know we&apos;re not the only ones who would appreciate some functionality like this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93484</commentid>
    <comment_count>1</comment_count>
    <who name="boucher">rboucher</who>
    <bug_when>2008-09-30 18:23:23 -0700</bug_when>
    <thetext>Just noticed, it also doesn&apos;t highlight the active line in source that&apos;s in &quot;(program)&quot; blocks when you&apos;re stepping through the debugger.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93485</commentid>
    <comment_count>2</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2008-09-30 18:51:37 -0700</bug_when>
    <thetext>No jumping and highlighting is just a bug. Names for eval would be nice. We do want to show something better than (program).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93668</commentid>
    <comment_count>3</comment_count>
    <who name="boucher">rboucher</who>
    <bug_when>2008-10-01 22:37:54 -0700</bug_when>
    <thetext>I think perhaps using the first N characters of the first non empty line is a good (first attempt) proxy for a file name.

This means that anyone formatting their code to include newlines can properly label the first line with a comment containing whatever they&apos;d like displayed to the debugger.  Non empty should be defined to exclude empty comment lines (in other words the first line to contain something more than just whitespace, //, /*, or *).

Definitely no substitute for real naming, but perhaps something that would be easy enough to add in for the time being.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124273</commentid>
    <comment_count>4</comment_count>
    <who name="Patrick Mueller">pmuellr</who>
    <bug_when>2009-06-03 22:15:51 -0700</bug_when>
    <thetext>Patch for supporting for naming evals via the Firefox convention of annotation comment is available in Bug 25475 .  I modified fragment_evaluate_code() in Objective-J.js to append the relevant comment, and got all of the Function()&apos;s named in the script drop-down, and I believe in the call stacks as well.

The change was to augment the aFragment.info property like this, before using with the Function() constructor:

        aFragment.info += &quot;\n//@sourceURL=&quot; + aFragment.file.path + &quot;\n&quot;;
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>