From f1c831bd3a4758989f062f8af6705ef81aadebcc Mon Sep 17 00:00:00 2001 From: Haydar Metin Date: Wed, 21 Aug 2024 12:55:08 +0200 Subject: [PATCH] Disable breakpoint functionality --- package.json | 12 ++-- src/common/breakpoint.ts | 8 ++- src/plugin/breakpoints/breakpoint-tracker.ts | 22 +++---- src/plugin/session-tracker.ts | 4 -- src/webview/breakpoints/breakpoint-service.ts | 58 +++++++++++++++++++ src/webview/memory-webview-view.tsx | 6 +- 6 files changed, 80 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 0354ca9..e0ec966 100644 --- a/package.json +++ b/package.json @@ -271,27 +271,27 @@ { "command": "memory-inspector.data-breakpoint.set.read", "group": "breakpoints@1", - "when": "webviewId === memory-inspector.memory && memory-inspector.breakpoint.isBreakable" + "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.isBreakable" }, { "command": "memory-inspector.data-breakpoint.set.write", "group": "breakpoints@2", - "when": "webviewId === memory-inspector.memory && memory-inspector.breakpoint.isBreakable" + "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.isBreakable" }, { "command": "memory-inspector.data-breakpoint.set.readWrite", "group": "breakpoints@3", - "when": "webviewId === memory-inspector.memory && memory-inspector.breakpoint.isBreakable" + "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.isBreakable" }, { "command": "memory-inspector.data-breakpoint.remove", "group": "breakpoints@4", - "when": "webviewId === memory-inspector.memory && memory-inspector.breakpoint.type === 'internal'" + "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.type === 'internal'" }, { "command": "memory-inspector.data-breakpoint.remove-all", "group": "breakpoints@5", - "when": "webviewId === memory-inspector.memory && memory-inspector.breakpoint.type === 'internal'" + "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.type === 'internal'" } ] }, @@ -501,4 +501,4 @@ "extensionKind": [ "ui" ] -} \ No newline at end of file +} diff --git a/src/common/breakpoint.ts b/src/common/breakpoint.ts index cc02f47..9fe438c 100644 --- a/src/common/breakpoint.ts +++ b/src/common/breakpoint.ts @@ -23,9 +23,12 @@ export interface TrackedDataBreakpoint { /** * The respective response for the breakpoint. */ - response: DebugProtocol.SetDataBreakpointsResponse['body']['breakpoints'][0] + response: DebugProtocol.Breakpoint; } +/** + * Temp. workaround till we have a proper API for this within VSCode. + */ export interface TrackedDataBreakpoints { /** * Breakpoints set from external contributors. @@ -37,6 +40,9 @@ export interface TrackedDataBreakpoints { internal: TrackedDataBreakpoint[] } +/** + * Temp. workaround till we have a proper API for this within VSCode. + */ export type TrackedBreakpointType = 'internal' | 'external'; export type DataBreakpointInfoArguments = DebugRequestTypes['dataBreakpointInfo'][0]; diff --git a/src/plugin/breakpoints/breakpoint-tracker.ts b/src/plugin/breakpoints/breakpoint-tracker.ts index e7a4032..c2274e4 100644 --- a/src/plugin/breakpoints/breakpoint-tracker.ts +++ b/src/plugin/breakpoints/breakpoint-tracker.ts @@ -20,6 +20,12 @@ import { SetDataBreakpointsResult, TrackedDataBreakpoint, TrackedDataBreakpoints import { isDebugRequest, isDebugResponse } from '../../common/debug-requests'; import { isSessionEvent, SessionContinuedEvent, SessionEvent, SessionRequest, SessionResponse, SessionStoppedEvent, SessionTracker } from '../session-tracker'; +/** + * Tracks data breakpoints and provides events for changes. + * + * Currently the webview part is disabled and does not react to the changes. + * It will be enabled again after VSCode extends the breakpoint API. + */ export class BreakpointTracker { protected _dataBreakpoints: TrackedDataBreakpoints = { external: [], internal: [] }; protected _stoppedEvent?: SessionStoppedEvent; @@ -84,20 +90,8 @@ export class BreakpointTracker { } if (isSessionEvent('stopped', event)) { - // TODO: Only for demo purposes - // Reason: The debugger does not set the hitBreakpointIds property - const demoEvent: SessionStoppedEvent = { - ...event, - data: { - ...event.data, - body: { - ...event.data.body, - hitBreakpointIds: this.externalDataBreakpoints.map(bp => bp.response.id ?? -1) - } - } - }; - this._stoppedEvent = demoEvent; - this._onStopped.fire(demoEvent); + this._stoppedEvent = event; + this._onStopped.fire(event); } else if (isSessionEvent('continued', event)) { this._stoppedEvent = undefined; this._onContinued.fire(event); diff --git a/src/plugin/session-tracker.ts b/src/plugin/session-tracker.ts index 780bb7f..38b94aa 100644 --- a/src/plugin/session-tracker.ts +++ b/src/plugin/session-tracker.ts @@ -145,8 +145,6 @@ export class SessionTracker implements vscode.DebugAdapterTrackerFactory { } protected willSendClientMessage(session: vscode.DebugSession, message: unknown): void { - // TODO: ONLY FOR DEMO PURPOSES - console.log('[SEND] ==>', message); if (isDebugRequest('initialize', message)) { this.sessionInfo(session).clientCapabilities = message.arguments; } @@ -157,8 +155,6 @@ export class SessionTracker implements vscode.DebugAdapterTrackerFactory { } protected adapterMessageReceived(session: vscode.DebugSession, message: unknown): void { - // TODO: ONLY FOR DEMO PURPOSES - console.log('[RECV] <==', message); if (isDebugResponse('initialize', message)) { this.sessionInfo(session).debugCapabilities = message.body; } else if (isDebugEvent('stopped', message)) { diff --git a/src/webview/breakpoints/breakpoint-service.ts b/src/webview/breakpoints/breakpoint-service.ts index 54ec97b..9150c93 100644 --- a/src/webview/breakpoints/breakpoint-service.ts +++ b/src/webview/breakpoints/breakpoint-service.ts @@ -171,4 +171,62 @@ export namespace BreakpointService { } } +/** + * This service has been disabled for now, as it is not used. + * It is kept here until VSCode extends the breakpoints API. + * + * **Tasks for re-enabling** + * + * 1) Activate the service in the view component + * ```typescript + * // src/webview/memory-webview-view.tsx + * componentDidMount() { + * ... + * breakpointService.activate(); + * breakpointService.onDidChange(() => this.forceUpdate()); + * } + * + * doFetchMemory() { + * ... + * await Promise.all(Array.from( + * new Set(columnContributionService + * .getUpdateExecutors() + * .concat(decorationService.getUpdateExecutors()) + * .concat(breakpointService)), + * executor => executor.fetchData(memoryOptions) + * )); + * } + * ``` + * + * 2) Enable commands in package.json (see false part) + * ```json + * ... + * { + * "command": "memory-inspector.data-breakpoint.set.read", + * "group": "breakpoints@1", + * "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.isBreakable" + * }, + * { + * "command": "memory-inspector.data-breakpoint.set.write", + * "group": "breakpoints@2", + * "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.isBreakable" + * }, + * { + * "command": "memory-inspector.data-breakpoint.set.readWrite", + * "group": "breakpoints@3", + * "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.isBreakable" + * }, + * { + * "command": "memory-inspector.data-breakpoint.remove", + * "group": "breakpoints@4", + * "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.type === 'internal'" + * }, + * { + * "command": "memory-inspector.data-breakpoint.remove-all", + * "group": "breakpoints@5", + * "when": "false && webviewId === memory-inspector.memory && memory-inspector.breakpoint.type === 'internal'" + * } + * ... + * ``` + */ export const breakpointService = new BreakpointService(); diff --git a/src/webview/memory-webview-view.tsx b/src/webview/memory-webview-view.tsx index 6101dcf..668fc69 100644 --- a/src/webview/memory-webview-view.tsx +++ b/src/webview/memory-webview-view.tsx @@ -43,7 +43,6 @@ import { } from '../common/messaging'; import { Change, hasChanged, hasChangedTo } from '../common/typescript'; import { MemoryDisplaySettings, MemoryViewSettings } from '../common/webview-configuration'; -import { breakpointService } from './breakpoints/breakpoint-service'; import { AddressColumn } from './columns/address-column'; import { AsciiColumn } from './columns/ascii-column'; import { columnContributionService, ColumnStatus } from './columns/column-contribution-service'; @@ -135,8 +134,6 @@ class App extends React.Component<{}, MemoryAppState> { messenger.onRequest(getWebviewSelectionType, () => this.getWebviewSelection()); messenger.onNotification(showAdvancedOptionsType, () => this.showAdvancedOptions()); messenger.sendNotification(readyType, HOST_EXTENSION, undefined); - breakpointService.activate(); - breakpointService.onDidChange(() => this.forceUpdate()); this.updatePeriodicRefresh(); } @@ -296,8 +293,7 @@ class App extends React.Component<{}, MemoryAppState> { await Promise.all(Array.from( new Set(columnContributionService .getUpdateExecutors() - .concat(decorationService.getUpdateExecutors()) - .concat(breakpointService)), + .concat(decorationService.getUpdateExecutors())), executor => executor.fetchData(memoryOptions) ));