Skip to content

Commit

Permalink
Disable breakpoint functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
haydar-metin committed Aug 21, 2024
1 parent e668f5d commit f1c831b
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 30 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
}
]
},
Expand Down Expand Up @@ -501,4 +501,4 @@
"extensionKind": [
"ui"
]
}
}
8 changes: 7 additions & 1 deletion src/common/breakpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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];
Expand Down
22 changes: 8 additions & 14 deletions src/plugin/breakpoints/breakpoint-tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/plugin/session-tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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)) {
Expand Down
58 changes: 58 additions & 0 deletions src/webview/breakpoints/breakpoint-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
6 changes: 1 addition & 5 deletions src/webview/memory-webview-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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)
));

Expand Down

0 comments on commit f1c831b

Please sign in to comment.