Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Web Inspector: Add Function Breakpoints/Tracepoints (like Symbolic Br…
…eakpoints) https://bugs.webkit.org/show_bug.cgi?id=142914 <rdar://problem/20242025> Reviewed by Patrick Angle. Existing JavaScript breakpoints are only useful so long as the developer knows the source code location of the function. Web Inspector does provide a bunch of ways to find that location (e.g. Search Tab, hovering a symbol when paused to see it's definition, etc.), but that makes adding a breakpoint into a multi-step process. To make matters worse, it's not uncommon for there to be different functions with the same name, meaning that if the developer wants to add breakpoints to all of them it becomes a geometric problem (and that's not even considering the hassle of having to duplicate any breakpoint configuration each time). Symbolic breakpoints are a single-step way to add a single breakpoint that will be used across all functions that share the same name, regardless of when they are created or where they are located. * Source/JavaScriptCore/debugger/Debugger.h: (JSC::Debugger::Observer::willEnter): Added. (JSC::Debugger::Observer::applyBreakpoints): Added. * Source/JavaScriptCore/debugger/Debugger.cpp: (JSC::Debugger::forEachRegisteredCodeBlock): Added. (JSC::Debugger::applyBreakpoints): (JSC::Debugger::callEvent): Add hooks to allow `InspectorDebuggerAgent` to also do things whenever a new `CodeBlock` is created and when a new `CallFrame` is about to be entered (i.e. a function call). * Source/JavaScriptCore/inspector/protocol/Debugger.json: * Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h: (Inspector::InspectorDebuggerAgent::SymbolicBreakpoint::operator== const): Added. * Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::functionName): Added. (Inspector::InspectorDebuggerAgent::addSymbolicBreakpoint): Added. (Inspector::InspectorDebuggerAgent::removeSymbolicBreakpoint): Added. (Inspector::InspectorDebuggerAgent::willEnter): Added. (Inspector::InspectorDebuggerAgent::applyBreakpoints): Added. (Inspector::InspectorDebuggerAgent::SymbolicBreakpoint::matches): Added. Add commands for adding/removing symbolic breakpoints, leveraging the above `Debugger` hooks to mark matching `CodeBlock` as having a (symbolic) breakpoint so that debug hooks will not be ignored. * Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js: (WI.DebuggerManager): (WI.DebuggerManager.prototype.async initializeTarget): (WI.DebuggerManager.pauseReasonFromPayload): (WI.DebuggerManager.prototype.symbolicBreakpointsForSymbol): Added. (WI.DebuggerManager.prototype.addSymbolicBreakpoint): Added. (WI.DebuggerManager.prototype.removeSymbolicBreakpoint): Added. (WI.DebuggerManager.prototype._setSymbolicBreakpoint): Added. (WI.DebuggerManager.prototype._removeSymbolicBreakpoint): Added. (WI.DebuggerManager.prototype._handleSymbolicBreakpointDisabledStateChanged): Added. (WI.DebuggerManager.prototype._handleSymbolicBreakpointEditablePropertyChanged): Added. (WI.DebuggerManager.prototype._handleSymbolicBreakpointActionsChanged): Added. Manage adding/removing symbolic breakpoints, including handling state changes for existing symbolic breakpoints (e.g. disabled, actions, etc.). * Source/WebInspectorUI/UserInterface/Models/SymbolicBreakpoint.js: Added. (WI.SymbolicBreakpoint): (WI.SymbolicBreakpoint.supported): (WI.SymbolicBreakpoint.fromJSON): (WI.SymbolicBreakpoint.prototype.get symbol): (WI.SymbolicBreakpoint.prototype.get caseSensitive): (WI.SymbolicBreakpoint.prototype.get isRegex): (WI.SymbolicBreakpoint.prototype.get displayName): (WI.SymbolicBreakpoint.prototype.get editable): (WI.SymbolicBreakpoint.prototype.matches): (WI.SymbolicBreakpoint.prototype.equals): (WI.SymbolicBreakpoint.prototype.remove): (WI.SymbolicBreakpoint.prototype.saveIdentityToCookie): (WI.SymbolicBreakpoint.prototype.toJSON): Create a model object to represent a symbolic breakpoint. * Source/WebInspectorUI/UserInterface/Views/BreakpointPopover.js: (WI.BreakpointPopover.show): * Source/WebInspectorUI/UserInterface/Views/SymbolicBreakpointPopover.js: Added. (WI.SymbolicBreakpointPopover): (WI.SymbolicBreakpointPopover.get supportsEditing): (WI.SymbolicBreakpointPopover.prototype.populateContent): (WI.SymbolicBreakpointPopover.prototype.createBreakpoint): (WI.SymbolicBreakpointPopover.prototype._updateSymbolCodeMirrorMode): * Source/WebInspectorUI/UserInterface/Views/SymbolicBreakpointPopover.css: Added. (.popover .edit-breakpoint-popover-content .symbol.editor): (.popover .edit-breakpoint-popover-content .symbol.editor > .CodeMirror): (.popover .edit-breakpoint-popover-content .symbol.editor + label): (.popover .edit-breakpoint-popover-content .symbol.editor + label + label): * Source/WebInspectorUI/UserInterface/Views/SymbolicBreakpointTreeElement.js: Added. (WI.SymbolicBreakpointTreeElement): * Source/WebInspectorUI/UserInterface/Views/SymbolicBreakpointTreeElement.css: Added. (.item.breakpoint.symbolic:not(.paused) .icon): (@media(prefers-color-scheme: dark) .item.breakpoint.symbolic:not(.paused) .icon): * Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js: (WI.NavigationSidebarPanel.prototype._isTreeElementWithoutRepresentedObject): * Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js: (WI.SourcesNavigationSidebarPanel): (WI.SourcesNavigationSidebarPanel.prototype.closed): (WI.SourcesNavigationSidebarPanel.prototype.willDismissPopover): (WI.SourcesNavigationSidebarPanel.prototype._willDismissSymbolicBreakpointPopover): Added. (WI.SourcesNavigationSidebarPanel.prototype._insertDebuggerTreeElement): (WI.SourcesNavigationSidebarPanel.prototype._addBreakpoint): (WI.SourcesNavigationSidebarPanel.prototype._updatePauseReasonSection): (WI.SourcesNavigationSidebarPanel.prototype._handleTreeSelectionDidChange): (WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu): Add various UI elements for `WI.SymbolicBreakpoint`. * Source/WebInspectorUI/UserInterface/Base/Setting.js: * Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js: (WI.SettingsTabContentView.prototype._createExperimentalSettingsView): Create an experimental setting for symbolic breakpoints, as they currently do not work for - native functions (e.g. `Event.prototype.preventDefault`) - functions that changed their `name` after creation (e.g. `foo.name = "bar"`) * Source/WebInspectorUI/UserInterface/Base/ObjectStore.js: (WI.ObjectStore._open): Increment the database version for the new symbolic breakpoint object store. * Source/WebInspectorUI/UserInterface/Base/ReferencePage.js: Create a link to a reference page (to be created). * Source/WebInspectorUI/UserInterface/Main.html: * Source/WebInspectorUI/UserInterface/Images/TypeIcons.svg: * Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js: * Source/WebInspectorUI/UserInterface/Test.html: * LayoutTests/inspector/debugger/symbolic-breakpoint.html: Added. * LayoutTests/inspector/debugger/symbolic-breakpoint-expected.txt: Added. * LayoutTests/inspector/debugger/symbolic-breakpoint-exact-case-insensitive.html: Added. * LayoutTests/inspector/debugger/symbolic-breakpoint-exact-case-insensitive-expected.txt: Added. * LayoutTests/inspector/debugger/symbolic-breakpoint-exact-case-sensitive.html: Added. * LayoutTests/inspector/debugger/symbolic-breakpoint-exact-case-sensitive-expected.txt: Added. * LayoutTests/inspector/debugger/symbolic-breakpoint-regex-case-insensitive.html: Added. * LayoutTests/inspector/debugger/symbolic-breakpoint-regex-case-insensitive-expected.txt: Added. * LayoutTests/inspector/debugger/symbolic-breakpoint-regex-case-sensitive.html: Added. * LayoutTests/inspector/debugger/symbolic-breakpoint-regex-case-sensitive-expected.txt: Added. Canonical link: https://commits.webkit.org/253374@main
- Loading branch information