Bug 72481

Summary: Web Inspector: support Javascript probes in the Scripts pane
Product: WebKit Reporter: Xavier Morel <webkit.org>
Component: Web Inspector (Deprecated)Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Enhancement CC: apavlov, bburg, bweinstein, joepeck, keishi, loislo, pfeldman, pmuellr, rik, shezbaig.wk, yurys
Priority: P3    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   

Description Xavier Morel 2011-11-16 01:42:00 PST
The Web Inspector already has good debugging support, which is nice, but sometimes the developer wants to gather some data or do rough checks on various spots in order to pinpoint the issue.

For this, the debugger tends to be far too slow (and changes timings which may "fix" race conditions), so developers have to rely on "printf-debugging" (via the console API). This has its own set of issues, in that it requires reloading the script. Some versions of the Web Inspector (used in Chrome) provide JS source edition which is nice, but I think an other, less intrusive, mechanism would be nice.

The idea would be a (much) simpler form of DTrace, with analogues to DTrace's "static" probes in UI (dynamic probes are more complex):

* when context-clicking on a line number of the Script tab, two new items would be added to the menu, "Add Probe" and "Add Conditional Probe"
  * The "conditional" part is similar to breakpoints: it adds a "condition" field, which requires a Javascript expression and executes the probe if and only if the condition is true
* the probe is a javascript expression (or maybe a list of expressions, understood as so many arguments to a `console.log` call?)
* upon reaching a probe, the javascript interpreter should check the condition (assuming it's true for unconditional probes)
  * if the condition is true, it should execute the probe code

This is already possible by abusing conditional breakpoints, putting display expression in the condition and using the comma operator to ensure the breakpoint does not "break"  e.g.

    console.log(var1, var2), false

or

    (condition ? console.log(va1, var2) : ''), false

for a conditional probe

but I think a dedicated tool would be useful, and it could allow for DTrace-type dynamic probes (via a code selector) in the long run.
Comment 1 Xavier Morel 2011-11-16 01:42:33 PST
forgot to set the importance to enhancement