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

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 (102) 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 +12 -3
  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/editor/debug-inline-value-decorator.js +3 -3
  57. package/lib/browser/editor/debug-inline-value-decorator.js.map +1 -1
  58. package/lib/browser/model/debug-instruction-breakpoint.d.ts +15 -0
  59. package/lib/browser/model/debug-instruction-breakpoint.d.ts.map +1 -0
  60. package/lib/browser/model/debug-instruction-breakpoint.js +66 -0
  61. package/lib/browser/model/debug-instruction-breakpoint.js.map +1 -0
  62. package/lib/browser/model/debug-thread.d.ts +2 -0
  63. package/lib/browser/model/debug-thread.d.ts.map +1 -1
  64. package/lib/browser/model/debug-thread.js +5 -0
  65. package/lib/browser/model/debug-thread.js.map +1 -1
  66. package/lib/browser/view/debug-breakpoints-source.d.ts.map +1 -1
  67. package/lib/browser/view/debug-breakpoints-source.js +3 -0
  68. package/lib/browser/view/debug-breakpoints-source.js.map +1 -1
  69. package/lib/browser/view/debug-toolbar-widget.d.ts +2 -0
  70. package/lib/browser/view/debug-toolbar-widget.d.ts.map +1 -1
  71. package/lib/browser/view/debug-toolbar-widget.js +1 -0
  72. package/lib/browser/view/debug-toolbar-widget.js.map +1 -1
  73. package/lib/browser/view/debug-view-model.d.ts +2 -0
  74. package/lib/browser/view/debug-view-model.d.ts.map +1 -1
  75. package/lib/browser/view/debug-view-model.js +3 -0
  76. package/lib/browser/view/debug-view-model.js.map +1 -1
  77. package/lib/common/debug-service.d.ts +3 -2
  78. package/lib/common/debug-service.d.ts.map +1 -1
  79. package/lib/common/debug-service.js +0 -2
  80. package/lib/common/debug-service.js.map +1 -1
  81. package/package.json +15 -15
  82. package/src/browser/breakpoint/breakpoint-manager.ts +81 -7
  83. package/src/browser/breakpoint/breakpoint-marker.ts +17 -0
  84. package/src/browser/debug-frontend-application-contribution.ts +16 -4
  85. package/src/browser/debug-frontend-module.ts +2 -0
  86. package/src/browser/debug-preferences.ts +6 -0
  87. package/src/browser/debug-session-manager.ts +21 -6
  88. package/src/browser/debug-session.tsx +35 -8
  89. package/src/browser/disassembly-view/disassembly-view-accessibility-provider.ts +43 -0
  90. package/src/browser/disassembly-view/disassembly-view-breakpoint-renderer.ts +119 -0
  91. package/src/browser/disassembly-view/disassembly-view-contribution.ts +109 -0
  92. package/src/browser/disassembly-view/disassembly-view-instruction-renderer.ts +245 -0
  93. package/src/browser/disassembly-view/disassembly-view-table-delegate.ts +39 -0
  94. package/src/browser/disassembly-view/disassembly-view-utilities.ts +55 -0
  95. package/src/browser/disassembly-view/disassembly-view-widget.ts +464 -0
  96. package/src/browser/editor/debug-inline-value-decorator.ts +3 -3
  97. package/src/browser/model/debug-instruction-breakpoint.tsx +68 -0
  98. package/src/browser/model/debug-thread.tsx +5 -0
  99. package/src/browser/view/debug-breakpoints-source.tsx +3 -0
  100. package/src/browser/view/debug-toolbar-widget.tsx +3 -1
  101. package/src/browser/view/debug-view-model.ts +6 -1
  102. package/src/common/debug-service.ts +4 -6
@@ -14,8 +14,6 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- /* eslint-disable @typescript-eslint/no-explicit-any */
18
-
19
17
  import { DisposableCollection, Emitter, Event, MessageService, ProgressService, WaitUntilEvent } from '@theia/core';
20
18
  import { LabelProvider, ApplicationShell } from '@theia/core/lib/browser';
21
19
  import { ContextKey, ContextKeyService } from '@theia/core/lib/browser/context-key-service';
@@ -38,6 +36,7 @@ import { TaskIdentifier } from '@theia/task/lib/common';
38
36
  import { DebugSourceBreakpoint } from './model/debug-source-breakpoint';
39
37
  import { DebugFunctionBreakpoint } from './model/debug-function-breakpoint';
40
38
  import * as monaco from '@theia/monaco-editor-core';
39
+ import { DebugInstructionBreakpoint } from './model/debug-instruction-breakpoint';
41
40
 
42
41
  export interface WillStartDebugSession extends WaitUntilEvent {
43
42
  }
@@ -56,8 +55,13 @@ export interface DidChangeBreakpointsEvent {
56
55
  uri: URI
57
56
  }
58
57
 
58
+ export interface DidFocusStackFrameEvent {
59
+ session: DebugSession;
60
+ frame: DebugStackFrame | undefined;
61
+ }
62
+
59
63
  export interface DebugSessionCustomEvent {
60
- readonly body?: any
64
+ readonly body?: any // eslint-disable-line @typescript-eslint/no-explicit-any
61
65
  readonly event: string
62
66
  readonly session: DebugSession
63
67
  }
@@ -90,8 +94,11 @@ export class DebugSessionManager {
90
94
  protected readonly onDidReceiveDebugSessionCustomEventEmitter = new Emitter<DebugSessionCustomEvent>();
91
95
  readonly onDidReceiveDebugSessionCustomEvent: Event<DebugSessionCustomEvent> = this.onDidReceiveDebugSessionCustomEventEmitter.event;
92
96
 
97
+ protected readonly onDidFocusStackFrameEmitter = new Emitter<DidFocusStackFrameEvent>();
98
+ readonly onDidFocusStackFrame = this.onDidFocusStackFrameEmitter.event;
99
+
93
100
  protected readonly onDidChangeBreakpointsEmitter = new Emitter<DidChangeBreakpointsEvent>();
94
- readonly onDidChangeBreakpoints: Event<DidChangeBreakpointsEvent> = this.onDidChangeBreakpointsEmitter.event;
101
+ readonly onDidChangeBreakpoints = this.onDidChangeBreakpointsEmitter.event;
95
102
  protected fireDidChangeBreakpoints(event: DidChangeBreakpointsEvent): void {
96
103
  this.onDidChangeBreakpointsEmitter.fire(event);
97
104
  }
@@ -250,8 +257,7 @@ export class DebugSessionManager {
250
257
  context: options.workspaceFolderUri ? new URI(options.workspaceFolderUri) : undefined,
251
258
  configurationSection: 'launch',
252
259
  commandIdVariables,
253
- configuration,
254
- checkAllResolved: true
260
+ configuration
255
261
  });
256
262
 
257
263
  if (configuration) {
@@ -417,6 +423,7 @@ export class DebugSessionManager {
417
423
  }
418
424
  this.fireDidChange(current);
419
425
  }));
426
+ this.disposeOnCurrentSessionChanged.push(current.onDidFocusStackFrame(frame => this.onDidFocusStackFrameEmitter.fire({ session: current, frame })));
420
427
  }
421
428
  this.updateBreakpoints(previous, current);
422
429
  this.open();
@@ -475,6 +482,14 @@ export class DebugSessionManager {
475
482
  return this.breakpoints.getFunctionBreakpoints().map(origin => new DebugFunctionBreakpoint(origin, { labelProvider, breakpoints, editorManager }));
476
483
  }
477
484
 
485
+ getInstructionBreakpoints(session = this.currentSession): DebugInstructionBreakpoint[] {
486
+ if (session && session.state > DebugState.Initializing) {
487
+ return session.getInstructionBreakpoints();
488
+ }
489
+ const { labelProvider, breakpoints, editorManager } = this;
490
+ return this.breakpoints.getInstructionBreakpoints().map(origin => new DebugInstructionBreakpoint(origin, { labelProvider, breakpoints, editorManager }));
491
+ }
492
+
478
493
  getBreakpoints(session?: DebugSession): DebugSourceBreakpoint[];
479
494
  getBreakpoints(uri: URI, session?: DebugSession): DebugSourceBreakpoint[];
480
495
  getBreakpoints(arg?: URI | DebugSession, arg2?: DebugSession): DebugSourceBreakpoint[] {
@@ -42,6 +42,7 @@ import { FileService } from '@theia/filesystem/lib/browser/file-service';
42
42
  import { DebugContribution } from './debug-contribution';
43
43
  import { waitForEvent } from '@theia/core/lib/common/promise-util';
44
44
  import { WorkspaceService } from '@theia/workspace/lib/browser';
45
+ import { DebugInstructionBreakpoint } from './model/debug-instruction-breakpoint';
45
46
 
46
47
  export enum DebugState {
47
48
  Inactive,
@@ -57,6 +58,10 @@ export class DebugSession implements CompositeTreeElement {
57
58
  protected fireDidChange(): void {
58
59
  this.onDidChangeEmitter.fire(undefined);
59
60
  }
61
+ protected readonly onDidFocusStackFrameEmitter = new Emitter<DebugStackFrame | undefined>();
62
+ get onDidFocusStackFrame(): Event<DebugStackFrame | undefined> {
63
+ return this.onDidFocusStackFrameEmitter.event;
64
+ }
60
65
 
61
66
  protected readonly onDidChangeBreakpointsEmitter = new Emitter<URI>();
62
67
  readonly onDidChangeBreakpoints: Event<URI> = this.onDidChangeBreakpointsEmitter.event;
@@ -235,6 +240,7 @@ export class DebugSession implements CompositeTreeElement {
235
240
  this.fireDidChange();
236
241
  if (thread) {
237
242
  this.toDisposeOnCurrentThread.push(thread.onDidChanged(() => this.fireDidChange()));
243
+ this.toDisposeOnCurrentThread.push(thread.onDidFocusStackFrame(frame => this.onDidFocusStackFrameEmitter.fire(frame)));
238
244
 
239
245
  // If this thread is missing stack frame information, then load that.
240
246
  this.updateFrames();
@@ -513,13 +519,15 @@ export class DebugSession implements CompositeTreeElement {
513
519
  }
514
520
 
515
521
  getFunctionBreakpoints(): DebugFunctionBreakpoint[] {
516
- const breakpoints = [];
517
- for (const breakpoint of this.getBreakpoints(BreakpointManager.FUNCTION_URI)) {
518
- if (breakpoint instanceof DebugFunctionBreakpoint) {
519
- breakpoints.push(breakpoint);
520
- }
522
+ return this.getBreakpoints(BreakpointManager.FUNCTION_URI).filter((breakpoint): breakpoint is DebugFunctionBreakpoint => breakpoint instanceof DebugFunctionBreakpoint);
523
+ }
524
+
525
+ getInstructionBreakpoints(): DebugInstructionBreakpoint[] {
526
+ if (this.capabilities.supportsInstructionBreakpoints) {
527
+ return this.getBreakpoints(BreakpointManager.FUNCTION_URI)
528
+ .filter((breakpoint): breakpoint is DebugInstructionBreakpoint => breakpoint instanceof DebugInstructionBreakpoint);
521
529
  }
522
- return breakpoints;
530
+ return this.breakpoints.getInstructionBreakpoints().map(origin => new DebugInstructionBreakpoint(origin, this.asDebugBreakpointOptions()));
523
531
  }
524
532
 
525
533
  getBreakpoints(uri?: URI): DebugBreakpoint[] {
@@ -614,6 +622,8 @@ export class DebugSession implements CompositeTreeElement {
614
622
  await this.sendExceptionBreakpoints();
615
623
  } else if (affectedUri.toString() === BreakpointManager.FUNCTION_URI.toString()) {
616
624
  await this.sendFunctionBreakpoints(affectedUri);
625
+ } else if (affectedUri.toString() === BreakpointManager.INSTRUCTION_URI.toString()) {
626
+ await this.sendInstructionBreakpoints();
617
627
  } else {
618
628
  await this.sendSourceBreakpoints(affectedUri, sourceModified);
619
629
  }
@@ -640,7 +650,7 @@ export class DebugSession implements CompositeTreeElement {
640
650
  const response = await this.sendRequest('setFunctionBreakpoints', {
641
651
  breakpoints: enabled.map(b => b.origin.raw)
642
652
  });
643
- response.body.breakpoints.map((raw, index) => {
653
+ response.body.breakpoints.forEach((raw, index) => {
644
654
  // node debug adapter returns more breakpoints sometimes
645
655
  if (enabled[index]) {
646
656
  enabled[index].update({ raw });
@@ -679,7 +689,7 @@ export class DebugSession implements CompositeTreeElement {
679
689
  sourceModified,
680
690
  breakpoints: enabled.map(({ origin }) => origin.raw)
681
691
  });
682
- response.body.breakpoints.map((raw, index) => {
692
+ response.body.breakpoints.forEach((raw, index) => {
683
693
  // node debug adapter returns more breakpoints sometimes
684
694
  if (enabled[index]) {
685
695
  enabled[index].update({ raw });
@@ -705,6 +715,23 @@ export class DebugSession implements CompositeTreeElement {
705
715
  this.setSourceBreakpoints(affectedUri, all);
706
716
  }
707
717
 
718
+ protected async sendInstructionBreakpoints(): Promise<void> {
719
+ if (!this.capabilities.supportsInstructionBreakpoints) {
720
+ return;
721
+ }
722
+ const all = this.breakpoints.getInstructionBreakpoints().map(breakpoint => new DebugInstructionBreakpoint(breakpoint, this.asDebugBreakpointOptions()));
723
+ const enabled = all.filter(breakpoint => breakpoint.enabled);
724
+ try {
725
+ const response = await this.sendRequest('setInstructionBreakpoints', {
726
+ breakpoints: enabled.map(renderable => renderable.origin),
727
+ });
728
+ response.body.breakpoints.forEach((raw, index) => enabled[index]?.update({ raw }));
729
+ } catch {
730
+ enabled.forEach(breakpoint => breakpoint.update({ raw: { verified: false } }));
731
+ }
732
+ this.setBreakpoints(BreakpointManager.INSTRUCTION_URI, all);
733
+ }
734
+
708
735
  protected setBreakpoints(uri: URI, breakpoints: DebugBreakpoint[]): void {
709
736
  this._breakpoints.set(uri.toString(), breakpoints);
710
737
  this.fireDidChangeBreakpoints(uri);
@@ -0,0 +1,43 @@
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 { IListAccessibilityProvider } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/listWidget';
19
+ import { DisassembledInstructionEntry } from './disassembly-view-utilities';
20
+
21
+ // This file is adapted from https://github.com/microsoft/vscode/blob/c061ce5c24fc480342fbc5f23244289d633c56eb/src/vs/workbench/contrib/debug/browser/disassemblyView.ts
22
+
23
+ export class AccessibilityProvider implements IListAccessibilityProvider<DisassembledInstructionEntry> {
24
+
25
+ getWidgetAriaLabel(): string {
26
+ return nls.localize('disassemblyView', 'Disassembly View');
27
+ }
28
+
29
+ getAriaLabel(element: DisassembledInstructionEntry): string | null {
30
+ let label = '';
31
+
32
+ const instruction = element.instruction;
33
+ if (instruction.address !== '-1') {
34
+ label += `${nls.localize('theia/debug/instructionAddress', 'Address')}: ${instruction.address}`;
35
+ }
36
+ if (instruction.instructionBytes) {
37
+ label += `, ${nls.localize('theia/debug/instructionBytes', 'Bytes')}: ${instruction.instructionBytes}`;
38
+ }
39
+ label += `, ${nls.localize('theia/debug/instructionText', 'Instruction')}: ${instruction.instruction}`;
40
+
41
+ return label;
42
+ }
43
+ }
@@ -0,0 +1,119 @@
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 { append, $, addStandardDisposableListener } from '@theia/monaco-editor-core/esm/vs/base/browser/dom';
18
+ import { ITableRenderer } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/table/table';
19
+ import { dispose } from '@theia/monaco-editor-core/esm/vs/base/common/lifecycle';
20
+ import { BreakpointManager } from '../breakpoint/breakpoint-manager';
21
+ import { BreakpointColumnTemplateData, DisassembledInstructionEntry, DisassemblyViewRendererReference } from './disassembly-view-utilities';
22
+
23
+ // This file is adapted from https://github.com/microsoft/vscode/blob/c061ce5c24fc480342fbc5f23244289d633c56eb/src/vs/workbench/contrib/debug/browser/disassemblyView.ts
24
+
25
+ export class BreakpointRenderer implements ITableRenderer<DisassembledInstructionEntry, BreakpointColumnTemplateData> {
26
+
27
+ static readonly TEMPLATE_ID = 'breakpoint';
28
+
29
+ templateId: string = BreakpointRenderer.TEMPLATE_ID;
30
+
31
+ protected readonly _breakpointIcon = 'codicon-debug-breakpoint';
32
+ protected readonly _breakpointDisabledIcon = 'codicon-debug-breakpoint-disabled';
33
+ protected readonly _breakpointHintIcon = 'codicon-debug-hint';
34
+ protected readonly _debugStackframe = 'codicon-debug-stackframe';
35
+ protected readonly _debugStackframeFocused = 'codicon-debug-stackframe-focused';
36
+
37
+ constructor(
38
+ protected readonly _disassemblyView: DisassemblyViewRendererReference,
39
+ protected readonly _debugService: BreakpointManager,
40
+ ) { }
41
+
42
+ renderTemplate(container: HTMLElement): BreakpointColumnTemplateData {
43
+ // align from the bottom so that it lines up with instruction when source code is present.
44
+ container.style.alignSelf = 'flex-end';
45
+
46
+ const icon = append(container, $('.disassembly-view'));
47
+ icon.classList.add('codicon');
48
+ icon.style.display = 'flex';
49
+ icon.style.alignItems = 'center';
50
+ icon.style.justifyContent = 'center';
51
+ icon.style.height = this._disassemblyView.fontInfo.lineHeight + 'px';
52
+
53
+ const currentElement: { element?: DisassembledInstructionEntry } = { element: undefined };
54
+
55
+ const disposables = [
56
+ this._disassemblyView.onDidChangeStackFrame(() => this.rerenderDebugStackframe(icon, currentElement.element)),
57
+ addStandardDisposableListener(container, 'mouseover', () => {
58
+ if (currentElement.element?.allowBreakpoint) {
59
+ icon.classList.add(this._breakpointHintIcon);
60
+ }
61
+ }),
62
+ addStandardDisposableListener(container, 'mouseout', () => {
63
+ if (currentElement.element?.allowBreakpoint) {
64
+ icon.classList.remove(this._breakpointHintIcon);
65
+ }
66
+ }),
67
+ addStandardDisposableListener(container, 'click', () => {
68
+ if (currentElement.element?.allowBreakpoint) {
69
+ // click show hint while waiting for BP to resolve.
70
+ icon.classList.add(this._breakpointHintIcon);
71
+ if (currentElement.element.isBreakpointSet) {
72
+ this._debugService.removeInstructionBreakpoint(currentElement.element.instruction.address);
73
+
74
+ } else if (currentElement.element.allowBreakpoint && !currentElement.element.isBreakpointSet) {
75
+ this._debugService.addInstructionBreakpoint(currentElement.element.instruction.address, 0);
76
+ }
77
+ }
78
+ })
79
+ ];
80
+
81
+ return { currentElement, icon, disposables };
82
+ }
83
+
84
+ renderElement(element: DisassembledInstructionEntry, index: number, templateData: BreakpointColumnTemplateData, height: number | undefined): void {
85
+ templateData.currentElement.element = element;
86
+ this.rerenderDebugStackframe(templateData.icon, element);
87
+ }
88
+
89
+ disposeTemplate(templateData: BreakpointColumnTemplateData): void {
90
+ dispose(templateData.disposables);
91
+ templateData.disposables = [];
92
+ }
93
+
94
+ protected rerenderDebugStackframe(icon: HTMLElement, element?: DisassembledInstructionEntry): void {
95
+ if (element?.instruction.address === this._disassemblyView.focusedCurrentInstructionAddress) {
96
+ icon.classList.add(this._debugStackframe);
97
+ } else if (element?.instruction.address === this._disassemblyView.focusedInstructionAddress) {
98
+ icon.classList.add(this._debugStackframeFocused);
99
+ } else {
100
+ icon.classList.remove(this._debugStackframe);
101
+ icon.classList.remove(this._debugStackframeFocused);
102
+ }
103
+
104
+ icon.classList.remove(this._breakpointHintIcon);
105
+
106
+ if (element?.isBreakpointSet) {
107
+ if (element.isBreakpointEnabled) {
108
+ icon.classList.add(this._breakpointIcon);
109
+ icon.classList.remove(this._breakpointDisabledIcon);
110
+ } else {
111
+ icon.classList.remove(this._breakpointIcon);
112
+ icon.classList.add(this._breakpointDisabledIcon);
113
+ }
114
+ } else {
115
+ icon.classList.remove(this._breakpointIcon);
116
+ icon.classList.remove(this._breakpointDisabledIcon);
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,109 @@
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, interfaces, postConstruct } from '@theia/core/shared/inversify';
18
+ import { AbstractViewContribution, bindViewContribution, WidgetFactory } from '@theia/core/lib/browser';
19
+ import { DisassemblyViewWidget } from './disassembly-view-widget';
20
+ import { Command, CommandRegistry, MenuModelRegistry, nls } from '@theia/core';
21
+ import { DebugService } from '../../common/debug-service';
22
+ import { EditorManager, EDITOR_CONTEXT_MENU } from '@theia/editor/lib/browser';
23
+ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
24
+ import { DebugSessionManager } from '../debug-session-manager';
25
+ import { DebugStackFrame } from '../model/debug-stack-frame';
26
+ import { DebugSession, DebugState } from '../debug-session';
27
+ import { DebugStackFramesWidget } from '../view/debug-stack-frames-widget';
28
+
29
+ export const OPEN_DISASSEMBLY_VIEW_COMMAND: Command = {
30
+ id: 'open-disassembly-view',
31
+ label: nls.localize('theia/debug/open-disassembly-view', 'Open Disassembly View')
32
+ };
33
+
34
+ export const LANGUAGE_SUPPORTS_DISASSEMBLE_REQUEST = 'languageSupportsDisassembleRequest';
35
+ export const FOCUSED_STACK_FRAME_HAS_INSTRUCTION_REFERENCE = 'focusedStackFrameHasInstructionReference';
36
+ export const DISASSEMBLE_REQUEST_SUPPORTED = 'disassembleRequestSupported';
37
+ export const DISASSEMBLY_VIEW_FOCUS = 'disassemblyViewFocus';
38
+
39
+ @injectable()
40
+ export class DisassemblyViewContribution extends AbstractViewContribution<DisassemblyViewWidget> {
41
+ @inject(DebugService) protected readonly debugService: DebugService;
42
+ @inject(EditorManager) protected readonly editorManager: EditorManager;
43
+ @inject(ContextKeyService) protected readonly contextKeyService: ContextKeyService;
44
+ @inject(DebugSessionManager) protected readonly debugSessionManager: DebugSessionManager;
45
+
46
+ constructor() {
47
+ super({
48
+ widgetId: DisassemblyViewWidget.ID,
49
+ widgetName: 'Disassembly View',
50
+ defaultWidgetOptions: { area: 'main' }
51
+ });
52
+ }
53
+
54
+ @postConstruct()
55
+ protected init(): void {
56
+ let activeEditorChangeCancellation = { cancelled: false };
57
+ const updateLanguageSupportsDisassemblyKey = async () => {
58
+ const editor = this.editorManager.currentEditor;
59
+ activeEditorChangeCancellation.cancelled = true;
60
+ const localCancellation = activeEditorChangeCancellation = { cancelled: false };
61
+
62
+ const language = editor?.editor.document.languageId;
63
+ const debuggersForLanguage = language && await this.debugService.getDebuggersForLanguage(language);
64
+ if (!localCancellation.cancelled) {
65
+ this.contextKeyService.setContext(LANGUAGE_SUPPORTS_DISASSEMBLE_REQUEST, Boolean(debuggersForLanguage?.length));
66
+ }
67
+ };
68
+ this.editorManager.onCurrentEditorChanged(updateLanguageSupportsDisassemblyKey);
69
+ this.debugService.onDidChangeDebuggers?.(updateLanguageSupportsDisassemblyKey);
70
+ let lastSession: DebugSession | undefined;
71
+ let lastFrame: DebugStackFrame | undefined;
72
+ this.debugSessionManager.onDidChange(() => {
73
+ const { currentFrame, currentSession } = this.debugSessionManager;
74
+ if (currentFrame !== lastFrame) {
75
+ lastFrame = currentFrame;
76
+ this.contextKeyService.setContext(FOCUSED_STACK_FRAME_HAS_INSTRUCTION_REFERENCE, Boolean(currentFrame?.raw.instructionPointerReference));
77
+ }
78
+ if (currentSession !== lastSession) {
79
+ lastSession = currentSession;
80
+ this.contextKeyService.setContext(DISASSEMBLE_REQUEST_SUPPORTED, Boolean(currentSession?.capabilities.supportsDisassembleRequest));
81
+ }
82
+ });
83
+ this.shell.onDidChangeCurrentWidget(widget => {
84
+ this.contextKeyService.setContext(DISASSEMBLY_VIEW_FOCUS, widget instanceof DisassemblyViewWidget);
85
+ });
86
+ }
87
+
88
+ override registerCommands(commands: CommandRegistry): void {
89
+ commands.registerCommand(OPEN_DISASSEMBLY_VIEW_COMMAND, {
90
+ isEnabled: () => this.debugSessionManager.inDebugMode
91
+ && this.debugSessionManager.state === DebugState.Stopped
92
+ && this.contextKeyService.match('focusedStackFrameHasInstructionReference'),
93
+ execute: () => this.openView({ activate: true }),
94
+ });
95
+ }
96
+
97
+ override registerMenus(menus: MenuModelRegistry): void {
98
+ menus.registerMenuAction(DebugStackFramesWidget.CONTEXT_MENU,
99
+ { commandId: OPEN_DISASSEMBLY_VIEW_COMMAND.id, label: OPEN_DISASSEMBLY_VIEW_COMMAND.label });
100
+ menus.registerMenuAction([...EDITOR_CONTEXT_MENU, 'a_debug'],
101
+ { commandId: OPEN_DISASSEMBLY_VIEW_COMMAND.id, label: OPEN_DISASSEMBLY_VIEW_COMMAND.label, when: LANGUAGE_SUPPORTS_DISASSEMBLE_REQUEST });
102
+ }
103
+ }
104
+
105
+ export function bindDisassemblyView(bind: interfaces.Bind): void {
106
+ bind(DisassemblyViewWidget).toSelf();
107
+ bind(WidgetFactory).toDynamicValue(({ container }) => ({ id: DisassemblyViewWidget.ID, createWidget: () => container.get(DisassemblyViewWidget) }));
108
+ bindViewContribution(bind, DisassemblyViewContribution);
109
+ }