@theia/debug 1.28.0-next.2 → 1.28.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/lib/browser/breakpoint/breakpoint-manager.d.ts +13 -1
  2. package/lib/browser/breakpoint/breakpoint-manager.d.ts.map +1 -1
  3. package/lib/browser/breakpoint/breakpoint-manager.js +66 -2
  4. package/lib/browser/breakpoint/breakpoint-manager.js.map +1 -1
  5. package/lib/browser/breakpoint/breakpoint-marker.d.ts +6 -0
  6. package/lib/browser/breakpoint/breakpoint-marker.d.ts.map +1 -1
  7. package/lib/browser/breakpoint/breakpoint-marker.js +14 -1
  8. package/lib/browser/breakpoint/breakpoint-marker.js.map +1 -1
  9. package/lib/browser/debug-frontend-application-contribution.d.ts +3 -0
  10. package/lib/browser/debug-frontend-application-contribution.d.ts.map +1 -1
  11. package/lib/browser/debug-frontend-application-contribution.js +15 -3
  12. package/lib/browser/debug-frontend-application-contribution.js.map +1 -1
  13. package/lib/browser/debug-frontend-module.d.ts.map +1 -1
  14. package/lib/browser/debug-frontend-module.js +2 -0
  15. package/lib/browser/debug-frontend-module.js.map +1 -1
  16. package/lib/browser/debug-preferences.d.ts +1 -0
  17. package/lib/browser/debug-preferences.d.ts.map +1 -1
  18. package/lib/browser/debug-preferences.js +5 -0
  19. package/lib/browser/debug-preferences.js.map +1 -1
  20. package/lib/browser/debug-session-manager.d.ts +8 -0
  21. package/lib/browser/debug-session-manager.d.ts.map +1 -1
  22. package/lib/browser/debug-session-manager.js +11 -1
  23. package/lib/browser/debug-session-manager.js.map +1 -1
  24. package/lib/browser/debug-session.d.ts +5 -0
  25. package/lib/browser/debug-session.d.ts.map +1 -1
  26. package/lib/browser/debug-session.js +35 -8
  27. package/lib/browser/debug-session.js.map +1 -1
  28. package/lib/browser/disassembly-view/disassembly-view-accessibility-provider.d.ts +7 -0
  29. package/lib/browser/disassembly-view/disassembly-view-accessibility-provider.d.ts.map +1 -0
  30. package/lib/browser/disassembly-view/disassembly-view-accessibility-provider.js +39 -0
  31. package/lib/browser/disassembly-view/disassembly-view-accessibility-provider.js.map +1 -0
  32. package/lib/browser/disassembly-view/disassembly-view-breakpoint-renderer.d.ts +20 -0
  33. package/lib/browser/disassembly-view/disassembly-view-breakpoint-renderer.d.ts.map +1 -0
  34. package/lib/browser/disassembly-view/disassembly-view-breakpoint-renderer.js +111 -0
  35. package/lib/browser/disassembly-view/disassembly-view-breakpoint-renderer.js.map +1 -0
  36. package/lib/browser/disassembly-view/disassembly-view-contribution.d.ts +25 -0
  37. package/lib/browser/disassembly-view/disassembly-view-contribution.d.ts.map +1 -0
  38. package/lib/browser/disassembly-view/disassembly-view-contribution.js +132 -0
  39. package/lib/browser/disassembly-view/disassembly-view-contribution.js.map +1 -0
  40. package/lib/browser/disassembly-view/disassembly-view-instruction-renderer.d.ts +39 -0
  41. package/lib/browser/disassembly-view/disassembly-view-instruction-renderer.d.ts.map +1 -0
  42. package/lib/browser/disassembly-view/disassembly-view-instruction-renderer.js +223 -0
  43. package/lib/browser/disassembly-view/disassembly-view-instruction-renderer.js.map +1 -0
  44. package/lib/browser/disassembly-view/disassembly-view-table-delegate.d.ts +16 -0
  45. package/lib/browser/disassembly-view/disassembly-view-table-delegate.d.ts.map +1 -0
  46. package/lib/browser/disassembly-view/disassembly-view-table-delegate.js +39 -0
  47. package/lib/browser/disassembly-view/disassembly-view-table-delegate.js.map +1 -0
  48. package/lib/browser/disassembly-view/disassembly-view-utilities.d.ts +38 -0
  49. package/lib/browser/disassembly-view/disassembly-view-utilities.d.ts.map +1 -0
  50. package/lib/browser/disassembly-view/disassembly-view-utilities.js +18 -0
  51. package/lib/browser/disassembly-view/disassembly-view-utilities.js.map +1 -0
  52. package/lib/browser/disassembly-view/disassembly-view-widget.d.ts +61 -0
  53. package/lib/browser/disassembly-view/disassembly-view-widget.d.ts.map +1 -0
  54. package/lib/browser/disassembly-view/disassembly-view-widget.js +453 -0
  55. package/lib/browser/disassembly-view/disassembly-view-widget.js.map +1 -0
  56. package/lib/browser/model/debug-instruction-breakpoint.d.ts +15 -0
  57. package/lib/browser/model/debug-instruction-breakpoint.d.ts.map +1 -0
  58. package/lib/browser/model/debug-instruction-breakpoint.js +66 -0
  59. package/lib/browser/model/debug-instruction-breakpoint.js.map +1 -0
  60. package/lib/browser/model/debug-thread.d.ts +2 -0
  61. package/lib/browser/model/debug-thread.d.ts.map +1 -1
  62. package/lib/browser/model/debug-thread.js +5 -0
  63. package/lib/browser/model/debug-thread.js.map +1 -1
  64. package/lib/browser/view/debug-breakpoints-source.d.ts.map +1 -1
  65. package/lib/browser/view/debug-breakpoints-source.js +3 -0
  66. package/lib/browser/view/debug-breakpoints-source.js.map +1 -1
  67. package/lib/browser/view/debug-view-model.d.ts +2 -0
  68. package/lib/browser/view/debug-view-model.d.ts.map +1 -1
  69. package/lib/browser/view/debug-view-model.js +3 -0
  70. package/lib/browser/view/debug-view-model.js.map +1 -1
  71. package/lib/common/debug-service.d.ts +3 -2
  72. package/lib/common/debug-service.d.ts.map +1 -1
  73. package/lib/common/debug-service.js +0 -2
  74. package/lib/common/debug-service.js.map +1 -1
  75. package/package.json +14 -14
  76. package/src/browser/breakpoint/breakpoint-manager.ts +81 -7
  77. package/src/browser/breakpoint/breakpoint-marker.ts +17 -0
  78. package/src/browser/debug-frontend-application-contribution.ts +16 -4
  79. package/src/browser/debug-frontend-module.ts +2 -0
  80. package/src/browser/debug-preferences.ts +6 -0
  81. package/src/browser/debug-session-manager.ts +20 -4
  82. package/src/browser/debug-session.tsx +35 -8
  83. package/src/browser/disassembly-view/disassembly-view-accessibility-provider.ts +43 -0
  84. package/src/browser/disassembly-view/disassembly-view-breakpoint-renderer.ts +119 -0
  85. package/src/browser/disassembly-view/disassembly-view-contribution.ts +109 -0
  86. package/src/browser/disassembly-view/disassembly-view-instruction-renderer.ts +245 -0
  87. package/src/browser/disassembly-view/disassembly-view-table-delegate.ts +39 -0
  88. package/src/browser/disassembly-view/disassembly-view-utilities.ts +55 -0
  89. package/src/browser/disassembly-view/disassembly-view-widget.ts +464 -0
  90. package/src/browser/model/debug-instruction-breakpoint.tsx +68 -0
  91. package/src/browser/model/debug-thread.tsx +5 -0
  92. package/src/browser/view/debug-breakpoints-source.tsx +3 -0
  93. package/src/browser/view/debug-view-model.ts +6 -1
  94. package/src/common/debug-service.ts +4 -6
@@ -0,0 +1,55 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { IDisposable, IEvent } from '@theia/monaco-editor-core';
18
+ import { BareFontInfo } from '@theia/monaco-editor-core/esm/vs/editor/common/config/fontInfo';
19
+ import { DebugProtocol } from 'vscode-debugprotocol';
20
+
21
+ export interface DisassemblyViewRendererReference {
22
+ onDidChangeStackFrame: IEvent<void>;
23
+ isSourceCodeRender: boolean;
24
+ currentInstructionAddresses: Array<string | undefined>;
25
+ focusedInstructionAddress: string | undefined;
26
+ focusedCurrentInstructionAddress: string | undefined;
27
+ debugSession: { id: string } | undefined;
28
+ fontInfo: BareFontInfo;
29
+ }
30
+
31
+ // The rest of the file is adapted from https://github.com/microsoft/vscode/blob/c061ce5c24fc480342fbc5f23244289d633c56eb/src/vs/workbench/contrib/debug/browser/disassemblyView.ts
32
+ export interface DisassembledInstructionEntry {
33
+ allowBreakpoint: boolean;
34
+ isBreakpointSet: boolean;
35
+ isBreakpointEnabled: boolean;
36
+ instruction: DebugProtocol.DisassembledInstruction;
37
+ instructionAddress?: bigint;
38
+ }
39
+
40
+ export interface InstructionColumnTemplateData {
41
+ currentElement: { element?: DisassembledInstructionEntry };
42
+ // TODO: hover widget?
43
+ instruction: HTMLElement;
44
+ sourcecode: HTMLElement;
45
+ // disposed when cell is closed.
46
+ cellDisposable: IDisposable[];
47
+ // disposed when template is closed.
48
+ disposables: IDisposable[];
49
+ }
50
+
51
+ export interface BreakpointColumnTemplateData {
52
+ currentElement: { element?: DisassembledInstructionEntry };
53
+ icon: HTMLElement;
54
+ disposables: IDisposable[];
55
+ }
@@ -0,0 +1,464 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
+ import { BaseWidget, LabelProvider, Message, OpenerService, Widget } from '@theia/core/lib/browser';
19
+ import { ArrayUtils } from '@theia/core/lib/common/types';
20
+ import { DebugProtocol } from 'vscode-debugprotocol';
21
+ import { InstructionBreakpoint } from '../breakpoint/breakpoint-marker';
22
+ import { BreakpointManager } from '../breakpoint/breakpoint-manager';
23
+ import { DebugSessionManager } from '../debug-session-manager';
24
+ import { Emitter, IDisposable, IRange, Range, Uri } from '@theia/monaco-editor-core';
25
+ import { nls } from '@theia/core';
26
+ import { BareFontInfo } from '@theia/monaco-editor-core/esm/vs/editor/common/config/fontInfo';
27
+ import { WorkbenchTable } from '@theia/monaco-editor-core/esm/vs/platform/list/browser/listService';
28
+ import { DebugState, DebugSession } from '../debug-session';
29
+ import { EditorPreferences } from '@theia/editor/lib/browser';
30
+ import { PixelRatio } from '@theia/monaco-editor-core/esm/vs/base/browser/browser';
31
+ import { DebugPreferences } from '../debug-preferences';
32
+ import { DebugThread } from '../model/debug-thread';
33
+ import { Event } from '@theia/monaco-editor-core/esm/vs/base/common/event';
34
+ import { DisassembledInstructionEntry } from './disassembly-view-utilities';
35
+ import { DisassemblyViewTableDelegate } from './disassembly-view-table-delegate';
36
+ import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
37
+ import { InstructionRenderer } from './disassembly-view-instruction-renderer';
38
+ import { IInstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
39
+ import { BreakpointRenderer } from './disassembly-view-breakpoint-renderer';
40
+ import { AccessibilityProvider } from './disassembly-view-accessibility-provider';
41
+ import { editorBackground } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/colorRegistry';
42
+ import { Dimension } from '@theia/monaco-editor-core/esm/vs/base/browser/dom';
43
+ import { URI } from '@theia/core/lib/common/uri';
44
+
45
+ // This file is adapted from https://github.com/microsoft/vscode/blob/c061ce5c24fc480342fbc5f23244289d633c56eb/src/vs/workbench/contrib/debug/browser/disassemblyView.ts
46
+
47
+ // Special entry as a placeholer when disassembly is not available
48
+ const disassemblyNotAvailable: DisassembledInstructionEntry = {
49
+ allowBreakpoint: false,
50
+ isBreakpointSet: false,
51
+ isBreakpointEnabled: false,
52
+ instruction: {
53
+ address: '-1',
54
+ instruction: nls.localize('theia/debug/instructionNotAvailable', 'Disassembly not available.')
55
+ },
56
+ instructionAddress: BigInt(-1)
57
+ } as const;
58
+
59
+ @injectable()
60
+ export class DisassemblyViewWidget extends BaseWidget {
61
+ static readonly ID = 'disassembly-view-widget';
62
+ protected static readonly NUM_INSTRUCTIONS_TO_LOAD = 50;
63
+ protected readonly iconReferenceUri = new URI().withScheme('file').withPath('disassembly-view.disassembly-view');
64
+
65
+ @inject(BreakpointManager) protected readonly breakpointManager: BreakpointManager;
66
+ @inject(DebugSessionManager) protected readonly debugSessionManager: DebugSessionManager;
67
+ @inject(EditorPreferences) protected readonly editorPreferences: EditorPreferences;
68
+ @inject(DebugPreferences) protected readonly debugPreferences: DebugPreferences;
69
+ @inject(OpenerService) protected readonly openerService: OpenerService;
70
+ @inject(LabelProvider) protected readonly labelProvider: LabelProvider;
71
+
72
+ protected _fontInfo: BareFontInfo;
73
+ protected _disassembledInstructions: WorkbenchTable<DisassembledInstructionEntry> | undefined = undefined;
74
+ protected _onDidChangeStackFrame = new Emitter<void>();
75
+ protected _previousDebuggingState: DebugState;
76
+ protected _instructionBpList: readonly InstructionBreakpoint[] = [];
77
+ protected _enableSourceCodeRender: boolean = true;
78
+ protected _loadingLock: boolean = false;
79
+
80
+ @postConstruct()
81
+ protected init(): void {
82
+ this.id = DisassemblyViewWidget.ID;
83
+ this.addClass(DisassemblyViewWidget.ID);
84
+ this.title.closable = true;
85
+ this.title.label = 'Disassembly';
86
+ const updateIcon = () => this.title.iconClass = this.labelProvider.getIcon(this.iconReferenceUri) + ' file-icon';
87
+ updateIcon();
88
+ this.toDispose.push(this.labelProvider.onDidChange(updateIcon));
89
+ this.node.tabIndex = -1;
90
+ this.node.style.outline = 'none';
91
+ this._previousDebuggingState = this.debugSessionManager.currentSession?.state ?? DebugState.Inactive;
92
+ this._fontInfo = BareFontInfo.createFromRawSettings(this.toFontInfo(), PixelRatio.value);
93
+ this.editorPreferences.onPreferenceChanged(() => this._fontInfo = BareFontInfo.createFromRawSettings(this.toFontInfo(), PixelRatio.value));
94
+ this.debugPreferences.onPreferenceChanged(e => {
95
+ if (e.preferenceName === 'debug.disassemblyView.showSourceCode' && e.newValue !== this._enableSourceCodeRender) {
96
+ this._enableSourceCodeRender = e.newValue;
97
+ this.reloadDisassembly(undefined);
98
+ } else {
99
+ this._disassembledInstructions?.rerender();
100
+ }
101
+ });
102
+ this.createPane();
103
+ }
104
+
105
+ get fontInfo(): BareFontInfo { return this._fontInfo; }
106
+
107
+ get currentInstructionAddresses(): Array<string | undefined> {
108
+ return this.debugSessionManager.sessions
109
+ .map(session => session.getThreads(() => true))
110
+ .reduce<DebugThread[]>((prev, curr) => prev.concat(Array.from(curr)), [])
111
+ .map(thread => thread.topFrame)
112
+ .map(frame => frame?.raw.instructionPointerReference);
113
+ }
114
+
115
+ get focusedCurrentInstructionAddress(): string | undefined {
116
+ return this.debugSessionManager.currentFrame?.thread.topFrame?.raw.instructionPointerReference;
117
+ }
118
+
119
+ get isSourceCodeRender(): boolean { return this._enableSourceCodeRender; }
120
+
121
+ get debugSession(): DebugSession | undefined { return this.debugSessionManager.currentSession; }
122
+
123
+ get focusedInstructionAddress(): string | undefined {
124
+ return this.debugSessionManager.currentFrame?.raw.instructionPointerReference;
125
+ }
126
+
127
+ get onDidChangeStackFrame(): Event<void> { return this._onDidChangeStackFrame.event; }
128
+
129
+ protected createPane(): void {
130
+ this._enableSourceCodeRender = this.debugPreferences['debug.disassemblyView.showSourceCode'];
131
+ const monacoInstantiationService = StandaloneServices.initialize({});
132
+ const tableDelegate = new DisassemblyViewTableDelegate(this);
133
+ const instructionRenderer = monacoInstantiationService.createInstance(InstructionRenderer, this, this.openerService, { asCanonicalUri(thing: Uri): Uri { return thing; } });
134
+ this.toDispose.push(instructionRenderer);
135
+ this.getTable(monacoInstantiationService, tableDelegate, instructionRenderer);
136
+ this.reloadDisassembly();
137
+ this._register(this._disassembledInstructions!.onDidScroll(e => {
138
+ if (this._loadingLock) {
139
+ return;
140
+ }
141
+
142
+ if (e.oldScrollTop > e.scrollTop && e.scrollTop < e.height) {
143
+ this._loadingLock = true;
144
+ const topElement = Math.floor(e.scrollTop / this.fontInfo.lineHeight) + DisassemblyViewWidget.NUM_INSTRUCTIONS_TO_LOAD;
145
+ this.scrollUp_LoadDisassembledInstructions(DisassemblyViewWidget.NUM_INSTRUCTIONS_TO_LOAD).then(success => {
146
+ if (success) {
147
+ this._disassembledInstructions!.reveal(topElement, 0);
148
+ }
149
+ this._loadingLock = false;
150
+ });
151
+ } else if (e.oldScrollTop < e.scrollTop && e.scrollTop + e.height > e.scrollHeight - e.height) {
152
+ this._loadingLock = true;
153
+ this.scrollDown_LoadDisassembledInstructions(DisassemblyViewWidget.NUM_INSTRUCTIONS_TO_LOAD).then(() => { this._loadingLock = false; });
154
+ }
155
+ }));
156
+ this._register(this.debugSessionManager.onDidFocusStackFrame(() => {
157
+ if (this._disassembledInstructions) {
158
+ this.goToAddress();
159
+ this._onDidChangeStackFrame.fire();
160
+ }
161
+ }));
162
+ this._register(this.breakpointManager.onDidChangeInstructionBreakpoints(bpEvent => {
163
+ if (bpEvent && this._disassembledInstructions) {
164
+ // draw viewable BP
165
+ let changed = false;
166
+ bpEvent.added?.forEach(bp => {
167
+ if (InstructionBreakpoint.is(bp)) {
168
+ const index = this.getIndexFromAddress(bp.instructionReference);
169
+ if (index >= 0) {
170
+ this._disassembledInstructions!.row(index).isBreakpointSet = true;
171
+ this._disassembledInstructions!.row(index).isBreakpointEnabled = bp.enabled;
172
+ changed = true;
173
+ }
174
+ }
175
+ });
176
+
177
+ bpEvent.removed?.forEach(bp => {
178
+ if (InstructionBreakpoint.is(bp)) {
179
+ const index = this.getIndexFromAddress(bp.instructionReference);
180
+ if (index >= 0) {
181
+ this._disassembledInstructions!.row(index).isBreakpointSet = false;
182
+ changed = true;
183
+ }
184
+ }
185
+ });
186
+
187
+ bpEvent.changed?.forEach(bp => {
188
+ if (InstructionBreakpoint.is(bp)) {
189
+ const index = this.getIndexFromAddress(bp.instructionReference);
190
+ if (index >= 0) {
191
+ if (this._disassembledInstructions!.row(index).isBreakpointEnabled !== bp.enabled) {
192
+ this._disassembledInstructions!.row(index).isBreakpointEnabled = bp.enabled;
193
+ changed = true;
194
+ }
195
+ }
196
+ }
197
+ });
198
+
199
+ // get an updated list so that items beyond the current range would render when reached.
200
+ this._instructionBpList = this.breakpointManager.getInstructionBreakpoints();
201
+
202
+ if (changed) {
203
+ this._onDidChangeStackFrame.fire();
204
+ }
205
+ }
206
+ }));
207
+
208
+ // This would like to be more specific: onDidChangeState
209
+ this._register(this.debugSessionManager.onDidChange(() => {
210
+ const state = this.debugSession?.state;
211
+
212
+ if ((state === DebugState.Running || state === DebugState.Stopped) &&
213
+ (this._previousDebuggingState !== DebugState.Running && this._previousDebuggingState !== DebugState.Stopped)) {
214
+ // Just started debugging, clear the view
215
+ this._disassembledInstructions?.splice(0, this._disassembledInstructions.length, [disassemblyNotAvailable]);
216
+ this._enableSourceCodeRender = this.debugPreferences['debug.disassemblyView.showSourceCode'];
217
+ }
218
+ if (state !== undefined && state !== this._previousDebuggingState) {
219
+ this._previousDebuggingState = state;
220
+ }
221
+ }));
222
+ }
223
+
224
+ protected getTable(
225
+ monacoInstantiationService: IInstantiationService,
226
+ tableDelegate: DisassemblyViewTableDelegate,
227
+ instructionRenderer: InstructionRenderer
228
+ ): WorkbenchTable<DisassembledInstructionEntry> {
229
+ return this._disassembledInstructions = this._register(monacoInstantiationService.createInstance(WorkbenchTable,
230
+ 'DisassemblyView', this.node, tableDelegate,
231
+ [
232
+ {
233
+ label: '',
234
+ tooltip: '',
235
+ weight: 0,
236
+ minimumWidth: this.fontInfo.lineHeight,
237
+ maximumWidth: this.fontInfo.lineHeight,
238
+ templateId: BreakpointRenderer.TEMPLATE_ID,
239
+ project(row: DisassembledInstructionEntry): DisassembledInstructionEntry { return row; }
240
+ },
241
+ {
242
+ label: nls.localize('theia/disassembly-view/disassemblyTableColumnLabel', 'instructions'),
243
+ tooltip: '',
244
+ weight: 0.3,
245
+ templateId: InstructionRenderer.TEMPLATE_ID,
246
+ project(row: DisassembledInstructionEntry): DisassembledInstructionEntry { return row; }
247
+ },
248
+ ],
249
+ [
250
+ new BreakpointRenderer(this, this.breakpointManager),
251
+ instructionRenderer,
252
+ ],
253
+ {
254
+ identityProvider: { getId: (e: DisassembledInstructionEntry) => e.instruction.address },
255
+ horizontalScrolling: false,
256
+ overrideStyles: {
257
+ listBackground: editorBackground
258
+ },
259
+ multipleSelectionSupport: false,
260
+ setRowLineHeight: false,
261
+ openOnSingleClick: false,
262
+ accessibilityProvider: new AccessibilityProvider(),
263
+ mouseSupport: false
264
+ }
265
+ )) as WorkbenchTable<DisassembledInstructionEntry>;
266
+ }
267
+
268
+ adjustLayout(dimension: Dimension): void {
269
+ if (this._disassembledInstructions) {
270
+ this._disassembledInstructions.layout(dimension.height);
271
+ }
272
+ }
273
+
274
+ goToAddress(address?: string, focus?: boolean): void {
275
+ if (!this._disassembledInstructions) {
276
+ return;
277
+ }
278
+
279
+ if (!address) {
280
+ address = this.focusedInstructionAddress;
281
+ }
282
+ if (!address) {
283
+ return;
284
+ }
285
+
286
+ const index = this.getIndexFromAddress(address);
287
+ if (index >= 0) {
288
+ this._disassembledInstructions.reveal(index);
289
+
290
+ if (focus) {
291
+ this._disassembledInstructions.domFocus();
292
+ this._disassembledInstructions.setFocus([index]);
293
+ }
294
+ } else if (this.debugSessionManager.state === DebugState.Stopped) {
295
+ // Address is not provided or not in the table currently, clear the table
296
+ // and reload if we are in the state where we can load disassembly.
297
+ this.reloadDisassembly(address);
298
+ }
299
+ }
300
+
301
+ protected async scrollUp_LoadDisassembledInstructions(instructionCount: number): Promise<boolean> {
302
+ if (this._disassembledInstructions && this._disassembledInstructions.length > 0) {
303
+ const address: string | undefined = this._disassembledInstructions?.row(0).instruction.address;
304
+ return this.loadDisassembledInstructions(address, -instructionCount, instructionCount);
305
+ }
306
+
307
+ return false;
308
+ }
309
+
310
+ protected async scrollDown_LoadDisassembledInstructions(instructionCount: number): Promise<boolean> {
311
+ if (this._disassembledInstructions && this._disassembledInstructions.length > 0) {
312
+ const address: string | undefined = this._disassembledInstructions?.row(this._disassembledInstructions?.length - 1).instruction.address;
313
+ return this.loadDisassembledInstructions(address, 1, instructionCount);
314
+ }
315
+
316
+ return false;
317
+ }
318
+
319
+ protected async loadDisassembledInstructions(memoryReference: string | undefined, instructionOffset: number, instructionCount: number): Promise<boolean> {
320
+ // if address is null, then use current stack frame.
321
+ if (!memoryReference || memoryReference === '-1') {
322
+ memoryReference = this.focusedInstructionAddress;
323
+ }
324
+ if (!memoryReference) {
325
+ return false;
326
+ }
327
+
328
+ const session = this.debugSession;
329
+ const resultEntries = (await session?.sendRequest('disassemble', {
330
+ instructionCount,
331
+ memoryReference,
332
+ instructionOffset,
333
+ offset: 0,
334
+ resolveSymbols: true,
335
+ }))?.body?.instructions;
336
+ if (session && resultEntries && this._disassembledInstructions) {
337
+ const newEntries: DisassembledInstructionEntry[] = [];
338
+ const allowBreakpoint = Boolean(session.capabilities.supportsInstructionBreakpoints);
339
+
340
+ let lastLocation: DebugProtocol.Source | undefined;
341
+ let lastLine: IRange | undefined;
342
+ for (let i = 0; i < resultEntries.length; i++) {
343
+ const found = this._instructionBpList.find(p => p.instructionReference === resultEntries[i].address);
344
+ const instruction = resultEntries[i];
345
+
346
+ // Forward fill the missing location as detailed in the DAP spec.
347
+ if (instruction.location) {
348
+ lastLocation = instruction.location;
349
+ lastLine = undefined;
350
+ }
351
+
352
+ if (instruction.line) {
353
+ const currentLine: IRange = {
354
+ startLineNumber: instruction.line,
355
+ startColumn: instruction.column ?? 0,
356
+ endLineNumber: instruction.endLine ?? instruction.line!,
357
+ endColumn: instruction.endColumn ?? 0,
358
+ };
359
+
360
+ // Add location only to the first unique range. This will give the appearance of grouping of instructions.
361
+ if (!Range.equalsRange(currentLine, lastLine ?? null)) { // eslint-disable-line no-null/no-null
362
+ lastLine = currentLine;
363
+ instruction.location = lastLocation;
364
+ }
365
+ }
366
+
367
+ newEntries.push({ allowBreakpoint, isBreakpointSet: found !== undefined, isBreakpointEnabled: !!found?.enabled, instruction: instruction });
368
+ }
369
+
370
+ const specialEntriesToRemove = this._disassembledInstructions.length === 1 ? 1 : 0;
371
+
372
+ // request is either at the start or end
373
+ if (instructionOffset >= 0) {
374
+ this._disassembledInstructions.splice(this._disassembledInstructions.length, specialEntriesToRemove, newEntries);
375
+ } else {
376
+ this._disassembledInstructions.splice(0, specialEntriesToRemove, newEntries);
377
+ }
378
+
379
+ return true;
380
+ }
381
+
382
+ return false;
383
+ }
384
+
385
+ protected getIndexFromAddress(instructionAddress: string): number {
386
+ const disassembledInstructions = this._disassembledInstructions;
387
+ if (disassembledInstructions && disassembledInstructions.length > 0) {
388
+ const address = BigInt(instructionAddress);
389
+ if (address) {
390
+ return ArrayUtils.binarySearch2(disassembledInstructions.length, index => {
391
+ const row = disassembledInstructions.row(index);
392
+
393
+ this.ensureAddressParsed(row);
394
+ if (row.instructionAddress! > address) {
395
+ return 1;
396
+ } else if (row.instructionAddress! < address) {
397
+ return -1;
398
+ } else {
399
+ return 0;
400
+ }
401
+ });
402
+ }
403
+ }
404
+
405
+ return -1;
406
+ }
407
+
408
+ protected ensureAddressParsed(entry: DisassembledInstructionEntry): void {
409
+ if (entry.instructionAddress !== undefined) {
410
+ return;
411
+ } else {
412
+ entry.instructionAddress = BigInt(entry.instruction.address);
413
+ }
414
+ }
415
+
416
+ /**
417
+ * Clears the table and reload instructions near the target address
418
+ */
419
+ protected reloadDisassembly(targetAddress?: string): void {
420
+ if (this._disassembledInstructions) {
421
+ this._loadingLock = true; // stop scrolling during the load.
422
+ this._disassembledInstructions.splice(0, this._disassembledInstructions.length, [disassemblyNotAvailable]);
423
+ this._instructionBpList = this.breakpointManager.getInstructionBreakpoints();
424
+ this.loadDisassembledInstructions(targetAddress, -DisassemblyViewWidget.NUM_INSTRUCTIONS_TO_LOAD * 4, DisassemblyViewWidget.NUM_INSTRUCTIONS_TO_LOAD * 8).then(() => {
425
+ // on load, set the target instruction in the middle of the page.
426
+ if (this._disassembledInstructions!.length > 0) {
427
+ const targetIndex = Math.floor(this._disassembledInstructions!.length / 2);
428
+ this._disassembledInstructions!.reveal(targetIndex, 0.5);
429
+
430
+ // Always focus the target address on reload, or arrow key navigation would look terrible
431
+ this._disassembledInstructions!.domFocus();
432
+ this._disassembledInstructions!.setFocus([targetIndex]);
433
+ }
434
+ this._loadingLock = false;
435
+ });
436
+ }
437
+ }
438
+
439
+ protected override onResize(msg: Widget.ResizeMessage): void {
440
+ this.adjustLayout(new Dimension(msg.width, msg.height));
441
+ }
442
+
443
+ protected override onActivateRequest(msg: Message): void {
444
+ this.node.focus();
445
+ super.onActivateRequest(msg);
446
+ }
447
+
448
+ protected toFontInfo(): Parameters<typeof BareFontInfo.createFromRawSettings>[0] {
449
+ return {
450
+ fontFamily: this.editorPreferences['editor.fontFamily'],
451
+ fontWeight: String(this.editorPreferences['editor.fontWeight']),
452
+ fontSize: this.editorPreferences['editor.fontSize'],
453
+ fontLigatures: this.editorPreferences['editor.fontLigatures'],
454
+ lineHeight: this.editorPreferences['editor.lineHeight'],
455
+ letterSpacing: this.editorPreferences['editor.letterSpacing'],
456
+ };
457
+ }
458
+
459
+ protected _register<T extends IDisposable>(disposable: T): T {
460
+ this.toDispose.push(disposable);
461
+ return disposable;
462
+ }
463
+ }
464
+
@@ -0,0 +1,68 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { nls } from '@theia/core';
18
+ import * as React from '@theia/core/shared/react';
19
+ import { BreakpointManager } from '../breakpoint/breakpoint-manager';
20
+ import { InstructionBreakpoint } from '../breakpoint/breakpoint-marker';
21
+ import { DebugBreakpoint, DebugBreakpointDecoration, DebugBreakpointOptions } from './debug-breakpoint';
22
+
23
+ export class DebugInstructionBreakpoint extends DebugBreakpoint<InstructionBreakpoint> {
24
+ constructor(readonly origin: InstructionBreakpoint, options: DebugBreakpointOptions) {
25
+ super(BreakpointManager.INSTRUCTION_URI, options);
26
+ }
27
+
28
+ setEnabled(enabled: boolean): void {
29
+ if (enabled !== this.origin.enabled) {
30
+ this.breakpoints.updateInstructionBreakpoint(this.origin.id, { enabled });
31
+ }
32
+ }
33
+
34
+ protected override isEnabled(): boolean {
35
+ return super.isEnabled() && this.isSupported();
36
+ }
37
+
38
+ protected isSupported(): boolean {
39
+ return Boolean(this.session?.capabilities.supportsInstructionBreakpoints);
40
+ }
41
+
42
+ remove(): void {
43
+ this.breakpoints.removeInstructionBreakpoint(this.origin.instructionReference);
44
+ }
45
+
46
+ protected doRender(): React.ReactNode {
47
+ return <span className="line-info">{this.origin.instructionReference}</span>;
48
+ }
49
+
50
+ protected getBreakpointDecoration(message?: string[]): DebugBreakpointDecoration {
51
+ if (!this.isSupported()) {
52
+ return {
53
+ className: 'codicon-debug-breakpoint-unsupported',
54
+ message: message ?? [nls.localize('theia/debug/instruction-breakpoint', 'Instruction Breakpoint')],
55
+ };
56
+ }
57
+ if (this.origin.condition || this.origin.hitCondition) {
58
+ return {
59
+ className: 'codicon-debug-breakpoint-conditional',
60
+ message: message || [nls.localizeByDefault('Conditional Breakpoint...')]
61
+ };
62
+ }
63
+ return {
64
+ className: 'codicon-debug-breakpoint',
65
+ message: message || [nls.localize('theia/debug/instruction-breakpoint', 'Instruction Breakpoint')]
66
+ };
67
+ }
68
+ }
@@ -41,6 +41,10 @@ export class DebugThread extends DebugThreadData implements TreeElement {
41
41
 
42
42
  protected readonly onDidChangedEmitter = new Emitter<void>();
43
43
  readonly onDidChanged: Event<void> = this.onDidChangedEmitter.event;
44
+ protected readonly onDidFocusStackFrameEmitter = new Emitter<DebugStackFrame | undefined>();
45
+ get onDidFocusStackFrame(): Event<DebugStackFrame | undefined> {
46
+ return this.onDidFocusStackFrameEmitter.event;
47
+ }
44
48
 
45
49
  constructor(
46
50
  readonly session: DebugSession
@@ -59,6 +63,7 @@ export class DebugThread extends DebugThreadData implements TreeElement {
59
63
  set currentFrame(frame: DebugStackFrame | undefined) {
60
64
  this._currentFrame = frame;
61
65
  this.onDidChangedEmitter.fire(undefined);
66
+ this.onDidFocusStackFrameEmitter.fire(frame);
62
67
  }
63
68
 
64
69
  get stopped(): boolean {
@@ -42,6 +42,9 @@ export class DebugBreakpointsSource extends TreeSource {
42
42
  for (const functionBreakpoint of this.model.functionBreakpoints) {
43
43
  yield functionBreakpoint;
44
44
  }
45
+ for (const instructionBreakpoint of this.model.instructionBreakpoints) {
46
+ yield instructionBreakpoint;
47
+ }
45
48
  for (const breakpoint of this.model.breakpoints) {
46
49
  yield breakpoint;
47
50
  }
@@ -26,6 +26,7 @@ import { DebugSourceBreakpoint } from '../model/debug-source-breakpoint';
26
26
  import { DebugWatchExpression } from './debug-watch-expression';
27
27
  import { DebugWatchManager } from '../debug-watch-manager';
28
28
  import { DebugFunctionBreakpoint } from '../model/debug-function-breakpoint';
29
+ import { DebugInstructionBreakpoint } from '../model/debug-instruction-breakpoint';
29
30
 
30
31
  @injectable()
31
32
  export class DebugViewModel implements Disposable {
@@ -54,7 +55,7 @@ export class DebugViewModel implements Disposable {
54
55
  protected readonly toDispose = new DisposableCollection(
55
56
  this.onDidChangeEmitter,
56
57
  this.onDidChangeBreakpointsEmitter,
57
- this.onDidChangeWatchExpressionsEmitter
58
+ this.onDidChangeWatchExpressionsEmitter,
58
59
  );
59
60
 
60
61
  @inject(DebugSessionManager)
@@ -131,6 +132,10 @@ export class DebugViewModel implements Disposable {
131
132
  return this.manager.getFunctionBreakpoints(this.currentSession);
132
133
  }
133
134
 
135
+ get instructionBreakpoints(): DebugInstructionBreakpoint[] {
136
+ return this.manager.getInstructionBreakpoints(this.currentSession);
137
+ }
138
+
134
139
  async start(): Promise<void> {
135
140
  const { session } = this;
136
141
  if (!session) {