@theia/memory-inspector 1.45.0 → 1.46.0-next.72
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.
- package/README.md +71 -71
- package/lib/browser/diff-widget/memory-diff-options-widget.d.ts +36 -36
- package/lib/browser/diff-widget/memory-diff-options-widget.js +132 -132
- package/lib/browser/diff-widget/memory-diff-select-widget.d.ts +50 -50
- package/lib/browser/diff-widget/memory-diff-select-widget.js +137 -137
- package/lib/browser/diff-widget/memory-diff-table-widget.d.ts +77 -77
- package/lib/browser/diff-widget/memory-diff-table-widget.js +314 -314
- package/lib/browser/diff-widget/memory-diff-widget-types.d.ts +41 -41
- package/lib/browser/diff-widget/memory-diff-widget-types.js +23 -23
- package/lib/browser/editable-widget/memory-editable-table-widget.d.ts +64 -64
- package/lib/browser/editable-widget/memory-editable-table-widget.js +324 -324
- package/lib/browser/memory-inspector-frontend-contribution.d.ts +46 -46
- package/lib/browser/memory-inspector-frontend-contribution.js +291 -291
- package/lib/browser/memory-inspector-frontend-module.d.ts +21 -21
- package/lib/browser/memory-inspector-frontend-module.js +87 -87
- package/lib/browser/memory-provider/cdt-gdb-memory-provider.d.ts +35 -35
- package/lib/browser/memory-provider/cdt-gdb-memory-provider.js +136 -136
- package/lib/browser/memory-provider/memory-provider-service.d.ts +36 -36
- package/lib/browser/memory-provider/memory-provider-service.js +101 -101
- package/lib/browser/memory-provider/memory-provider.d.ts +65 -65
- package/lib/browser/memory-provider/memory-provider.js +96 -96
- package/lib/browser/memory-provider/memory-provider.spec.d.ts +16 -16
- package/lib/browser/memory-provider/memory-provider.spec.js +23 -23
- package/lib/browser/memory-widget/memory-options-widget.d.ts +136 -136
- package/lib/browser/memory-widget/memory-options-widget.js +564 -564
- package/lib/browser/memory-widget/memory-table-widget.d.ts +146 -146
- package/lib/browser/memory-widget/memory-table-widget.js +487 -487
- package/lib/browser/memory-widget/memory-widget.d.ts +33 -33
- package/lib/browser/memory-widget/memory-widget.js +112 -112
- package/lib/browser/register-widget/register-filter-service.d.ts +42 -42
- package/lib/browser/register-widget/register-filter-service.js +81 -81
- package/lib/browser/register-widget/register-options-widget.d.ts +81 -81
- package/lib/browser/register-widget/register-options-widget.js +338 -338
- package/lib/browser/register-widget/register-table-widget.d.ts +77 -77
- package/lib/browser/register-widget/register-table-widget.js +230 -230
- package/lib/browser/register-widget/register-widget-types.d.ts +29 -29
- package/lib/browser/register-widget/register-widget-types.js +35 -35
- package/lib/browser/utils/memory-commands.d.ts +27 -27
- package/lib/browser/utils/memory-commands.js +67 -67
- package/lib/browser/utils/memory-hover-renderer.d.ts +33 -33
- package/lib/browser/utils/memory-hover-renderer.js +111 -111
- package/lib/browser/utils/memory-recents.d.ts +27 -27
- package/lib/browser/utils/memory-recents.js +52 -52
- package/lib/browser/utils/memory-widget-components.d.ts +58 -58
- package/lib/browser/utils/memory-widget-components.js +69 -69
- package/lib/browser/utils/memory-widget-manager.d.ts +50 -50
- package/lib/browser/utils/memory-widget-manager.js +182 -182
- package/lib/browser/utils/memory-widget-utils.d.ts +113 -113
- package/lib/browser/utils/memory-widget-utils.js +42 -42
- package/lib/browser/utils/memory-widget-variable-utils.d.ts +57 -57
- package/lib/browser/utils/memory-widget-variable-utils.js +143 -143
- package/lib/browser/utils/multi-select-bar.d.ts +31 -31
- package/lib/browser/utils/multi-select-bar.js +34 -34
- package/lib/browser/wrapper-widgets/memory-dock-panel.d.ts +24 -24
- package/lib/browser/wrapper-widgets/memory-dock-panel.js +48 -48
- package/lib/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.d.ts +23 -23
- package/lib/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.js +57 -57
- package/lib/browser/wrapper-widgets/memory-layout-widget.d.ts +51 -51
- package/lib/browser/wrapper-widgets/memory-layout-widget.js +191 -191
- package/lib/common/util.d.ts +21 -21
- package/lib/common/util.js +30 -30
- package/lib/common/utils.spec.d.ts +16 -16
- package/lib/common/utils.spec.js +45 -45
- package/package.json +4 -4
- package/src/browser/diff-widget/memory-diff-options-widget.tsx +152 -152
- package/src/browser/diff-widget/memory-diff-select-widget.tsx +163 -163
- package/src/browser/diff-widget/memory-diff-table-widget.tsx +366 -366
- package/src/browser/diff-widget/memory-diff-widget-types.ts +45 -45
- package/src/browser/editable-widget/memory-editable-table-widget.tsx +359 -359
- package/src/browser/memory-inspector-frontend-contribution.ts +301 -301
- package/src/browser/memory-inspector-frontend-module.ts +118 -118
- package/src/browser/memory-provider/cdt-gdb-memory-provider.ts +132 -132
- package/src/browser/memory-provider/memory-provider-service.ts +86 -86
- package/src/browser/memory-provider/memory-provider.spec.ts +23 -23
- package/src/browser/memory-provider/memory-provider.ts +119 -119
- package/src/browser/memory-widget/memory-options-widget.tsx +738 -738
- package/src/browser/memory-widget/memory-table-widget.tsx +625 -625
- package/src/browser/memory-widget/memory-widget.ts +114 -114
- package/src/browser/register-widget/register-filter-service.ts +76 -76
- package/src/browser/register-widget/register-options-widget.tsx +393 -393
- package/src/browser/register-widget/register-table-widget.tsx +276 -276
- package/src/browser/register-widget/register-widget-types.ts +45 -45
- package/src/browser/register-widget/register-widget.css +34 -34
- package/src/browser/style/index.css +746 -746
- package/src/browser/style/memory-lock.svg +21 -21
- package/src/browser/style/memory-view.svg +20 -20
- package/src/browser/style/register-lock.svg +29 -29
- package/src/browser/style/register-view.svg +28 -28
- package/src/browser/utils/memory-commands.ts +76 -76
- package/src/browser/utils/memory-hover-renderer.ts +113 -113
- package/src/browser/utils/memory-recents.ts +58 -58
- package/src/browser/utils/memory-widget-components.tsx +193 -193
- package/src/browser/utils/memory-widget-manager.ts +179 -179
- package/src/browser/utils/memory-widget-utils.tsx +132 -132
- package/src/browser/utils/memory-widget-variable-utils.ts +170 -170
- package/src/browser/utils/multi-select-bar.css +61 -61
- package/src/browser/utils/multi-select-bar.tsx +75 -75
- package/src/browser/wrapper-widgets/memory-dock-panel.ts +51 -51
- package/src/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.tsx +38 -38
- package/src/browser/wrapper-widgets/memory-layout-widget.tsx +167 -167
- package/src/common/util.ts +28 -28
- package/src/common/utils.spec.ts +52 -52
|
@@ -1,301 +1,301 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (C) 2019 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-only WITH Classpath-exception-2.0
|
|
15
|
-
********************************************************************************/
|
|
16
|
-
|
|
17
|
-
import { AbstractViewContribution, FrontendApplicationContribution, Widget } from '@theia/core/lib/browser';
|
|
18
|
-
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
19
|
-
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
|
|
20
|
-
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
|
21
|
-
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
22
|
-
import { Command, CommandRegistry, MenuModelRegistry } from '@theia/core/lib/common';
|
|
23
|
-
import { Color } from '@theia/core/lib/common/color';
|
|
24
|
-
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
25
|
-
import { DebugScope, DebugVariable } from '@theia/debug/lib/browser/console/debug-console-items';
|
|
26
|
-
import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
|
|
27
|
-
import { DebugVariablesWidget } from '@theia/debug/lib/browser/view/debug-variables-widget';
|
|
28
|
-
import * as Long from 'long';
|
|
29
|
-
import { MemoryEditableTableWidget } from './editable-widget/memory-editable-table-widget';
|
|
30
|
-
import { MemoryProviderService } from './memory-provider/memory-provider-service';
|
|
31
|
-
import { MemoryTableWidget } from './memory-widget/memory-table-widget';
|
|
32
|
-
import { MemoryWidget } from './memory-widget/memory-widget';
|
|
33
|
-
import { RegisterTableWidget } from './register-widget/register-table-widget';
|
|
34
|
-
import { RegisterWidget } from './register-widget/register-widget-types';
|
|
35
|
-
import {
|
|
36
|
-
CreateNewMemoryViewCommand, CreateNewRegisterViewCommand, FollowPointerDebugCommand, FollowPointerTableCommand, MemoryCommand,
|
|
37
|
-
RegisterSetVariableCommand, ResetModifiedCellCommand, ToggleDiffSelectWidgetVisibilityCommand, ViewVariableInMemoryCommand, ViewVariableInRegisterViewCommand
|
|
38
|
-
} from './utils/memory-commands';
|
|
39
|
-
import { MemoryWidgetManager } from './utils/memory-widget-manager';
|
|
40
|
-
import { VariableRange } from './utils/memory-widget-variable-utils';
|
|
41
|
-
import { MemoryDockPanel } from './wrapper-widgets/memory-dock-panel';
|
|
42
|
-
import { MemoryLayoutWidget } from './wrapper-widgets/memory-layout-widget';
|
|
43
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
44
|
-
|
|
45
|
-
const ONE_HALF_OPACITY = 0.5;
|
|
46
|
-
|
|
47
|
-
@injectable()
|
|
48
|
-
export class DebugFrontendContribution extends AbstractViewContribution<MemoryLayoutWidget>
|
|
49
|
-
implements FrontendApplicationContribution,
|
|
50
|
-
TabBarToolbarContribution,
|
|
51
|
-
ColorContribution {
|
|
52
|
-
@inject(DebugFrontendApplicationContribution) protected readonly debugContribution: DebugFrontendApplicationContribution;
|
|
53
|
-
@inject(MemoryWidgetManager) protected readonly memoryWidgetManager: MemoryWidgetManager;
|
|
54
|
-
@inject(FrontendApplicationStateService) protected readonly stateService: FrontendApplicationStateService;
|
|
55
|
-
@inject(MemoryProviderService) protected readonly memoryProvider: MemoryProviderService;
|
|
56
|
-
|
|
57
|
-
constructor() {
|
|
58
|
-
super({
|
|
59
|
-
widgetId: MemoryLayoutWidget.ID,
|
|
60
|
-
widgetName: MemoryLayoutWidget.LABEL,
|
|
61
|
-
defaultWidgetOptions: {
|
|
62
|
-
area: 'right',
|
|
63
|
-
},
|
|
64
|
-
toggleCommandId: MemoryCommand.id,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@postConstruct()
|
|
69
|
-
init(): void {
|
|
70
|
-
this.stateService.reachedState('initialized_layout').then(() => {
|
|
71
|
-
// Close leftover widgets from previous sessions.
|
|
72
|
-
this.memoryWidgetManager.availableWidgets.forEach(widget => {
|
|
73
|
-
if (!(widget.parent instanceof MemoryDockPanel)) {
|
|
74
|
-
widget.close();
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async initializeLayout(): Promise<void> {
|
|
81
|
-
await this.openView({ activate: false });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
override registerCommands(registry: CommandRegistry): void {
|
|
85
|
-
super.registerCommands(registry);
|
|
86
|
-
registry.registerCommand(ViewVariableInMemoryCommand, {
|
|
87
|
-
execute: async () => {
|
|
88
|
-
const { selectedVariable } = this.debugContribution;
|
|
89
|
-
const referenceText = this.memoryProvider.formatVariableReference(selectedVariable);
|
|
90
|
-
if (referenceText) {
|
|
91
|
-
await this.openMemoryWidgetAt(referenceText);
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
isVisible: () => {
|
|
95
|
-
const { selectedVariable } = this.debugContribution;
|
|
96
|
-
return Boolean(this.memoryProvider.supportsVariableReferenceSyntax(selectedVariable) && this.memoryProvider.formatVariableReference(selectedVariable));
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
registry.registerCommand(ViewVariableInRegisterViewCommand, {
|
|
100
|
-
execute: async () => {
|
|
101
|
-
const name = this.debugContribution.selectedVariable?.name;
|
|
102
|
-
if (name) {
|
|
103
|
-
await this.openRegisterWidgetWithReg(name);
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
isVisible: () => {
|
|
107
|
-
let { selectedVariable: currentLevel } = this.debugContribution;
|
|
108
|
-
if (!currentLevel) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
// Make sure it looks like it has a numerical value.
|
|
112
|
-
try { BigInt(currentLevel.value); } catch { return false; }
|
|
113
|
-
while (currentLevel.parent instanceof DebugVariable) {
|
|
114
|
-
currentLevel = currentLevel.parent;
|
|
115
|
-
}
|
|
116
|
-
return currentLevel.parent instanceof DebugScope && currentLevel.parent?.['raw']?.name === 'Registers';
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
registry.registerCommand(FollowPointerDebugCommand, {
|
|
120
|
-
isVisible: () => !!this.isPointer(this.debugContribution.selectedVariable?.type),
|
|
121
|
-
isEnabled: () => !!this.isPointer(this.debugContribution.selectedVariable?.type),
|
|
122
|
-
execute: async () => {
|
|
123
|
-
const name = this.debugContribution.selectedVariable?.name;
|
|
124
|
-
if (name) {
|
|
125
|
-
await this.openMemoryWidgetAt(name);
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
registry.registerCommand(ResetModifiedCellCommand, {
|
|
130
|
-
isEnabled: (widgetToActOn, address: Long) => Long.isLong(address) && widgetToActOn instanceof MemoryEditableTableWidget,
|
|
131
|
-
isVisible: (widgetToActOn, address: Long) => Long.isLong(address) && widgetToActOn instanceof MemoryEditableTableWidget,
|
|
132
|
-
execute: (widgetToActOn: MemoryEditableTableWidget, address: Long) => widgetToActOn.resetModifiedValue(address),
|
|
133
|
-
});
|
|
134
|
-
registry.registerCommand(FollowPointerTableCommand, {
|
|
135
|
-
isEnabled: (widgetToActOn, address, variable?: VariableRange) => widgetToActOn instanceof MemoryTableWidget &&
|
|
136
|
-
this.isPointer(variable?.type),
|
|
137
|
-
isVisible: (widgetToActOn, address, variable?: VariableRange) => widgetToActOn instanceof MemoryTableWidget &&
|
|
138
|
-
this.isPointer(variable?.type),
|
|
139
|
-
execute: (widgetToActOn: MemoryTableWidget, address, variable: VariableRange) => {
|
|
140
|
-
if (variable?.name) {
|
|
141
|
-
widgetToActOn.optionsWidget.setAddressAndGo(variable.name);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
registry.registerCommand(CreateNewMemoryViewCommand, {
|
|
146
|
-
isEnabled: w => this.withWidget(() => true, w),
|
|
147
|
-
isVisible: w => this.withWidget(() => true, w),
|
|
148
|
-
execute: () => this.memoryWidgetManager.createNewMemoryWidget(),
|
|
149
|
-
});
|
|
150
|
-
registry.registerCommand(CreateNewRegisterViewCommand, {
|
|
151
|
-
isEnabled: w => this.withWidget(() => true, w),
|
|
152
|
-
isVisible: w => this.withWidget(() => true, w),
|
|
153
|
-
execute: () => this.memoryWidgetManager.createNewMemoryWidget('register'),
|
|
154
|
-
});
|
|
155
|
-
registry.registerCommand(RegisterSetVariableCommand, {
|
|
156
|
-
isEnabled: (widgetToActOn, dVar: DebugVariable) => widgetToActOn instanceof RegisterTableWidget &&
|
|
157
|
-
dVar && dVar.supportSetVariable,
|
|
158
|
-
isVisible: (widgetToActOn, dVar: DebugVariable) => widgetToActOn instanceof RegisterTableWidget &&
|
|
159
|
-
dVar && dVar.supportSetVariable,
|
|
160
|
-
execute: (widgetToActOn: RegisterTableWidget, dVar: DebugVariable) => dVar && widgetToActOn.handleSetValue(dVar),
|
|
161
|
-
});
|
|
162
|
-
registry.registerCommand(ToggleDiffSelectWidgetVisibilityCommand, {
|
|
163
|
-
isVisible: widget => this.withWidget(() => this.memoryWidgetManager.canCompare, widget),
|
|
164
|
-
execute: (widget: MemoryLayoutWidget) => {
|
|
165
|
-
widget.toggleComparisonVisibility();
|
|
166
|
-
},
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
protected isPointer(type?: string): boolean {
|
|
171
|
-
return !!type?.includes('*');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @param {string} addressReference Should be the exact string to be used in the address bar. I.e. it must resolve to an address value.
|
|
176
|
-
*/
|
|
177
|
-
protected async openMemoryWidgetAt(addressReference: string): Promise<MemoryWidget> {
|
|
178
|
-
await this.openView({ activate: false });
|
|
179
|
-
const newWidget = await this.memoryWidgetManager.createNewMemoryWidget();
|
|
180
|
-
await this.shell.activateWidget(newWidget.id);
|
|
181
|
-
if (newWidget) {
|
|
182
|
-
newWidget.optionsWidget.setAddressAndGo(addressReference);
|
|
183
|
-
}
|
|
184
|
-
return newWidget;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
protected async openRegisterWidgetWithReg(name: string): Promise<MemoryWidget> {
|
|
188
|
-
await this.openView({ activate: false });
|
|
189
|
-
const newWidget = await this.memoryWidgetManager.createNewMemoryWidget<RegisterWidget>('register');
|
|
190
|
-
await this.shell.activateWidget(newWidget.id);
|
|
191
|
-
if (newWidget) {
|
|
192
|
-
newWidget.optionsWidget.setRegAndUpdate(name);
|
|
193
|
-
}
|
|
194
|
-
return newWidget;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
protected withWidget(fn: (widget: MemoryLayoutWidget) => boolean, widget: Widget | undefined = this.tryGetWidget()): boolean {
|
|
198
|
-
if (widget instanceof MemoryLayoutWidget && widget.id === MemoryLayoutWidget.ID) {
|
|
199
|
-
return fn(widget);
|
|
200
|
-
}
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
override registerMenus(registry: MenuModelRegistry): void {
|
|
205
|
-
super.registerMenus(registry);
|
|
206
|
-
const registerMenuActions = (menuPath: string[], ...commands: Command[]): void => {
|
|
207
|
-
for (const [index, command] of commands.entries()) {
|
|
208
|
-
registry.registerMenuAction(menuPath, {
|
|
209
|
-
commandId: command.id,
|
|
210
|
-
label: command.label,
|
|
211
|
-
icon: command.iconClass,
|
|
212
|
-
order: String.fromCharCode('a'.charCodeAt(0) + index),
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
registry.registerMenuAction(
|
|
218
|
-
DebugVariablesWidget.WATCH_MENU,
|
|
219
|
-
{ commandId: ViewVariableInMemoryCommand.id, label: ViewVariableInMemoryCommand.label },
|
|
220
|
-
);
|
|
221
|
-
registry.registerMenuAction(
|
|
222
|
-
DebugVariablesWidget.WATCH_MENU,
|
|
223
|
-
{ commandId: FollowPointerDebugCommand.id, label: FollowPointerDebugCommand.label },
|
|
224
|
-
);
|
|
225
|
-
registry.registerMenuAction(
|
|
226
|
-
DebugVariablesWidget.WATCH_MENU,
|
|
227
|
-
{ commandId: ViewVariableInRegisterViewCommand.id, label: ViewVariableInRegisterViewCommand.label },
|
|
228
|
-
);
|
|
229
|
-
registry.registerMenuAction(
|
|
230
|
-
MemoryEditableTableWidget.CONTEXT_MENU,
|
|
231
|
-
{ commandId: ResetModifiedCellCommand.id, label: ResetModifiedCellCommand.label },
|
|
232
|
-
);
|
|
233
|
-
registry.registerMenuAction(
|
|
234
|
-
MemoryTableWidget.CONTEXT_MENU,
|
|
235
|
-
{ commandId: FollowPointerTableCommand.id, label: FollowPointerTableCommand.label },
|
|
236
|
-
);
|
|
237
|
-
registerMenuActions(
|
|
238
|
-
RegisterTableWidget.CONTEXT_MENU,
|
|
239
|
-
RegisterSetVariableCommand,
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
registerToolbarItems(toolbarRegistry: TabBarToolbarRegistry): void {
|
|
244
|
-
toolbarRegistry.registerItem({
|
|
245
|
-
id: CreateNewMemoryViewCommand.id,
|
|
246
|
-
command: CreateNewMemoryViewCommand.id,
|
|
247
|
-
tooltip: CreateNewMemoryViewCommand.label,
|
|
248
|
-
priority: -2,
|
|
249
|
-
});
|
|
250
|
-
toolbarRegistry.registerItem({
|
|
251
|
-
id: CreateNewRegisterViewCommand.id,
|
|
252
|
-
command: CreateNewRegisterViewCommand.id,
|
|
253
|
-
tooltip: CreateNewRegisterViewCommand.label,
|
|
254
|
-
priority: -1,
|
|
255
|
-
});
|
|
256
|
-
toolbarRegistry.registerItem({
|
|
257
|
-
id: ToggleDiffSelectWidgetVisibilityCommand.id,
|
|
258
|
-
command: ToggleDiffSelectWidgetVisibilityCommand.id,
|
|
259
|
-
tooltip: nls.localize('theia/memory-inspector/toggleComparisonWidgetVisibility', 'Toggle Comparison Widget Visibility'),
|
|
260
|
-
priority: -3,
|
|
261
|
-
onDidChange: this.memoryWidgetManager.onChanged,
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
registerColors(colorRegistry: ColorRegistry): void {
|
|
266
|
-
colorRegistry.register(
|
|
267
|
-
{
|
|
268
|
-
id: 'memoryDiff.removedTextBackground',
|
|
269
|
-
defaults: {
|
|
270
|
-
dark: Color.transparent('diffEditor.removedTextBackground', ONE_HALF_OPACITY),
|
|
271
|
-
light: Color.transparent('diffEditor.removedTextBackground', ONE_HALF_OPACITY),
|
|
272
|
-
},
|
|
273
|
-
description: 'A less opaque diff color for use in the Memory Inspector where various overlays may me in place at once.',
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
id: 'memoryDiff.insertedTextBackground',
|
|
277
|
-
defaults: {
|
|
278
|
-
dark: Color.transparent('diffEditor.insertedTextBackground', ONE_HALF_OPACITY),
|
|
279
|
-
light: Color.transparent('diffEditor.insertedTextBackground', ONE_HALF_OPACITY),
|
|
280
|
-
},
|
|
281
|
-
description: 'A less opaque diff color for use in the Memory Inspector where various overlays may me in place at once.',
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
id: 'memoryInspector.focusBorder',
|
|
285
|
-
defaults: {
|
|
286
|
-
dark: Color.transparent('focusBorder', ONE_HALF_OPACITY),
|
|
287
|
-
light: Color.transparent('focusBorder', ONE_HALF_OPACITY),
|
|
288
|
-
},
|
|
289
|
-
description: 'A less opaque focus border color for use in the Memory Inspector where several overlays may be in place at once.',
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
id: 'memoryInspector.foreground',
|
|
293
|
-
defaults: {
|
|
294
|
-
dark: Color.transparent('editor.foreground', ONE_HALF_OPACITY),
|
|
295
|
-
light: Color.transparent('editor.foreground', ONE_HALF_OPACITY),
|
|
296
|
-
},
|
|
297
|
-
description: 'A less opaque foreground text style for use in the Memory Inspector',
|
|
298
|
-
},
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2019 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-only WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import { AbstractViewContribution, FrontendApplicationContribution, Widget } from '@theia/core/lib/browser';
|
|
18
|
+
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
19
|
+
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
|
|
20
|
+
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
|
21
|
+
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
22
|
+
import { Command, CommandRegistry, MenuModelRegistry } from '@theia/core/lib/common';
|
|
23
|
+
import { Color } from '@theia/core/lib/common/color';
|
|
24
|
+
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
25
|
+
import { DebugScope, DebugVariable } from '@theia/debug/lib/browser/console/debug-console-items';
|
|
26
|
+
import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
|
|
27
|
+
import { DebugVariablesWidget } from '@theia/debug/lib/browser/view/debug-variables-widget';
|
|
28
|
+
import * as Long from 'long';
|
|
29
|
+
import { MemoryEditableTableWidget } from './editable-widget/memory-editable-table-widget';
|
|
30
|
+
import { MemoryProviderService } from './memory-provider/memory-provider-service';
|
|
31
|
+
import { MemoryTableWidget } from './memory-widget/memory-table-widget';
|
|
32
|
+
import { MemoryWidget } from './memory-widget/memory-widget';
|
|
33
|
+
import { RegisterTableWidget } from './register-widget/register-table-widget';
|
|
34
|
+
import { RegisterWidget } from './register-widget/register-widget-types';
|
|
35
|
+
import {
|
|
36
|
+
CreateNewMemoryViewCommand, CreateNewRegisterViewCommand, FollowPointerDebugCommand, FollowPointerTableCommand, MemoryCommand,
|
|
37
|
+
RegisterSetVariableCommand, ResetModifiedCellCommand, ToggleDiffSelectWidgetVisibilityCommand, ViewVariableInMemoryCommand, ViewVariableInRegisterViewCommand
|
|
38
|
+
} from './utils/memory-commands';
|
|
39
|
+
import { MemoryWidgetManager } from './utils/memory-widget-manager';
|
|
40
|
+
import { VariableRange } from './utils/memory-widget-variable-utils';
|
|
41
|
+
import { MemoryDockPanel } from './wrapper-widgets/memory-dock-panel';
|
|
42
|
+
import { MemoryLayoutWidget } from './wrapper-widgets/memory-layout-widget';
|
|
43
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
44
|
+
|
|
45
|
+
const ONE_HALF_OPACITY = 0.5;
|
|
46
|
+
|
|
47
|
+
@injectable()
|
|
48
|
+
export class DebugFrontendContribution extends AbstractViewContribution<MemoryLayoutWidget>
|
|
49
|
+
implements FrontendApplicationContribution,
|
|
50
|
+
TabBarToolbarContribution,
|
|
51
|
+
ColorContribution {
|
|
52
|
+
@inject(DebugFrontendApplicationContribution) protected readonly debugContribution: DebugFrontendApplicationContribution;
|
|
53
|
+
@inject(MemoryWidgetManager) protected readonly memoryWidgetManager: MemoryWidgetManager;
|
|
54
|
+
@inject(FrontendApplicationStateService) protected readonly stateService: FrontendApplicationStateService;
|
|
55
|
+
@inject(MemoryProviderService) protected readonly memoryProvider: MemoryProviderService;
|
|
56
|
+
|
|
57
|
+
constructor() {
|
|
58
|
+
super({
|
|
59
|
+
widgetId: MemoryLayoutWidget.ID,
|
|
60
|
+
widgetName: MemoryLayoutWidget.LABEL,
|
|
61
|
+
defaultWidgetOptions: {
|
|
62
|
+
area: 'right',
|
|
63
|
+
},
|
|
64
|
+
toggleCommandId: MemoryCommand.id,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@postConstruct()
|
|
69
|
+
init(): void {
|
|
70
|
+
this.stateService.reachedState('initialized_layout').then(() => {
|
|
71
|
+
// Close leftover widgets from previous sessions.
|
|
72
|
+
this.memoryWidgetManager.availableWidgets.forEach(widget => {
|
|
73
|
+
if (!(widget.parent instanceof MemoryDockPanel)) {
|
|
74
|
+
widget.close();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async initializeLayout(): Promise<void> {
|
|
81
|
+
await this.openView({ activate: false });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
override registerCommands(registry: CommandRegistry): void {
|
|
85
|
+
super.registerCommands(registry);
|
|
86
|
+
registry.registerCommand(ViewVariableInMemoryCommand, {
|
|
87
|
+
execute: async () => {
|
|
88
|
+
const { selectedVariable } = this.debugContribution;
|
|
89
|
+
const referenceText = this.memoryProvider.formatVariableReference(selectedVariable);
|
|
90
|
+
if (referenceText) {
|
|
91
|
+
await this.openMemoryWidgetAt(referenceText);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
isVisible: () => {
|
|
95
|
+
const { selectedVariable } = this.debugContribution;
|
|
96
|
+
return Boolean(this.memoryProvider.supportsVariableReferenceSyntax(selectedVariable) && this.memoryProvider.formatVariableReference(selectedVariable));
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
registry.registerCommand(ViewVariableInRegisterViewCommand, {
|
|
100
|
+
execute: async () => {
|
|
101
|
+
const name = this.debugContribution.selectedVariable?.name;
|
|
102
|
+
if (name) {
|
|
103
|
+
await this.openRegisterWidgetWithReg(name);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
isVisible: () => {
|
|
107
|
+
let { selectedVariable: currentLevel } = this.debugContribution;
|
|
108
|
+
if (!currentLevel) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
// Make sure it looks like it has a numerical value.
|
|
112
|
+
try { BigInt(currentLevel.value); } catch { return false; }
|
|
113
|
+
while (currentLevel.parent instanceof DebugVariable) {
|
|
114
|
+
currentLevel = currentLevel.parent;
|
|
115
|
+
}
|
|
116
|
+
return currentLevel.parent instanceof DebugScope && currentLevel.parent?.['raw']?.name === 'Registers';
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
registry.registerCommand(FollowPointerDebugCommand, {
|
|
120
|
+
isVisible: () => !!this.isPointer(this.debugContribution.selectedVariable?.type),
|
|
121
|
+
isEnabled: () => !!this.isPointer(this.debugContribution.selectedVariable?.type),
|
|
122
|
+
execute: async () => {
|
|
123
|
+
const name = this.debugContribution.selectedVariable?.name;
|
|
124
|
+
if (name) {
|
|
125
|
+
await this.openMemoryWidgetAt(name);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
registry.registerCommand(ResetModifiedCellCommand, {
|
|
130
|
+
isEnabled: (widgetToActOn, address: Long) => Long.isLong(address) && widgetToActOn instanceof MemoryEditableTableWidget,
|
|
131
|
+
isVisible: (widgetToActOn, address: Long) => Long.isLong(address) && widgetToActOn instanceof MemoryEditableTableWidget,
|
|
132
|
+
execute: (widgetToActOn: MemoryEditableTableWidget, address: Long) => widgetToActOn.resetModifiedValue(address),
|
|
133
|
+
});
|
|
134
|
+
registry.registerCommand(FollowPointerTableCommand, {
|
|
135
|
+
isEnabled: (widgetToActOn, address, variable?: VariableRange) => widgetToActOn instanceof MemoryTableWidget &&
|
|
136
|
+
this.isPointer(variable?.type),
|
|
137
|
+
isVisible: (widgetToActOn, address, variable?: VariableRange) => widgetToActOn instanceof MemoryTableWidget &&
|
|
138
|
+
this.isPointer(variable?.type),
|
|
139
|
+
execute: (widgetToActOn: MemoryTableWidget, address, variable: VariableRange) => {
|
|
140
|
+
if (variable?.name) {
|
|
141
|
+
widgetToActOn.optionsWidget.setAddressAndGo(variable.name);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
registry.registerCommand(CreateNewMemoryViewCommand, {
|
|
146
|
+
isEnabled: w => this.withWidget(() => true, w),
|
|
147
|
+
isVisible: w => this.withWidget(() => true, w),
|
|
148
|
+
execute: () => this.memoryWidgetManager.createNewMemoryWidget(),
|
|
149
|
+
});
|
|
150
|
+
registry.registerCommand(CreateNewRegisterViewCommand, {
|
|
151
|
+
isEnabled: w => this.withWidget(() => true, w),
|
|
152
|
+
isVisible: w => this.withWidget(() => true, w),
|
|
153
|
+
execute: () => this.memoryWidgetManager.createNewMemoryWidget('register'),
|
|
154
|
+
});
|
|
155
|
+
registry.registerCommand(RegisterSetVariableCommand, {
|
|
156
|
+
isEnabled: (widgetToActOn, dVar: DebugVariable) => widgetToActOn instanceof RegisterTableWidget &&
|
|
157
|
+
dVar && dVar.supportSetVariable,
|
|
158
|
+
isVisible: (widgetToActOn, dVar: DebugVariable) => widgetToActOn instanceof RegisterTableWidget &&
|
|
159
|
+
dVar && dVar.supportSetVariable,
|
|
160
|
+
execute: (widgetToActOn: RegisterTableWidget, dVar: DebugVariable) => dVar && widgetToActOn.handleSetValue(dVar),
|
|
161
|
+
});
|
|
162
|
+
registry.registerCommand(ToggleDiffSelectWidgetVisibilityCommand, {
|
|
163
|
+
isVisible: widget => this.withWidget(() => this.memoryWidgetManager.canCompare, widget),
|
|
164
|
+
execute: (widget: MemoryLayoutWidget) => {
|
|
165
|
+
widget.toggleComparisonVisibility();
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
protected isPointer(type?: string): boolean {
|
|
171
|
+
return !!type?.includes('*');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @param {string} addressReference Should be the exact string to be used in the address bar. I.e. it must resolve to an address value.
|
|
176
|
+
*/
|
|
177
|
+
protected async openMemoryWidgetAt(addressReference: string): Promise<MemoryWidget> {
|
|
178
|
+
await this.openView({ activate: false });
|
|
179
|
+
const newWidget = await this.memoryWidgetManager.createNewMemoryWidget();
|
|
180
|
+
await this.shell.activateWidget(newWidget.id);
|
|
181
|
+
if (newWidget) {
|
|
182
|
+
newWidget.optionsWidget.setAddressAndGo(addressReference);
|
|
183
|
+
}
|
|
184
|
+
return newWidget;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
protected async openRegisterWidgetWithReg(name: string): Promise<MemoryWidget> {
|
|
188
|
+
await this.openView({ activate: false });
|
|
189
|
+
const newWidget = await this.memoryWidgetManager.createNewMemoryWidget<RegisterWidget>('register');
|
|
190
|
+
await this.shell.activateWidget(newWidget.id);
|
|
191
|
+
if (newWidget) {
|
|
192
|
+
newWidget.optionsWidget.setRegAndUpdate(name);
|
|
193
|
+
}
|
|
194
|
+
return newWidget;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
protected withWidget(fn: (widget: MemoryLayoutWidget) => boolean, widget: Widget | undefined = this.tryGetWidget()): boolean {
|
|
198
|
+
if (widget instanceof MemoryLayoutWidget && widget.id === MemoryLayoutWidget.ID) {
|
|
199
|
+
return fn(widget);
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
override registerMenus(registry: MenuModelRegistry): void {
|
|
205
|
+
super.registerMenus(registry);
|
|
206
|
+
const registerMenuActions = (menuPath: string[], ...commands: Command[]): void => {
|
|
207
|
+
for (const [index, command] of commands.entries()) {
|
|
208
|
+
registry.registerMenuAction(menuPath, {
|
|
209
|
+
commandId: command.id,
|
|
210
|
+
label: command.label,
|
|
211
|
+
icon: command.iconClass,
|
|
212
|
+
order: String.fromCharCode('a'.charCodeAt(0) + index),
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
registry.registerMenuAction(
|
|
218
|
+
DebugVariablesWidget.WATCH_MENU,
|
|
219
|
+
{ commandId: ViewVariableInMemoryCommand.id, label: ViewVariableInMemoryCommand.label },
|
|
220
|
+
);
|
|
221
|
+
registry.registerMenuAction(
|
|
222
|
+
DebugVariablesWidget.WATCH_MENU,
|
|
223
|
+
{ commandId: FollowPointerDebugCommand.id, label: FollowPointerDebugCommand.label },
|
|
224
|
+
);
|
|
225
|
+
registry.registerMenuAction(
|
|
226
|
+
DebugVariablesWidget.WATCH_MENU,
|
|
227
|
+
{ commandId: ViewVariableInRegisterViewCommand.id, label: ViewVariableInRegisterViewCommand.label },
|
|
228
|
+
);
|
|
229
|
+
registry.registerMenuAction(
|
|
230
|
+
MemoryEditableTableWidget.CONTEXT_MENU,
|
|
231
|
+
{ commandId: ResetModifiedCellCommand.id, label: ResetModifiedCellCommand.label },
|
|
232
|
+
);
|
|
233
|
+
registry.registerMenuAction(
|
|
234
|
+
MemoryTableWidget.CONTEXT_MENU,
|
|
235
|
+
{ commandId: FollowPointerTableCommand.id, label: FollowPointerTableCommand.label },
|
|
236
|
+
);
|
|
237
|
+
registerMenuActions(
|
|
238
|
+
RegisterTableWidget.CONTEXT_MENU,
|
|
239
|
+
RegisterSetVariableCommand,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
registerToolbarItems(toolbarRegistry: TabBarToolbarRegistry): void {
|
|
244
|
+
toolbarRegistry.registerItem({
|
|
245
|
+
id: CreateNewMemoryViewCommand.id,
|
|
246
|
+
command: CreateNewMemoryViewCommand.id,
|
|
247
|
+
tooltip: CreateNewMemoryViewCommand.label,
|
|
248
|
+
priority: -2,
|
|
249
|
+
});
|
|
250
|
+
toolbarRegistry.registerItem({
|
|
251
|
+
id: CreateNewRegisterViewCommand.id,
|
|
252
|
+
command: CreateNewRegisterViewCommand.id,
|
|
253
|
+
tooltip: CreateNewRegisterViewCommand.label,
|
|
254
|
+
priority: -1,
|
|
255
|
+
});
|
|
256
|
+
toolbarRegistry.registerItem({
|
|
257
|
+
id: ToggleDiffSelectWidgetVisibilityCommand.id,
|
|
258
|
+
command: ToggleDiffSelectWidgetVisibilityCommand.id,
|
|
259
|
+
tooltip: nls.localize('theia/memory-inspector/toggleComparisonWidgetVisibility', 'Toggle Comparison Widget Visibility'),
|
|
260
|
+
priority: -3,
|
|
261
|
+
onDidChange: this.memoryWidgetManager.onChanged,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
registerColors(colorRegistry: ColorRegistry): void {
|
|
266
|
+
colorRegistry.register(
|
|
267
|
+
{
|
|
268
|
+
id: 'memoryDiff.removedTextBackground',
|
|
269
|
+
defaults: {
|
|
270
|
+
dark: Color.transparent('diffEditor.removedTextBackground', ONE_HALF_OPACITY),
|
|
271
|
+
light: Color.transparent('diffEditor.removedTextBackground', ONE_HALF_OPACITY),
|
|
272
|
+
},
|
|
273
|
+
description: 'A less opaque diff color for use in the Memory Inspector where various overlays may me in place at once.',
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
id: 'memoryDiff.insertedTextBackground',
|
|
277
|
+
defaults: {
|
|
278
|
+
dark: Color.transparent('diffEditor.insertedTextBackground', ONE_HALF_OPACITY),
|
|
279
|
+
light: Color.transparent('diffEditor.insertedTextBackground', ONE_HALF_OPACITY),
|
|
280
|
+
},
|
|
281
|
+
description: 'A less opaque diff color for use in the Memory Inspector where various overlays may me in place at once.',
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
id: 'memoryInspector.focusBorder',
|
|
285
|
+
defaults: {
|
|
286
|
+
dark: Color.transparent('focusBorder', ONE_HALF_OPACITY),
|
|
287
|
+
light: Color.transparent('focusBorder', ONE_HALF_OPACITY),
|
|
288
|
+
},
|
|
289
|
+
description: 'A less opaque focus border color for use in the Memory Inspector where several overlays may be in place at once.',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
id: 'memoryInspector.foreground',
|
|
293
|
+
defaults: {
|
|
294
|
+
dark: Color.transparent('editor.foreground', ONE_HALF_OPACITY),
|
|
295
|
+
light: Color.transparent('editor.foreground', ONE_HALF_OPACITY),
|
|
296
|
+
},
|
|
297
|
+
description: 'A less opaque foreground text style for use in the Memory Inspector',
|
|
298
|
+
},
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
}
|