Bug 142914

Summary: Web Inspector: Add Function Breakpoints/Tracepoints (like Symbolic Breakpoints)
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: graouts, inspector-bugzilla-changes, joepeck, jonowells, mark.lam, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 243717, 244642, 243716, 244717    

Joseph Pecoraro
Reported 2015-03-20 11:50:02 PDT
* SUMMARY Add Function Breakpoints/Tracepoints (like Symbolic Breakpoints). Often something you want to do is "pause when window.focus is called", or "do a console.trace every time Element.prototype.querySelector is called". It is possible to swizzle these functions out and get the functionality but that is cumbersome and doesn't play well with the inspector. It would be awesome if you could create a function breakpoint in Web Inspector's UI. Or via the console like `debug(window.focus)` or `trace(Element.prototype, "querySelector")` which would show up as a Breakpoint in Web Inspector and managed by Web Inspector. We may be able to avoid swizzling if the feature is in the engine. By having Web Inspector know about and manage these function breakpoints it has the opportunity to persist the breakpoints, carry them forward through navigations so you don't need to re-set them, and apply them to sub-frames automatically. - If the function breakpoints is set on a Native Function that is not a JSBoundFunction, then e should be able to restore the breakpoint immediately after navigation (when the global object is cleared). - Tricky with native getters/setters (Object.getOwnPropertyDescriptor(MouseEvent.prototype, "altKey").get) but that could be made to work. * NOTES Existing snippets that do things like this: - https://github.com/NV/captureCalls.js - https://gist.github.com/NV/5376464 - https://github.com/paulirish/break-on-access
Attachments
Radar WebKit Bug Importer
Comment 1 2015-03-20 11:50:24 PDT
Joseph Pecoraro
Comment 2 2015-03-20 11:56:13 PDT
> - https://github.com/paulirish/break-on-access I believe this will even swizzle out a value descriptor with a getter/setter so that you can break on any access to the original property. That also sounds useful. Also, integration with the text editor to quickly set these breakpoints on member variables sounds useful as well.
Joseph Pecoraro
Comment 3 2017-02-20 19:03:51 PST
Mark mentioned this may be easy with Native functions by inserting a middle thunk into the JITCode entry for Native Functions. This wouldn't work for built-in / Intrinsic functions though.
Devin Rousso
Comment 4 2022-08-08 22:14:53 PDT
EWS
Comment 5 2022-08-12 02:17:29 PDT
Committed 253374@main (631ebd578bab): <https://commits.webkit.org/253374@main> Reviewed commits have been landed. Closing PR #3140 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.