@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,565 +1,565 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/********************************************************************************
|
|
3
|
-
* Copyright (C) 2021 Ericsson and others.
|
|
4
|
-
*
|
|
5
|
-
* This program and the accompanying materials are made available under the
|
|
6
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
*
|
|
9
|
-
* This Source Code may also be made available under the following Secondary
|
|
10
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
* with the GNU Classpath Exception which is available at
|
|
13
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
*
|
|
15
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
********************************************************************************/
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
var MemoryOptionsWidget_1;
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.MemoryOptionsWidget = exports.AUTO_UPDATE_TOGGLE_ID = exports.ASCII_TOGGLE_ID = exports.ENDIAN_SELECT_ID = exports.BYTES_PER_GROUP_FIELD_ID = exports.BYTES_PER_ROW_FIELD_ID = exports.LOCATION_OFFSET_FIELD_ID = exports.LENGTH_FIELD_ID = exports.LOCATION_FIELD_ID = exports.EMPTY_MEMORY = void 0;
|
|
29
|
-
const core_1 = require("@theia/core");
|
|
30
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
31
|
-
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
32
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
33
|
-
const React = require("@theia/core/shared/react");
|
|
34
|
-
const debug_session_1 = require("@theia/debug/lib/browser/debug-session");
|
|
35
|
-
const debug_session_manager_1 = require("@theia/debug/lib/browser/debug-session-manager");
|
|
36
|
-
const Long = require("long");
|
|
37
|
-
const memory_provider_service_1 = require("../memory-provider/memory-provider-service");
|
|
38
|
-
const memory_recents_1 = require("../utils/memory-recents");
|
|
39
|
-
const memory_widget_components_1 = require("../utils/memory-widget-components");
|
|
40
|
-
const memory_widget_utils_1 = require("../utils/memory-widget-utils");
|
|
41
|
-
const multi_select_bar_1 = require("../utils/multi-select-bar");
|
|
42
|
-
const debounce = require("@theia/core/shared/lodash.debounce");
|
|
43
|
-
exports.EMPTY_MEMORY = (0, core_1.deepFreeze)({
|
|
44
|
-
bytes: new Uint8Array(),
|
|
45
|
-
address: new Long(0, 0, true),
|
|
46
|
-
});
|
|
47
|
-
exports.LOCATION_FIELD_ID = 't-mv-location';
|
|
48
|
-
exports.LENGTH_FIELD_ID = 't-mv-length';
|
|
49
|
-
exports.LOCATION_OFFSET_FIELD_ID = 't-mv-location-offset';
|
|
50
|
-
exports.BYTES_PER_ROW_FIELD_ID = 't-mv-bytesrow';
|
|
51
|
-
exports.BYTES_PER_GROUP_FIELD_ID = 't-mv-bytesgroup';
|
|
52
|
-
exports.ENDIAN_SELECT_ID = 't-mv-endiannesss';
|
|
53
|
-
exports.ASCII_TOGGLE_ID = 't-mv-ascii-toggle';
|
|
54
|
-
exports.AUTO_UPDATE_TOGGLE_ID = 't-mv-auto-update-toggle';
|
|
55
|
-
let MemoryOptionsWidget = MemoryOptionsWidget_1 = class MemoryOptionsWidget extends browser_1.ReactWidget {
|
|
56
|
-
constructor() {
|
|
57
|
-
super(...arguments);
|
|
58
|
-
this.iconClass = 'memory-view-icon';
|
|
59
|
-
this.lockIconClass = 'memory-lock-icon';
|
|
60
|
-
this.additionalColumnSelectLabel = core_1.nls.localize('theia/memory-inspector/extraColumn', 'Extra Column');
|
|
61
|
-
this.sessionListeners = new core_1.DisposableCollection();
|
|
62
|
-
this.onOptionsChangedEmitter = new core_1.Emitter();
|
|
63
|
-
this.onOptionsChanged = this.onOptionsChangedEmitter.event;
|
|
64
|
-
this.onMemoryChangedEmitter = new core_1.Emitter();
|
|
65
|
-
this.onMemoryChanged = this.onMemoryChangedEmitter.event;
|
|
66
|
-
this.memoryReadResult = exports.EMPTY_MEMORY;
|
|
67
|
-
this.columnsDisplayed = {
|
|
68
|
-
address: {
|
|
69
|
-
label: core_1.nls.localizeByDefault('Address'),
|
|
70
|
-
doRender: true
|
|
71
|
-
},
|
|
72
|
-
data: {
|
|
73
|
-
label: core_1.nls.localize('theia/memory-inspector/data', 'Data'),
|
|
74
|
-
doRender: true
|
|
75
|
-
},
|
|
76
|
-
variables: {
|
|
77
|
-
label: core_1.nls.localizeByDefault('Variables'),
|
|
78
|
-
doRender: true
|
|
79
|
-
},
|
|
80
|
-
ascii: {
|
|
81
|
-
label: core_1.nls.localize('theia/memory-inspector/ascii', 'ASCII'),
|
|
82
|
-
doRender: false
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
this.byteSize = 8;
|
|
86
|
-
this.bytesPerGroup = 1;
|
|
87
|
-
this.groupsPerRow = 4;
|
|
88
|
-
this.variables = [];
|
|
89
|
-
this.endianness = memory_widget_utils_1.Interfaces.Endianness.Little;
|
|
90
|
-
this.memoryReadError = core_1.nls.localize('theia/memory-inspector/memory/readError/noContents', 'No memory contents currently available.');
|
|
91
|
-
this.address = 0;
|
|
92
|
-
this.offset = 0;
|
|
93
|
-
this.readLength = 256;
|
|
94
|
-
this.doDisplaySettings = false;
|
|
95
|
-
this.doUpdateAutomatically = true;
|
|
96
|
-
this.showMemoryError = false;
|
|
97
|
-
this.errorTimeout = undefined;
|
|
98
|
-
this.recentLocations = new memory_recents_1.Recents();
|
|
99
|
-
this.showTitleEditIcon = false;
|
|
100
|
-
this.isTitleEditable = false;
|
|
101
|
-
this.handleColumnSelectionChange = (columnLabel, doShow) => this.doHandleColumnSelectionChange(columnLabel, doShow);
|
|
102
|
-
this.toggleAutoUpdate = (e) => {
|
|
103
|
-
var _a;
|
|
104
|
-
if (e.nativeEvent.type === 'click') {
|
|
105
|
-
e.currentTarget.blur();
|
|
106
|
-
}
|
|
107
|
-
if ('key' in e && ((_a = browser_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _a === void 0 ? void 0 : _a.keyCode) === browser_1.Key.TAB.keyCode) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
this.doUpdateAutomatically = !this.doUpdateAutomatically;
|
|
111
|
-
if (this.doUpdateAutomatically) {
|
|
112
|
-
this.title.iconClass = this.iconClass;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
this.title.iconClass = this.lockIconClass;
|
|
116
|
-
}
|
|
117
|
-
this.fireDidChangeOptions();
|
|
118
|
-
};
|
|
119
|
-
this.onByteSizeChange = (event) => {
|
|
120
|
-
this.byteSize = parseInt(event.target.value);
|
|
121
|
-
this.fireDidChangeOptions(event.target.id);
|
|
122
|
-
};
|
|
123
|
-
this.toggleDoShowSettings = (e) => {
|
|
124
|
-
var _a;
|
|
125
|
-
if (!('key' in e) || ((_a = browser_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _a === void 0 ? void 0 : _a.keyCode) === browser_1.Key.TAB.keyCode) {
|
|
126
|
-
this.doDisplaySettings = !this.doDisplaySettings;
|
|
127
|
-
this.update();
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
this.assignLocationRef = location => {
|
|
131
|
-
this.addressField = location !== null && location !== void 0 ? location : undefined;
|
|
132
|
-
};
|
|
133
|
-
this.assignReadLengthRef = readLength => {
|
|
134
|
-
this.readLengthField = readLength !== null && readLength !== void 0 ? readLength : undefined;
|
|
135
|
-
};
|
|
136
|
-
this.assignOffsetRef = offset => {
|
|
137
|
-
this.offsetField = offset !== null && offset !== void 0 ? offset : undefined;
|
|
138
|
-
};
|
|
139
|
-
this.setAddressFromSelect = (e) => {
|
|
140
|
-
if (this.addressField) {
|
|
141
|
-
this.addressField.value = e.target.value;
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
this.activateHeaderInputField = (e) => {
|
|
145
|
-
var _a, _b;
|
|
146
|
-
if (!this.isTitleEditable) {
|
|
147
|
-
const isMouseDown = !('key' in e);
|
|
148
|
-
const isActivationKey = 'key' in e && (((_a = browser_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _a === void 0 ? void 0 : _a.keyCode) === browser_1.Key.SPACE.keyCode
|
|
149
|
-
|| ((_b = browser_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _b === void 0 ? void 0 : _b.keyCode) === browser_1.Key.ENTER.keyCode);
|
|
150
|
-
if (isMouseDown || isActivationKey) {
|
|
151
|
-
if (isMouseDown) {
|
|
152
|
-
e.currentTarget.blur();
|
|
153
|
-
}
|
|
154
|
-
this.isTitleEditable = true;
|
|
155
|
-
this.update();
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
this.saveHeaderInputValue = (e) => {
|
|
160
|
-
const isMouseDown = !('key' in e);
|
|
161
|
-
const isSaveKey = 'key' in e && e.key === 'Enter';
|
|
162
|
-
const isCancelKey = 'key' in e && e.key === 'Escape';
|
|
163
|
-
e.stopPropagation();
|
|
164
|
-
if (isMouseDown || isSaveKey || isCancelKey) {
|
|
165
|
-
this.updateHeader(isCancelKey);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
this.assignHeaderInputRef = (element) => {
|
|
169
|
-
if (element) {
|
|
170
|
-
this.headerInputField = element;
|
|
171
|
-
element.focus();
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
this.doShowMemoryErrors = (doClearError = false) => {
|
|
175
|
-
if (this.errorTimeout !== undefined) {
|
|
176
|
-
clearTimeout(this.errorTimeout);
|
|
177
|
-
}
|
|
178
|
-
if (doClearError) {
|
|
179
|
-
this.showMemoryError = false;
|
|
180
|
-
this.update();
|
|
181
|
-
this.errorTimeout = undefined;
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
this.showMemoryError = true;
|
|
185
|
-
this.update();
|
|
186
|
-
this.errorTimeout = setTimeout(() => {
|
|
187
|
-
this.showMemoryError = false;
|
|
188
|
-
this.update();
|
|
189
|
-
this.errorTimeout = undefined;
|
|
190
|
-
}, memory_widget_utils_1.Constants.ERROR_TIMEOUT);
|
|
191
|
-
};
|
|
192
|
-
this.doRefresh = (event) => {
|
|
193
|
-
if ('key' in event && event.key !== 'Enter') {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
this.updateMemoryView();
|
|
197
|
-
};
|
|
198
|
-
this.updateMemoryView = debounce(this.doUpdateMemoryView.bind(this), memory_widget_utils_1.Constants.DEBOUNCE_TIME, { trailing: true });
|
|
199
|
-
// Callbacks for when the various view parameters change.
|
|
200
|
-
/**
|
|
201
|
-
* Handle bytes per row changed event.
|
|
202
|
-
*/
|
|
203
|
-
this.onGroupsPerRowChange = (event) => {
|
|
204
|
-
const { value, id } = event.target;
|
|
205
|
-
this.groupsPerRow = parseInt(value);
|
|
206
|
-
this.fireDidChangeOptions(id);
|
|
207
|
-
};
|
|
208
|
-
/**
|
|
209
|
-
* Handle bytes per group changed event.
|
|
210
|
-
*/
|
|
211
|
-
this.onBytesPerGroupChange = (event) => {
|
|
212
|
-
const { value, id } = event.target;
|
|
213
|
-
this.bytesPerGroup = parseInt(value);
|
|
214
|
-
this.fireDidChangeOptions(id);
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Handle endianness changed event.
|
|
218
|
-
*/
|
|
219
|
-
this.onEndiannessChange = (event) => {
|
|
220
|
-
const { value, id } = event.target;
|
|
221
|
-
if (value !== memory_widget_utils_1.Interfaces.Endianness.Big && value !== memory_widget_utils_1.Interfaces.Endianness.Little) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
this.endianness = value;
|
|
225
|
-
this.fireDidChangeOptions(id);
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
get memory() {
|
|
229
|
-
return {
|
|
230
|
-
...this.memoryReadResult,
|
|
231
|
-
variables: this.variables,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
get options() {
|
|
235
|
-
return this.storeState();
|
|
236
|
-
}
|
|
237
|
-
init() {
|
|
238
|
-
this.addClass(MemoryOptionsWidget_1.ID);
|
|
239
|
-
this.title.label = core_1.nls.localize('theia/memory-inspector/memory', 'Memory ({0})', this.memoryWidgetOptions.displayId);
|
|
240
|
-
this.title.caption = core_1.nls.localize('theia/memory-inspector/memory', 'Memory ({0})', this.memoryWidgetOptions.displayId);
|
|
241
|
-
this.title.iconClass = this.iconClass;
|
|
242
|
-
this.title.closable = true;
|
|
243
|
-
if (this.memoryWidgetOptions.dynamic !== false) {
|
|
244
|
-
this.toDispose.push(this.sessionManager.onDidChangeActiveDebugSession(({ current }) => {
|
|
245
|
-
this.setUpListeners(current);
|
|
246
|
-
}));
|
|
247
|
-
this.toDispose.push(this.sessionManager.onDidCreateDebugSession(current => {
|
|
248
|
-
this.setUpListeners(current);
|
|
249
|
-
}));
|
|
250
|
-
this.setUpListeners(this.sessionManager.currentSession);
|
|
251
|
-
}
|
|
252
|
-
this.toDispose.push(this.onOptionsChanged(() => this.update()));
|
|
253
|
-
this.update();
|
|
254
|
-
}
|
|
255
|
-
async setAddressAndGo(newAddress, newOffset, newLength, direction) {
|
|
256
|
-
let doUpdate = false;
|
|
257
|
-
const originalValues = {
|
|
258
|
-
offset: '',
|
|
259
|
-
length: '',
|
|
260
|
-
};
|
|
261
|
-
if (this.addressField) {
|
|
262
|
-
this.addressField.value = newAddress;
|
|
263
|
-
doUpdate = true;
|
|
264
|
-
}
|
|
265
|
-
if (this.offsetField && newOffset !== undefined) {
|
|
266
|
-
originalValues.offset = this.offsetField.value;
|
|
267
|
-
this.offsetField.value = newOffset.toString();
|
|
268
|
-
doUpdate = true;
|
|
269
|
-
}
|
|
270
|
-
if (this.readLengthField && newLength !== undefined) {
|
|
271
|
-
originalValues.length = this.readLengthField.value;
|
|
272
|
-
this.readLengthField.value = newLength.toString();
|
|
273
|
-
doUpdate = true;
|
|
274
|
-
}
|
|
275
|
-
if (doUpdate && this.readLengthField && this.offsetField) {
|
|
276
|
-
this.pinnedMemoryReadResult = new promise_util_1.Deferred();
|
|
277
|
-
this.updateMemoryView();
|
|
278
|
-
const result = await this.pinnedMemoryReadResult.promise;
|
|
279
|
-
if (result === false) {
|
|
280
|
-
// Memory request errored
|
|
281
|
-
this.readLengthField.value = originalValues.length;
|
|
282
|
-
this.offsetField.value = originalValues.offset;
|
|
283
|
-
}
|
|
284
|
-
if (result) {
|
|
285
|
-
// Memory request returned some memory
|
|
286
|
-
const resultLength = result.bytes.length * 8 / this.byteSize;
|
|
287
|
-
const lengthFieldValue = parseInt(this.readLengthField.value);
|
|
288
|
-
if (lengthFieldValue !== resultLength) {
|
|
289
|
-
this.memoryReadError = core_1.nls.localize('theia/memory-inspector/memory/readError/bounds', 'Memory bounds exceeded, result will be truncated.');
|
|
290
|
-
this.doShowMemoryErrors();
|
|
291
|
-
this.readLengthField.value = resultLength.toString();
|
|
292
|
-
if (direction === 'above') {
|
|
293
|
-
this.offsetField.value = `${parseInt(originalValues.offset) - (resultLength - parseInt(originalValues.length))}`;
|
|
294
|
-
}
|
|
295
|
-
this.update();
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
return undefined;
|
|
300
|
-
}
|
|
301
|
-
setUpListeners(session) {
|
|
302
|
-
this.sessionListeners.dispose();
|
|
303
|
-
this.sessionListeners = new core_1.DisposableCollection(core_1.Disposable.create(() => this.handleActiveSessionChange()));
|
|
304
|
-
if (session) {
|
|
305
|
-
this.sessionListeners.push(session.onDidChange(() => this.handleSessionChange()));
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
handleActiveSessionChange() {
|
|
309
|
-
const isDynamic = this.memoryWidgetOptions.dynamic !== false;
|
|
310
|
-
if (isDynamic && this.doUpdateAutomatically) {
|
|
311
|
-
this.memoryReadResult = exports.EMPTY_MEMORY;
|
|
312
|
-
this.fireDidChangeMemory();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
handleSessionChange() {
|
|
316
|
-
var _a, _b;
|
|
317
|
-
const isStopped = ((_a = this.sessionManager.currentSession) === null || _a === void 0 ? void 0 : _a.state) === debug_session_1.DebugState.Stopped;
|
|
318
|
-
const isReadyForQuery = !!((_b = this.sessionManager.currentSession) === null || _b === void 0 ? void 0 : _b.currentFrame);
|
|
319
|
-
const isDynamic = this.memoryWidgetOptions.dynamic !== false;
|
|
320
|
-
if (isStopped && isReadyForQuery && isDynamic && this.doUpdateAutomatically && this.memoryReadResult !== exports.EMPTY_MEMORY) {
|
|
321
|
-
this.updateMemoryView();
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
onActivateRequest(msg) {
|
|
325
|
-
super.onActivateRequest(msg);
|
|
326
|
-
this.acceptFocus();
|
|
327
|
-
}
|
|
328
|
-
acceptFocus() {
|
|
329
|
-
if (this.doUpdateAutomatically) {
|
|
330
|
-
if (this.addressField) {
|
|
331
|
-
this.addressField.focus();
|
|
332
|
-
this.addressField.select();
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
const settingsCog = this.node.querySelector('.toggle-settings-click-zone');
|
|
337
|
-
settingsCog === null || settingsCog === void 0 ? void 0 : settingsCog.focus();
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
doHandleColumnSelectionChange(columnLabel, doShow) {
|
|
341
|
-
if (columnLabel in this.columnsDisplayed) {
|
|
342
|
-
this.columnsDisplayed[columnLabel].doRender = doShow;
|
|
343
|
-
this.fireDidChangeOptions(exports.ASCII_TOGGLE_ID);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
onAfterAttach(msg) {
|
|
347
|
-
super.onAfterAttach(msg);
|
|
348
|
-
if (this.memoryWidgetOptions.dynamic !== false) {
|
|
349
|
-
if (this.addressField) {
|
|
350
|
-
this.addressField.value = this.address.toString();
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
render() {
|
|
355
|
-
return (React.createElement("div", { className: 't-mv-container' }, this.renderInputContainer()));
|
|
356
|
-
}
|
|
357
|
-
renderInputContainer() {
|
|
358
|
-
return (React.createElement("div", { className: 't-mv-settings-container' },
|
|
359
|
-
React.createElement("div", { className: 't-mv-wrapper' },
|
|
360
|
-
this.renderToolbar(),
|
|
361
|
-
this.renderMemoryLocationGroup(),
|
|
362
|
-
this.doDisplaySettings && (React.createElement("div", { className: 't-mv-toggle-settings-wrapper' }, this.renderByteDisplayGroup())))));
|
|
363
|
-
}
|
|
364
|
-
renderByteDisplayGroup() {
|
|
365
|
-
return (React.createElement("div", { className: 't-mv-group settings-group' },
|
|
366
|
-
React.createElement(memory_widget_components_1.MWSelect, { id: 'byte-size-select', label: core_1.nls.localize('theia/memory-inspector/byteSize', 'Byte Size'), value: this.byteSize.toString(), onChange: this.onByteSizeChange, options: ['8', '16', '32', '64'] }),
|
|
367
|
-
React.createElement(memory_widget_components_1.MWSelect, { id: exports.BYTES_PER_GROUP_FIELD_ID, label: core_1.nls.localize('theia/memory-inspector/bytesPerGroup', 'Bytes Per Group'), value: this.bytesPerGroup.toString(), onChange: this.onBytesPerGroupChange, options: ['1', '2', '4', '8', '16'] }),
|
|
368
|
-
React.createElement(memory_widget_components_1.MWSelect, { id: exports.BYTES_PER_ROW_FIELD_ID, label: core_1.nls.localize('theia/memory-inspector/groupsPerRow', 'Groups Per Row'), value: this.groupsPerRow.toString(), onChange: this.onGroupsPerRowChange, options: ['1', '2', '4', '8', '16', '32'] }),
|
|
369
|
-
React.createElement(memory_widget_components_1.MWSelect, { id: exports.ENDIAN_SELECT_ID, label: core_1.nls.localize('theia/memory-inspector/endianness', 'Endianness'), value: this.endianness, onChange: this.onEndiannessChange, options: [memory_widget_utils_1.Interfaces.Endianness.Little, memory_widget_utils_1.Interfaces.Endianness.Big] }),
|
|
370
|
-
React.createElement(multi_select_bar_1.MWMultiSelect, { id: exports.ASCII_TOGGLE_ID, label: core_1.nls.localize('theia/memory-inspector/columns', 'Columns'), items: this.getOptionalColumns(), onSelectionChanged: this.handleColumnSelectionChange })));
|
|
371
|
-
}
|
|
372
|
-
getObligatoryColumnIds() {
|
|
373
|
-
return ['address', 'data'];
|
|
374
|
-
}
|
|
375
|
-
getOptionalColumns() {
|
|
376
|
-
const obligatoryColumns = new Set(this.getObligatoryColumnIds());
|
|
377
|
-
return Object.entries(this.columnsDisplayed)
|
|
378
|
-
.reduce((accumulated, [id, { doRender, label }]) => {
|
|
379
|
-
if (!obligatoryColumns.has(id)) {
|
|
380
|
-
accumulated.push({ id, label, defaultChecked: doRender });
|
|
381
|
-
}
|
|
382
|
-
return accumulated;
|
|
383
|
-
}, []);
|
|
384
|
-
}
|
|
385
|
-
renderMemoryLocationGroup() {
|
|
386
|
-
return (React.createElement(React.Fragment, null,
|
|
387
|
-
React.createElement("div", { className: 't-mv-group view-group' },
|
|
388
|
-
React.createElement(memory_widget_components_1.MWInputWithSelect, { id: exports.LOCATION_FIELD_ID, label: core_1.nls.localizeByDefault('Address'), title: core_1.nls.localize('theia/memory-inspector/addressTooltip', 'Memory location to display, an address or expression evaluating to an address'), defaultValue: `${this.address}`, onSelectChange: this.setAddressFromSelect, passRef: this.assignLocationRef, onKeyDown: this.doRefresh, options: [...this.recentLocations.values], disabled: !this.doUpdateAutomatically }),
|
|
389
|
-
React.createElement(memory_widget_components_1.MWInput, { id: exports.LOCATION_OFFSET_FIELD_ID, label: core_1.nls.localize('theia/memory-inspector/offset', 'Offset'), title: core_1.nls.localize('theia/memory-inspector/offsetTooltip', 'Offset to be added to the current memory location, when navigating'), defaultValue: '0', passRef: this.assignOffsetRef, onKeyDown: this.doRefresh, disabled: !this.doUpdateAutomatically }),
|
|
390
|
-
React.createElement(memory_widget_components_1.MWInput, { id: exports.LENGTH_FIELD_ID, label: core_1.nls.localize('theia/memory-inspector/length', 'Length'), title: core_1.nls.localize('theia/memory-inspector/lengthTooltip', 'Number of bytes to fetch, in decimal or hexadecimal'), defaultValue: this.readLength.toString(), passRef: this.assignReadLengthRef, onChange: memory_widget_utils_1.Utils.validateNumericalInputs, onKeyDown: this.doRefresh, disabled: !this.doUpdateAutomatically }),
|
|
391
|
-
React.createElement("button", { type: 'button', className: 'theia-button main view-group-go-button', onClick: this.doRefresh, disabled: !this.doUpdateAutomatically, title: core_1.nls.localizeByDefault('Go') }, core_1.nls.localizeByDefault('Go'))),
|
|
392
|
-
React.createElement("div", { className: `t-mv-memory-fetch-error${this.showMemoryError ? ' show' : ' hide'}` }, this.memoryReadError)));
|
|
393
|
-
}
|
|
394
|
-
updateHeader(isCancelKey) {
|
|
395
|
-
if (!isCancelKey && this.headerInputField) {
|
|
396
|
-
this.title.label = this.headerInputField.value;
|
|
397
|
-
this.title.caption = this.headerInputField.value;
|
|
398
|
-
}
|
|
399
|
-
this.isTitleEditable = false;
|
|
400
|
-
this.update();
|
|
401
|
-
}
|
|
402
|
-
renderToolbar() {
|
|
403
|
-
return (React.createElement("div", { className: 'memory-widget-toolbar' },
|
|
404
|
-
this.renderLockIcon(),
|
|
405
|
-
this.renderEditableTitleField(),
|
|
406
|
-
this.renderSettingsContainer()));
|
|
407
|
-
}
|
|
408
|
-
renderSettingsContainer() {
|
|
409
|
-
return React.createElement("div", { className: 'toggle-settings-container' },
|
|
410
|
-
React.createElement("div", { className: 'toggle-settings-click-zone no-select', tabIndex: 0, "aria-label": this.doDisplaySettings ?
|
|
411
|
-
core_1.nls.localize('theia/memory-inspector/memory/hideSettings', 'Hide Settings Panel') :
|
|
412
|
-
core_1.nls.localize('theia/memory-inspector/memory/showSettings', 'Show Settings Panel'), role: 'button', onClick: this.toggleDoShowSettings, onKeyDown: this.toggleDoShowSettings, title: this.doDisplaySettings ?
|
|
413
|
-
core_1.nls.localize('theia/memory-inspector/memory/hideSettings', 'Hide Settings Panel') :
|
|
414
|
-
core_1.nls.localize('theia/memory-inspector/memory/showSettings', 'Show Settings Panel') },
|
|
415
|
-
React.createElement("i", { className: 'codicon codicon-settings-gear' }),
|
|
416
|
-
React.createElement("span", null, this.doDisplaySettings ?
|
|
417
|
-
core_1.nls.localize('theia/memory-inspector/closeSettings', 'Close Settings') :
|
|
418
|
-
core_1.nls.localizeByDefault('Settings'))));
|
|
419
|
-
}
|
|
420
|
-
renderLockIcon() {
|
|
421
|
-
return this.memoryWidgetOptions.dynamic !== false && (React.createElement("div", { className: 'memory-widget-auto-updates-container' },
|
|
422
|
-
React.createElement("div", { className: `fa fa-${this.doUpdateAutomatically ? 'unlock' : 'lock'}`, id: exports.AUTO_UPDATE_TOGGLE_ID, title: this.doUpdateAutomatically ?
|
|
423
|
-
core_1.nls.localize('theia/memory-inspector/memory/freeze', 'Freeze Memory View') :
|
|
424
|
-
core_1.nls.localize('theia/memory-inspector/memory/unfreeze', 'Unfreeze Memory View'), onClick: this.toggleAutoUpdate, onKeyDown: this.toggleAutoUpdate, role: 'button', tabIndex: 0 })));
|
|
425
|
-
}
|
|
426
|
-
renderEditableTitleField() {
|
|
427
|
-
return (React.createElement("div", { className: 'memory-widget-header-click-zone', tabIndex: 0, onClick: this.activateHeaderInputField, onKeyDown: this.activateHeaderInputField, role: 'button' },
|
|
428
|
-
!this.isTitleEditable
|
|
429
|
-
? (React.createElement("h2", { className: `${MemoryOptionsWidget_1.WIDGET_H2_CLASS}${!this.doUpdateAutomatically ? ' disabled' : ''} no-select` }, this.title.label))
|
|
430
|
-
: React.createElement("input", { className: 'theia-input', type: 'text', defaultValue: this.title.label, onKeyDown: this.saveHeaderInputValue, spellCheck: false, ref: this.assignHeaderInputRef }),
|
|
431
|
-
!this.isTitleEditable && (React.createElement("div", { className: `fa fa-pencil${this.showTitleEditIcon ? ' show' : ' hide'}` })),
|
|
432
|
-
this.isTitleEditable && (React.createElement("div", { className: 'fa fa-save', onClick: this.saveHeaderInputValue, onKeyDown: this.saveHeaderInputValue, role: 'button', tabIndex: 0, title: core_1.nls.localizeByDefault('Save') }))));
|
|
433
|
-
}
|
|
434
|
-
storeState() {
|
|
435
|
-
var _a, _b, _c, _d, _e, _f;
|
|
436
|
-
return {
|
|
437
|
-
address: (_b = (_a = this.addressField) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : this.address,
|
|
438
|
-
offset: (_d = parseInt(`${(_c = this.offsetField) === null || _c === void 0 ? void 0 : _c.value}`)) !== null && _d !== void 0 ? _d : this.offset,
|
|
439
|
-
length: (_f = parseInt(`${(_e = this.readLengthField) === null || _e === void 0 ? void 0 : _e.value}`)) !== null && _f !== void 0 ? _f : this.readLength,
|
|
440
|
-
byteSize: this.byteSize,
|
|
441
|
-
bytesPerGroup: this.bytesPerGroup,
|
|
442
|
-
groupsPerRow: this.groupsPerRow,
|
|
443
|
-
endianness: this.endianness,
|
|
444
|
-
doDisplaySettings: this.doDisplaySettings,
|
|
445
|
-
columnsDisplayed: this.columnsDisplayed,
|
|
446
|
-
recentLocationsArray: this.recentLocations.values,
|
|
447
|
-
isFrozen: !this.doUpdateAutomatically,
|
|
448
|
-
doUpdateAutomatically: this.doUpdateAutomatically,
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
restoreState(oldState) {
|
|
452
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
453
|
-
this.address = (_a = oldState.address) !== null && _a !== void 0 ? _a : this.address;
|
|
454
|
-
this.offset = (_b = oldState.offset) !== null && _b !== void 0 ? _b : this.offset;
|
|
455
|
-
this.readLength = (_c = oldState.length) !== null && _c !== void 0 ? _c : this.readLength;
|
|
456
|
-
this.byteSize = (_d = oldState.byteSize) !== null && _d !== void 0 ? _d : this.byteSize;
|
|
457
|
-
this.bytesPerGroup = (_e = oldState.bytesPerGroup) !== null && _e !== void 0 ? _e : this.bytesPerGroup;
|
|
458
|
-
this.groupsPerRow = (_f = oldState.groupsPerRow) !== null && _f !== void 0 ? _f : this.groupsPerRow;
|
|
459
|
-
this.endianness = (_g = oldState.endianness) !== null && _g !== void 0 ? _g : this.endianness;
|
|
460
|
-
this.recentLocations = (_h = new memory_recents_1.Recents(oldState.recentLocationsArray)) !== null && _h !== void 0 ? _h : this.recentLocations;
|
|
461
|
-
this.doDisplaySettings = !!oldState.doDisplaySettings;
|
|
462
|
-
if (oldState.columnsDisplayed) {
|
|
463
|
-
this.columnsDisplayed = oldState.columnsDisplayed;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
fetchNewMemory() {
|
|
467
|
-
this.updateMemoryView();
|
|
468
|
-
}
|
|
469
|
-
async doUpdateMemoryView() {
|
|
470
|
-
var _a, _b;
|
|
471
|
-
if (!(this.addressField && this.readLengthField)) {
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
if (((_a = this.addressField) === null || _a === void 0 ? void 0 : _a.value.trim().length) === 0) {
|
|
475
|
-
this.memoryReadError = core_1.nls.localize('theia/memory-inspector/memory/addressField/memoryReadError', 'Enter an address or expression in the Location field.');
|
|
476
|
-
this.doShowMemoryErrors();
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
if (this.readLengthField.value.trim().length === 0) {
|
|
480
|
-
this.memoryReadError = core_1.nls.localize('theia/memory-inspector/memory/readLength/memoryReadError', 'Enter a length (decimal or hexadecimal number) in the Length field.');
|
|
481
|
-
this.doShowMemoryErrors();
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
const startAddress = this.addressField.value;
|
|
485
|
-
const locationOffset = parseInt(`${(_b = this.offsetField) === null || _b === void 0 ? void 0 : _b.value}`) || 0;
|
|
486
|
-
const readLength = parseInt(this.readLengthField.value);
|
|
487
|
-
try {
|
|
488
|
-
this.memoryReadResult = await this.getMemory(startAddress, readLength, locationOffset);
|
|
489
|
-
this.fireDidChangeMemory();
|
|
490
|
-
if (this.pinnedMemoryReadResult) {
|
|
491
|
-
this.pinnedMemoryReadResult.resolve(this.memoryReadResult);
|
|
492
|
-
}
|
|
493
|
-
this.doShowMemoryErrors(true);
|
|
494
|
-
}
|
|
495
|
-
catch (err) {
|
|
496
|
-
this.memoryReadError = this.getUserError(err);
|
|
497
|
-
console.error('Failed to read memory', err);
|
|
498
|
-
this.doShowMemoryErrors();
|
|
499
|
-
if (this.pinnedMemoryReadResult) {
|
|
500
|
-
this.pinnedMemoryReadResult.resolve(this.memoryReadResult);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
finally {
|
|
504
|
-
this.pinnedMemoryReadResult = undefined;
|
|
505
|
-
this.update();
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
getUserError(err) {
|
|
509
|
-
return err instanceof Error ? err.message : core_1.nls.localize('theia/memory-inspector/memory/userError', 'There was an error fetching memory.');
|
|
510
|
-
}
|
|
511
|
-
async getMemory(memoryReference, count, offset) {
|
|
512
|
-
const result = await this.retrieveMemory(memoryReference, count, offset);
|
|
513
|
-
try {
|
|
514
|
-
this.variables = await this.memoryProvider.getLocals();
|
|
515
|
-
}
|
|
516
|
-
catch {
|
|
517
|
-
this.variables = [];
|
|
518
|
-
}
|
|
519
|
-
this.recentLocations.add(memoryReference);
|
|
520
|
-
this.updateDefaults(memoryReference, count, offset);
|
|
521
|
-
return result;
|
|
522
|
-
}
|
|
523
|
-
async retrieveMemory(memoryReference, count, offset) {
|
|
524
|
-
return this.memoryProvider.readMemory({ memoryReference, count, offset });
|
|
525
|
-
}
|
|
526
|
-
// TODO: This may not be necessary if we change how state is stored (currently in the text fields themselves.)
|
|
527
|
-
updateDefaults(address, readLength, offset) {
|
|
528
|
-
this.address = address;
|
|
529
|
-
this.readLength = readLength;
|
|
530
|
-
this.offset = offset;
|
|
531
|
-
}
|
|
532
|
-
fireDidChangeOptions(targetId) {
|
|
533
|
-
this.onOptionsChangedEmitter.fire(targetId);
|
|
534
|
-
}
|
|
535
|
-
fireDidChangeMemory() {
|
|
536
|
-
this.onMemoryChangedEmitter.fire(this.memoryReadResult);
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
|
-
MemoryOptionsWidget.ID = 'memory-view-options-widget';
|
|
540
|
-
MemoryOptionsWidget.LABEL = core_1.nls.localize('theia/memory-inspector/memoryTitle', 'Memory');
|
|
541
|
-
MemoryOptionsWidget.WIDGET_H2_CLASS = 'memory-widget-header';
|
|
542
|
-
MemoryOptionsWidget.WIDGET_HEADER_INPUT_CLASS = 'memory-widget-header-input';
|
|
543
|
-
__decorate([
|
|
544
|
-
(0, inversify_1.inject)(memory_provider_service_1.MemoryProviderService),
|
|
545
|
-
__metadata("design:type", memory_provider_service_1.MemoryProviderService)
|
|
546
|
-
], MemoryOptionsWidget.prototype, "memoryProvider", void 0);
|
|
547
|
-
__decorate([
|
|
548
|
-
(0, inversify_1.inject)(debug_session_manager_1.DebugSessionManager),
|
|
549
|
-
__metadata("design:type", debug_session_manager_1.DebugSessionManager)
|
|
550
|
-
], MemoryOptionsWidget.prototype, "sessionManager", void 0);
|
|
551
|
-
__decorate([
|
|
552
|
-
(0, inversify_1.inject)(memory_widget_utils_1.MemoryWidgetOptions),
|
|
553
|
-
__metadata("design:type", Object)
|
|
554
|
-
], MemoryOptionsWidget.prototype, "memoryWidgetOptions", void 0);
|
|
555
|
-
__decorate([
|
|
556
|
-
(0, inversify_1.postConstruct)(),
|
|
557
|
-
__metadata("design:type", Function),
|
|
558
|
-
__metadata("design:paramtypes", []),
|
|
559
|
-
__metadata("design:returntype", void 0)
|
|
560
|
-
], MemoryOptionsWidget.prototype, "init", null);
|
|
561
|
-
MemoryOptionsWidget = MemoryOptionsWidget_1 = __decorate([
|
|
562
|
-
(0, inversify_1.injectable)()
|
|
563
|
-
], MemoryOptionsWidget);
|
|
564
|
-
exports.MemoryOptionsWidget = MemoryOptionsWidget;
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (C) 2021 Ericsson and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
var MemoryOptionsWidget_1;
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.MemoryOptionsWidget = exports.AUTO_UPDATE_TOGGLE_ID = exports.ASCII_TOGGLE_ID = exports.ENDIAN_SELECT_ID = exports.BYTES_PER_GROUP_FIELD_ID = exports.BYTES_PER_ROW_FIELD_ID = exports.LOCATION_OFFSET_FIELD_ID = exports.LENGTH_FIELD_ID = exports.LOCATION_FIELD_ID = exports.EMPTY_MEMORY = void 0;
|
|
29
|
+
const core_1 = require("@theia/core");
|
|
30
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
31
|
+
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
32
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
33
|
+
const React = require("@theia/core/shared/react");
|
|
34
|
+
const debug_session_1 = require("@theia/debug/lib/browser/debug-session");
|
|
35
|
+
const debug_session_manager_1 = require("@theia/debug/lib/browser/debug-session-manager");
|
|
36
|
+
const Long = require("long");
|
|
37
|
+
const memory_provider_service_1 = require("../memory-provider/memory-provider-service");
|
|
38
|
+
const memory_recents_1 = require("../utils/memory-recents");
|
|
39
|
+
const memory_widget_components_1 = require("../utils/memory-widget-components");
|
|
40
|
+
const memory_widget_utils_1 = require("../utils/memory-widget-utils");
|
|
41
|
+
const multi_select_bar_1 = require("../utils/multi-select-bar");
|
|
42
|
+
const debounce = require("@theia/core/shared/lodash.debounce");
|
|
43
|
+
exports.EMPTY_MEMORY = (0, core_1.deepFreeze)({
|
|
44
|
+
bytes: new Uint8Array(),
|
|
45
|
+
address: new Long(0, 0, true),
|
|
46
|
+
});
|
|
47
|
+
exports.LOCATION_FIELD_ID = 't-mv-location';
|
|
48
|
+
exports.LENGTH_FIELD_ID = 't-mv-length';
|
|
49
|
+
exports.LOCATION_OFFSET_FIELD_ID = 't-mv-location-offset';
|
|
50
|
+
exports.BYTES_PER_ROW_FIELD_ID = 't-mv-bytesrow';
|
|
51
|
+
exports.BYTES_PER_GROUP_FIELD_ID = 't-mv-bytesgroup';
|
|
52
|
+
exports.ENDIAN_SELECT_ID = 't-mv-endiannesss';
|
|
53
|
+
exports.ASCII_TOGGLE_ID = 't-mv-ascii-toggle';
|
|
54
|
+
exports.AUTO_UPDATE_TOGGLE_ID = 't-mv-auto-update-toggle';
|
|
55
|
+
let MemoryOptionsWidget = MemoryOptionsWidget_1 = class MemoryOptionsWidget extends browser_1.ReactWidget {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
this.iconClass = 'memory-view-icon';
|
|
59
|
+
this.lockIconClass = 'memory-lock-icon';
|
|
60
|
+
this.additionalColumnSelectLabel = core_1.nls.localize('theia/memory-inspector/extraColumn', 'Extra Column');
|
|
61
|
+
this.sessionListeners = new core_1.DisposableCollection();
|
|
62
|
+
this.onOptionsChangedEmitter = new core_1.Emitter();
|
|
63
|
+
this.onOptionsChanged = this.onOptionsChangedEmitter.event;
|
|
64
|
+
this.onMemoryChangedEmitter = new core_1.Emitter();
|
|
65
|
+
this.onMemoryChanged = this.onMemoryChangedEmitter.event;
|
|
66
|
+
this.memoryReadResult = exports.EMPTY_MEMORY;
|
|
67
|
+
this.columnsDisplayed = {
|
|
68
|
+
address: {
|
|
69
|
+
label: core_1.nls.localizeByDefault('Address'),
|
|
70
|
+
doRender: true
|
|
71
|
+
},
|
|
72
|
+
data: {
|
|
73
|
+
label: core_1.nls.localize('theia/memory-inspector/data', 'Data'),
|
|
74
|
+
doRender: true
|
|
75
|
+
},
|
|
76
|
+
variables: {
|
|
77
|
+
label: core_1.nls.localizeByDefault('Variables'),
|
|
78
|
+
doRender: true
|
|
79
|
+
},
|
|
80
|
+
ascii: {
|
|
81
|
+
label: core_1.nls.localize('theia/memory-inspector/ascii', 'ASCII'),
|
|
82
|
+
doRender: false
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
this.byteSize = 8;
|
|
86
|
+
this.bytesPerGroup = 1;
|
|
87
|
+
this.groupsPerRow = 4;
|
|
88
|
+
this.variables = [];
|
|
89
|
+
this.endianness = memory_widget_utils_1.Interfaces.Endianness.Little;
|
|
90
|
+
this.memoryReadError = core_1.nls.localize('theia/memory-inspector/memory/readError/noContents', 'No memory contents currently available.');
|
|
91
|
+
this.address = 0;
|
|
92
|
+
this.offset = 0;
|
|
93
|
+
this.readLength = 256;
|
|
94
|
+
this.doDisplaySettings = false;
|
|
95
|
+
this.doUpdateAutomatically = true;
|
|
96
|
+
this.showMemoryError = false;
|
|
97
|
+
this.errorTimeout = undefined;
|
|
98
|
+
this.recentLocations = new memory_recents_1.Recents();
|
|
99
|
+
this.showTitleEditIcon = false;
|
|
100
|
+
this.isTitleEditable = false;
|
|
101
|
+
this.handleColumnSelectionChange = (columnLabel, doShow) => this.doHandleColumnSelectionChange(columnLabel, doShow);
|
|
102
|
+
this.toggleAutoUpdate = (e) => {
|
|
103
|
+
var _a;
|
|
104
|
+
if (e.nativeEvent.type === 'click') {
|
|
105
|
+
e.currentTarget.blur();
|
|
106
|
+
}
|
|
107
|
+
if ('key' in e && ((_a = browser_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _a === void 0 ? void 0 : _a.keyCode) === browser_1.Key.TAB.keyCode) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.doUpdateAutomatically = !this.doUpdateAutomatically;
|
|
111
|
+
if (this.doUpdateAutomatically) {
|
|
112
|
+
this.title.iconClass = this.iconClass;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
this.title.iconClass = this.lockIconClass;
|
|
116
|
+
}
|
|
117
|
+
this.fireDidChangeOptions();
|
|
118
|
+
};
|
|
119
|
+
this.onByteSizeChange = (event) => {
|
|
120
|
+
this.byteSize = parseInt(event.target.value);
|
|
121
|
+
this.fireDidChangeOptions(event.target.id);
|
|
122
|
+
};
|
|
123
|
+
this.toggleDoShowSettings = (e) => {
|
|
124
|
+
var _a;
|
|
125
|
+
if (!('key' in e) || ((_a = browser_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _a === void 0 ? void 0 : _a.keyCode) === browser_1.Key.TAB.keyCode) {
|
|
126
|
+
this.doDisplaySettings = !this.doDisplaySettings;
|
|
127
|
+
this.update();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
this.assignLocationRef = location => {
|
|
131
|
+
this.addressField = location !== null && location !== void 0 ? location : undefined;
|
|
132
|
+
};
|
|
133
|
+
this.assignReadLengthRef = readLength => {
|
|
134
|
+
this.readLengthField = readLength !== null && readLength !== void 0 ? readLength : undefined;
|
|
135
|
+
};
|
|
136
|
+
this.assignOffsetRef = offset => {
|
|
137
|
+
this.offsetField = offset !== null && offset !== void 0 ? offset : undefined;
|
|
138
|
+
};
|
|
139
|
+
this.setAddressFromSelect = (e) => {
|
|
140
|
+
if (this.addressField) {
|
|
141
|
+
this.addressField.value = e.target.value;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
this.activateHeaderInputField = (e) => {
|
|
145
|
+
var _a, _b;
|
|
146
|
+
if (!this.isTitleEditable) {
|
|
147
|
+
const isMouseDown = !('key' in e);
|
|
148
|
+
const isActivationKey = 'key' in e && (((_a = browser_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _a === void 0 ? void 0 : _a.keyCode) === browser_1.Key.SPACE.keyCode
|
|
149
|
+
|| ((_b = browser_1.KeyCode.createKeyCode(e.nativeEvent).key) === null || _b === void 0 ? void 0 : _b.keyCode) === browser_1.Key.ENTER.keyCode);
|
|
150
|
+
if (isMouseDown || isActivationKey) {
|
|
151
|
+
if (isMouseDown) {
|
|
152
|
+
e.currentTarget.blur();
|
|
153
|
+
}
|
|
154
|
+
this.isTitleEditable = true;
|
|
155
|
+
this.update();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
this.saveHeaderInputValue = (e) => {
|
|
160
|
+
const isMouseDown = !('key' in e);
|
|
161
|
+
const isSaveKey = 'key' in e && e.key === 'Enter';
|
|
162
|
+
const isCancelKey = 'key' in e && e.key === 'Escape';
|
|
163
|
+
e.stopPropagation();
|
|
164
|
+
if (isMouseDown || isSaveKey || isCancelKey) {
|
|
165
|
+
this.updateHeader(isCancelKey);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
this.assignHeaderInputRef = (element) => {
|
|
169
|
+
if (element) {
|
|
170
|
+
this.headerInputField = element;
|
|
171
|
+
element.focus();
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
this.doShowMemoryErrors = (doClearError = false) => {
|
|
175
|
+
if (this.errorTimeout !== undefined) {
|
|
176
|
+
clearTimeout(this.errorTimeout);
|
|
177
|
+
}
|
|
178
|
+
if (doClearError) {
|
|
179
|
+
this.showMemoryError = false;
|
|
180
|
+
this.update();
|
|
181
|
+
this.errorTimeout = undefined;
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
this.showMemoryError = true;
|
|
185
|
+
this.update();
|
|
186
|
+
this.errorTimeout = setTimeout(() => {
|
|
187
|
+
this.showMemoryError = false;
|
|
188
|
+
this.update();
|
|
189
|
+
this.errorTimeout = undefined;
|
|
190
|
+
}, memory_widget_utils_1.Constants.ERROR_TIMEOUT);
|
|
191
|
+
};
|
|
192
|
+
this.doRefresh = (event) => {
|
|
193
|
+
if ('key' in event && event.key !== 'Enter') {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
this.updateMemoryView();
|
|
197
|
+
};
|
|
198
|
+
this.updateMemoryView = debounce(this.doUpdateMemoryView.bind(this), memory_widget_utils_1.Constants.DEBOUNCE_TIME, { trailing: true });
|
|
199
|
+
// Callbacks for when the various view parameters change.
|
|
200
|
+
/**
|
|
201
|
+
* Handle bytes per row changed event.
|
|
202
|
+
*/
|
|
203
|
+
this.onGroupsPerRowChange = (event) => {
|
|
204
|
+
const { value, id } = event.target;
|
|
205
|
+
this.groupsPerRow = parseInt(value);
|
|
206
|
+
this.fireDidChangeOptions(id);
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Handle bytes per group changed event.
|
|
210
|
+
*/
|
|
211
|
+
this.onBytesPerGroupChange = (event) => {
|
|
212
|
+
const { value, id } = event.target;
|
|
213
|
+
this.bytesPerGroup = parseInt(value);
|
|
214
|
+
this.fireDidChangeOptions(id);
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Handle endianness changed event.
|
|
218
|
+
*/
|
|
219
|
+
this.onEndiannessChange = (event) => {
|
|
220
|
+
const { value, id } = event.target;
|
|
221
|
+
if (value !== memory_widget_utils_1.Interfaces.Endianness.Big && value !== memory_widget_utils_1.Interfaces.Endianness.Little) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
this.endianness = value;
|
|
225
|
+
this.fireDidChangeOptions(id);
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
get memory() {
|
|
229
|
+
return {
|
|
230
|
+
...this.memoryReadResult,
|
|
231
|
+
variables: this.variables,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
get options() {
|
|
235
|
+
return this.storeState();
|
|
236
|
+
}
|
|
237
|
+
init() {
|
|
238
|
+
this.addClass(MemoryOptionsWidget_1.ID);
|
|
239
|
+
this.title.label = core_1.nls.localize('theia/memory-inspector/memory', 'Memory ({0})', this.memoryWidgetOptions.displayId);
|
|
240
|
+
this.title.caption = core_1.nls.localize('theia/memory-inspector/memory', 'Memory ({0})', this.memoryWidgetOptions.displayId);
|
|
241
|
+
this.title.iconClass = this.iconClass;
|
|
242
|
+
this.title.closable = true;
|
|
243
|
+
if (this.memoryWidgetOptions.dynamic !== false) {
|
|
244
|
+
this.toDispose.push(this.sessionManager.onDidChangeActiveDebugSession(({ current }) => {
|
|
245
|
+
this.setUpListeners(current);
|
|
246
|
+
}));
|
|
247
|
+
this.toDispose.push(this.sessionManager.onDidCreateDebugSession(current => {
|
|
248
|
+
this.setUpListeners(current);
|
|
249
|
+
}));
|
|
250
|
+
this.setUpListeners(this.sessionManager.currentSession);
|
|
251
|
+
}
|
|
252
|
+
this.toDispose.push(this.onOptionsChanged(() => this.update()));
|
|
253
|
+
this.update();
|
|
254
|
+
}
|
|
255
|
+
async setAddressAndGo(newAddress, newOffset, newLength, direction) {
|
|
256
|
+
let doUpdate = false;
|
|
257
|
+
const originalValues = {
|
|
258
|
+
offset: '',
|
|
259
|
+
length: '',
|
|
260
|
+
};
|
|
261
|
+
if (this.addressField) {
|
|
262
|
+
this.addressField.value = newAddress;
|
|
263
|
+
doUpdate = true;
|
|
264
|
+
}
|
|
265
|
+
if (this.offsetField && newOffset !== undefined) {
|
|
266
|
+
originalValues.offset = this.offsetField.value;
|
|
267
|
+
this.offsetField.value = newOffset.toString();
|
|
268
|
+
doUpdate = true;
|
|
269
|
+
}
|
|
270
|
+
if (this.readLengthField && newLength !== undefined) {
|
|
271
|
+
originalValues.length = this.readLengthField.value;
|
|
272
|
+
this.readLengthField.value = newLength.toString();
|
|
273
|
+
doUpdate = true;
|
|
274
|
+
}
|
|
275
|
+
if (doUpdate && this.readLengthField && this.offsetField) {
|
|
276
|
+
this.pinnedMemoryReadResult = new promise_util_1.Deferred();
|
|
277
|
+
this.updateMemoryView();
|
|
278
|
+
const result = await this.pinnedMemoryReadResult.promise;
|
|
279
|
+
if (result === false) {
|
|
280
|
+
// Memory request errored
|
|
281
|
+
this.readLengthField.value = originalValues.length;
|
|
282
|
+
this.offsetField.value = originalValues.offset;
|
|
283
|
+
}
|
|
284
|
+
if (result) {
|
|
285
|
+
// Memory request returned some memory
|
|
286
|
+
const resultLength = result.bytes.length * 8 / this.byteSize;
|
|
287
|
+
const lengthFieldValue = parseInt(this.readLengthField.value);
|
|
288
|
+
if (lengthFieldValue !== resultLength) {
|
|
289
|
+
this.memoryReadError = core_1.nls.localize('theia/memory-inspector/memory/readError/bounds', 'Memory bounds exceeded, result will be truncated.');
|
|
290
|
+
this.doShowMemoryErrors();
|
|
291
|
+
this.readLengthField.value = resultLength.toString();
|
|
292
|
+
if (direction === 'above') {
|
|
293
|
+
this.offsetField.value = `${parseInt(originalValues.offset) - (resultLength - parseInt(originalValues.length))}`;
|
|
294
|
+
}
|
|
295
|
+
this.update();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
setUpListeners(session) {
|
|
302
|
+
this.sessionListeners.dispose();
|
|
303
|
+
this.sessionListeners = new core_1.DisposableCollection(core_1.Disposable.create(() => this.handleActiveSessionChange()));
|
|
304
|
+
if (session) {
|
|
305
|
+
this.sessionListeners.push(session.onDidChange(() => this.handleSessionChange()));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
handleActiveSessionChange() {
|
|
309
|
+
const isDynamic = this.memoryWidgetOptions.dynamic !== false;
|
|
310
|
+
if (isDynamic && this.doUpdateAutomatically) {
|
|
311
|
+
this.memoryReadResult = exports.EMPTY_MEMORY;
|
|
312
|
+
this.fireDidChangeMemory();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
handleSessionChange() {
|
|
316
|
+
var _a, _b;
|
|
317
|
+
const isStopped = ((_a = this.sessionManager.currentSession) === null || _a === void 0 ? void 0 : _a.state) === debug_session_1.DebugState.Stopped;
|
|
318
|
+
const isReadyForQuery = !!((_b = this.sessionManager.currentSession) === null || _b === void 0 ? void 0 : _b.currentFrame);
|
|
319
|
+
const isDynamic = this.memoryWidgetOptions.dynamic !== false;
|
|
320
|
+
if (isStopped && isReadyForQuery && isDynamic && this.doUpdateAutomatically && this.memoryReadResult !== exports.EMPTY_MEMORY) {
|
|
321
|
+
this.updateMemoryView();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
onActivateRequest(msg) {
|
|
325
|
+
super.onActivateRequest(msg);
|
|
326
|
+
this.acceptFocus();
|
|
327
|
+
}
|
|
328
|
+
acceptFocus() {
|
|
329
|
+
if (this.doUpdateAutomatically) {
|
|
330
|
+
if (this.addressField) {
|
|
331
|
+
this.addressField.focus();
|
|
332
|
+
this.addressField.select();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
const settingsCog = this.node.querySelector('.toggle-settings-click-zone');
|
|
337
|
+
settingsCog === null || settingsCog === void 0 ? void 0 : settingsCog.focus();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
doHandleColumnSelectionChange(columnLabel, doShow) {
|
|
341
|
+
if (columnLabel in this.columnsDisplayed) {
|
|
342
|
+
this.columnsDisplayed[columnLabel].doRender = doShow;
|
|
343
|
+
this.fireDidChangeOptions(exports.ASCII_TOGGLE_ID);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
onAfterAttach(msg) {
|
|
347
|
+
super.onAfterAttach(msg);
|
|
348
|
+
if (this.memoryWidgetOptions.dynamic !== false) {
|
|
349
|
+
if (this.addressField) {
|
|
350
|
+
this.addressField.value = this.address.toString();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
render() {
|
|
355
|
+
return (React.createElement("div", { className: 't-mv-container' }, this.renderInputContainer()));
|
|
356
|
+
}
|
|
357
|
+
renderInputContainer() {
|
|
358
|
+
return (React.createElement("div", { className: 't-mv-settings-container' },
|
|
359
|
+
React.createElement("div", { className: 't-mv-wrapper' },
|
|
360
|
+
this.renderToolbar(),
|
|
361
|
+
this.renderMemoryLocationGroup(),
|
|
362
|
+
this.doDisplaySettings && (React.createElement("div", { className: 't-mv-toggle-settings-wrapper' }, this.renderByteDisplayGroup())))));
|
|
363
|
+
}
|
|
364
|
+
renderByteDisplayGroup() {
|
|
365
|
+
return (React.createElement("div", { className: 't-mv-group settings-group' },
|
|
366
|
+
React.createElement(memory_widget_components_1.MWSelect, { id: 'byte-size-select', label: core_1.nls.localize('theia/memory-inspector/byteSize', 'Byte Size'), value: this.byteSize.toString(), onChange: this.onByteSizeChange, options: ['8', '16', '32', '64'] }),
|
|
367
|
+
React.createElement(memory_widget_components_1.MWSelect, { id: exports.BYTES_PER_GROUP_FIELD_ID, label: core_1.nls.localize('theia/memory-inspector/bytesPerGroup', 'Bytes Per Group'), value: this.bytesPerGroup.toString(), onChange: this.onBytesPerGroupChange, options: ['1', '2', '4', '8', '16'] }),
|
|
368
|
+
React.createElement(memory_widget_components_1.MWSelect, { id: exports.BYTES_PER_ROW_FIELD_ID, label: core_1.nls.localize('theia/memory-inspector/groupsPerRow', 'Groups Per Row'), value: this.groupsPerRow.toString(), onChange: this.onGroupsPerRowChange, options: ['1', '2', '4', '8', '16', '32'] }),
|
|
369
|
+
React.createElement(memory_widget_components_1.MWSelect, { id: exports.ENDIAN_SELECT_ID, label: core_1.nls.localize('theia/memory-inspector/endianness', 'Endianness'), value: this.endianness, onChange: this.onEndiannessChange, options: [memory_widget_utils_1.Interfaces.Endianness.Little, memory_widget_utils_1.Interfaces.Endianness.Big] }),
|
|
370
|
+
React.createElement(multi_select_bar_1.MWMultiSelect, { id: exports.ASCII_TOGGLE_ID, label: core_1.nls.localize('theia/memory-inspector/columns', 'Columns'), items: this.getOptionalColumns(), onSelectionChanged: this.handleColumnSelectionChange })));
|
|
371
|
+
}
|
|
372
|
+
getObligatoryColumnIds() {
|
|
373
|
+
return ['address', 'data'];
|
|
374
|
+
}
|
|
375
|
+
getOptionalColumns() {
|
|
376
|
+
const obligatoryColumns = new Set(this.getObligatoryColumnIds());
|
|
377
|
+
return Object.entries(this.columnsDisplayed)
|
|
378
|
+
.reduce((accumulated, [id, { doRender, label }]) => {
|
|
379
|
+
if (!obligatoryColumns.has(id)) {
|
|
380
|
+
accumulated.push({ id, label, defaultChecked: doRender });
|
|
381
|
+
}
|
|
382
|
+
return accumulated;
|
|
383
|
+
}, []);
|
|
384
|
+
}
|
|
385
|
+
renderMemoryLocationGroup() {
|
|
386
|
+
return (React.createElement(React.Fragment, null,
|
|
387
|
+
React.createElement("div", { className: 't-mv-group view-group' },
|
|
388
|
+
React.createElement(memory_widget_components_1.MWInputWithSelect, { id: exports.LOCATION_FIELD_ID, label: core_1.nls.localizeByDefault('Address'), title: core_1.nls.localize('theia/memory-inspector/addressTooltip', 'Memory location to display, an address or expression evaluating to an address'), defaultValue: `${this.address}`, onSelectChange: this.setAddressFromSelect, passRef: this.assignLocationRef, onKeyDown: this.doRefresh, options: [...this.recentLocations.values], disabled: !this.doUpdateAutomatically }),
|
|
389
|
+
React.createElement(memory_widget_components_1.MWInput, { id: exports.LOCATION_OFFSET_FIELD_ID, label: core_1.nls.localize('theia/memory-inspector/offset', 'Offset'), title: core_1.nls.localize('theia/memory-inspector/offsetTooltip', 'Offset to be added to the current memory location, when navigating'), defaultValue: '0', passRef: this.assignOffsetRef, onKeyDown: this.doRefresh, disabled: !this.doUpdateAutomatically }),
|
|
390
|
+
React.createElement(memory_widget_components_1.MWInput, { id: exports.LENGTH_FIELD_ID, label: core_1.nls.localize('theia/memory-inspector/length', 'Length'), title: core_1.nls.localize('theia/memory-inspector/lengthTooltip', 'Number of bytes to fetch, in decimal or hexadecimal'), defaultValue: this.readLength.toString(), passRef: this.assignReadLengthRef, onChange: memory_widget_utils_1.Utils.validateNumericalInputs, onKeyDown: this.doRefresh, disabled: !this.doUpdateAutomatically }),
|
|
391
|
+
React.createElement("button", { type: 'button', className: 'theia-button main view-group-go-button', onClick: this.doRefresh, disabled: !this.doUpdateAutomatically, title: core_1.nls.localizeByDefault('Go') }, core_1.nls.localizeByDefault('Go'))),
|
|
392
|
+
React.createElement("div", { className: `t-mv-memory-fetch-error${this.showMemoryError ? ' show' : ' hide'}` }, this.memoryReadError)));
|
|
393
|
+
}
|
|
394
|
+
updateHeader(isCancelKey) {
|
|
395
|
+
if (!isCancelKey && this.headerInputField) {
|
|
396
|
+
this.title.label = this.headerInputField.value;
|
|
397
|
+
this.title.caption = this.headerInputField.value;
|
|
398
|
+
}
|
|
399
|
+
this.isTitleEditable = false;
|
|
400
|
+
this.update();
|
|
401
|
+
}
|
|
402
|
+
renderToolbar() {
|
|
403
|
+
return (React.createElement("div", { className: 'memory-widget-toolbar' },
|
|
404
|
+
this.renderLockIcon(),
|
|
405
|
+
this.renderEditableTitleField(),
|
|
406
|
+
this.renderSettingsContainer()));
|
|
407
|
+
}
|
|
408
|
+
renderSettingsContainer() {
|
|
409
|
+
return React.createElement("div", { className: 'toggle-settings-container' },
|
|
410
|
+
React.createElement("div", { className: 'toggle-settings-click-zone no-select', tabIndex: 0, "aria-label": this.doDisplaySettings ?
|
|
411
|
+
core_1.nls.localize('theia/memory-inspector/memory/hideSettings', 'Hide Settings Panel') :
|
|
412
|
+
core_1.nls.localize('theia/memory-inspector/memory/showSettings', 'Show Settings Panel'), role: 'button', onClick: this.toggleDoShowSettings, onKeyDown: this.toggleDoShowSettings, title: this.doDisplaySettings ?
|
|
413
|
+
core_1.nls.localize('theia/memory-inspector/memory/hideSettings', 'Hide Settings Panel') :
|
|
414
|
+
core_1.nls.localize('theia/memory-inspector/memory/showSettings', 'Show Settings Panel') },
|
|
415
|
+
React.createElement("i", { className: 'codicon codicon-settings-gear' }),
|
|
416
|
+
React.createElement("span", null, this.doDisplaySettings ?
|
|
417
|
+
core_1.nls.localize('theia/memory-inspector/closeSettings', 'Close Settings') :
|
|
418
|
+
core_1.nls.localizeByDefault('Settings'))));
|
|
419
|
+
}
|
|
420
|
+
renderLockIcon() {
|
|
421
|
+
return this.memoryWidgetOptions.dynamic !== false && (React.createElement("div", { className: 'memory-widget-auto-updates-container' },
|
|
422
|
+
React.createElement("div", { className: `fa fa-${this.doUpdateAutomatically ? 'unlock' : 'lock'}`, id: exports.AUTO_UPDATE_TOGGLE_ID, title: this.doUpdateAutomatically ?
|
|
423
|
+
core_1.nls.localize('theia/memory-inspector/memory/freeze', 'Freeze Memory View') :
|
|
424
|
+
core_1.nls.localize('theia/memory-inspector/memory/unfreeze', 'Unfreeze Memory View'), onClick: this.toggleAutoUpdate, onKeyDown: this.toggleAutoUpdate, role: 'button', tabIndex: 0 })));
|
|
425
|
+
}
|
|
426
|
+
renderEditableTitleField() {
|
|
427
|
+
return (React.createElement("div", { className: 'memory-widget-header-click-zone', tabIndex: 0, onClick: this.activateHeaderInputField, onKeyDown: this.activateHeaderInputField, role: 'button' },
|
|
428
|
+
!this.isTitleEditable
|
|
429
|
+
? (React.createElement("h2", { className: `${MemoryOptionsWidget_1.WIDGET_H2_CLASS}${!this.doUpdateAutomatically ? ' disabled' : ''} no-select` }, this.title.label))
|
|
430
|
+
: React.createElement("input", { className: 'theia-input', type: 'text', defaultValue: this.title.label, onKeyDown: this.saveHeaderInputValue, spellCheck: false, ref: this.assignHeaderInputRef }),
|
|
431
|
+
!this.isTitleEditable && (React.createElement("div", { className: `fa fa-pencil${this.showTitleEditIcon ? ' show' : ' hide'}` })),
|
|
432
|
+
this.isTitleEditable && (React.createElement("div", { className: 'fa fa-save', onClick: this.saveHeaderInputValue, onKeyDown: this.saveHeaderInputValue, role: 'button', tabIndex: 0, title: core_1.nls.localizeByDefault('Save') }))));
|
|
433
|
+
}
|
|
434
|
+
storeState() {
|
|
435
|
+
var _a, _b, _c, _d, _e, _f;
|
|
436
|
+
return {
|
|
437
|
+
address: (_b = (_a = this.addressField) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : this.address,
|
|
438
|
+
offset: (_d = parseInt(`${(_c = this.offsetField) === null || _c === void 0 ? void 0 : _c.value}`)) !== null && _d !== void 0 ? _d : this.offset,
|
|
439
|
+
length: (_f = parseInt(`${(_e = this.readLengthField) === null || _e === void 0 ? void 0 : _e.value}`)) !== null && _f !== void 0 ? _f : this.readLength,
|
|
440
|
+
byteSize: this.byteSize,
|
|
441
|
+
bytesPerGroup: this.bytesPerGroup,
|
|
442
|
+
groupsPerRow: this.groupsPerRow,
|
|
443
|
+
endianness: this.endianness,
|
|
444
|
+
doDisplaySettings: this.doDisplaySettings,
|
|
445
|
+
columnsDisplayed: this.columnsDisplayed,
|
|
446
|
+
recentLocationsArray: this.recentLocations.values,
|
|
447
|
+
isFrozen: !this.doUpdateAutomatically,
|
|
448
|
+
doUpdateAutomatically: this.doUpdateAutomatically,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
restoreState(oldState) {
|
|
452
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
453
|
+
this.address = (_a = oldState.address) !== null && _a !== void 0 ? _a : this.address;
|
|
454
|
+
this.offset = (_b = oldState.offset) !== null && _b !== void 0 ? _b : this.offset;
|
|
455
|
+
this.readLength = (_c = oldState.length) !== null && _c !== void 0 ? _c : this.readLength;
|
|
456
|
+
this.byteSize = (_d = oldState.byteSize) !== null && _d !== void 0 ? _d : this.byteSize;
|
|
457
|
+
this.bytesPerGroup = (_e = oldState.bytesPerGroup) !== null && _e !== void 0 ? _e : this.bytesPerGroup;
|
|
458
|
+
this.groupsPerRow = (_f = oldState.groupsPerRow) !== null && _f !== void 0 ? _f : this.groupsPerRow;
|
|
459
|
+
this.endianness = (_g = oldState.endianness) !== null && _g !== void 0 ? _g : this.endianness;
|
|
460
|
+
this.recentLocations = (_h = new memory_recents_1.Recents(oldState.recentLocationsArray)) !== null && _h !== void 0 ? _h : this.recentLocations;
|
|
461
|
+
this.doDisplaySettings = !!oldState.doDisplaySettings;
|
|
462
|
+
if (oldState.columnsDisplayed) {
|
|
463
|
+
this.columnsDisplayed = oldState.columnsDisplayed;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
fetchNewMemory() {
|
|
467
|
+
this.updateMemoryView();
|
|
468
|
+
}
|
|
469
|
+
async doUpdateMemoryView() {
|
|
470
|
+
var _a, _b;
|
|
471
|
+
if (!(this.addressField && this.readLengthField)) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (((_a = this.addressField) === null || _a === void 0 ? void 0 : _a.value.trim().length) === 0) {
|
|
475
|
+
this.memoryReadError = core_1.nls.localize('theia/memory-inspector/memory/addressField/memoryReadError', 'Enter an address or expression in the Location field.');
|
|
476
|
+
this.doShowMemoryErrors();
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (this.readLengthField.value.trim().length === 0) {
|
|
480
|
+
this.memoryReadError = core_1.nls.localize('theia/memory-inspector/memory/readLength/memoryReadError', 'Enter a length (decimal or hexadecimal number) in the Length field.');
|
|
481
|
+
this.doShowMemoryErrors();
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const startAddress = this.addressField.value;
|
|
485
|
+
const locationOffset = parseInt(`${(_b = this.offsetField) === null || _b === void 0 ? void 0 : _b.value}`) || 0;
|
|
486
|
+
const readLength = parseInt(this.readLengthField.value);
|
|
487
|
+
try {
|
|
488
|
+
this.memoryReadResult = await this.getMemory(startAddress, readLength, locationOffset);
|
|
489
|
+
this.fireDidChangeMemory();
|
|
490
|
+
if (this.pinnedMemoryReadResult) {
|
|
491
|
+
this.pinnedMemoryReadResult.resolve(this.memoryReadResult);
|
|
492
|
+
}
|
|
493
|
+
this.doShowMemoryErrors(true);
|
|
494
|
+
}
|
|
495
|
+
catch (err) {
|
|
496
|
+
this.memoryReadError = this.getUserError(err);
|
|
497
|
+
console.error('Failed to read memory', err);
|
|
498
|
+
this.doShowMemoryErrors();
|
|
499
|
+
if (this.pinnedMemoryReadResult) {
|
|
500
|
+
this.pinnedMemoryReadResult.resolve(this.memoryReadResult);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
finally {
|
|
504
|
+
this.pinnedMemoryReadResult = undefined;
|
|
505
|
+
this.update();
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
getUserError(err) {
|
|
509
|
+
return err instanceof Error ? err.message : core_1.nls.localize('theia/memory-inspector/memory/userError', 'There was an error fetching memory.');
|
|
510
|
+
}
|
|
511
|
+
async getMemory(memoryReference, count, offset) {
|
|
512
|
+
const result = await this.retrieveMemory(memoryReference, count, offset);
|
|
513
|
+
try {
|
|
514
|
+
this.variables = await this.memoryProvider.getLocals();
|
|
515
|
+
}
|
|
516
|
+
catch {
|
|
517
|
+
this.variables = [];
|
|
518
|
+
}
|
|
519
|
+
this.recentLocations.add(memoryReference);
|
|
520
|
+
this.updateDefaults(memoryReference, count, offset);
|
|
521
|
+
return result;
|
|
522
|
+
}
|
|
523
|
+
async retrieveMemory(memoryReference, count, offset) {
|
|
524
|
+
return this.memoryProvider.readMemory({ memoryReference, count, offset });
|
|
525
|
+
}
|
|
526
|
+
// TODO: This may not be necessary if we change how state is stored (currently in the text fields themselves.)
|
|
527
|
+
updateDefaults(address, readLength, offset) {
|
|
528
|
+
this.address = address;
|
|
529
|
+
this.readLength = readLength;
|
|
530
|
+
this.offset = offset;
|
|
531
|
+
}
|
|
532
|
+
fireDidChangeOptions(targetId) {
|
|
533
|
+
this.onOptionsChangedEmitter.fire(targetId);
|
|
534
|
+
}
|
|
535
|
+
fireDidChangeMemory() {
|
|
536
|
+
this.onMemoryChangedEmitter.fire(this.memoryReadResult);
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
MemoryOptionsWidget.ID = 'memory-view-options-widget';
|
|
540
|
+
MemoryOptionsWidget.LABEL = core_1.nls.localize('theia/memory-inspector/memoryTitle', 'Memory');
|
|
541
|
+
MemoryOptionsWidget.WIDGET_H2_CLASS = 'memory-widget-header';
|
|
542
|
+
MemoryOptionsWidget.WIDGET_HEADER_INPUT_CLASS = 'memory-widget-header-input';
|
|
543
|
+
__decorate([
|
|
544
|
+
(0, inversify_1.inject)(memory_provider_service_1.MemoryProviderService),
|
|
545
|
+
__metadata("design:type", memory_provider_service_1.MemoryProviderService)
|
|
546
|
+
], MemoryOptionsWidget.prototype, "memoryProvider", void 0);
|
|
547
|
+
__decorate([
|
|
548
|
+
(0, inversify_1.inject)(debug_session_manager_1.DebugSessionManager),
|
|
549
|
+
__metadata("design:type", debug_session_manager_1.DebugSessionManager)
|
|
550
|
+
], MemoryOptionsWidget.prototype, "sessionManager", void 0);
|
|
551
|
+
__decorate([
|
|
552
|
+
(0, inversify_1.inject)(memory_widget_utils_1.MemoryWidgetOptions),
|
|
553
|
+
__metadata("design:type", Object)
|
|
554
|
+
], MemoryOptionsWidget.prototype, "memoryWidgetOptions", void 0);
|
|
555
|
+
__decorate([
|
|
556
|
+
(0, inversify_1.postConstruct)(),
|
|
557
|
+
__metadata("design:type", Function),
|
|
558
|
+
__metadata("design:paramtypes", []),
|
|
559
|
+
__metadata("design:returntype", void 0)
|
|
560
|
+
], MemoryOptionsWidget.prototype, "init", null);
|
|
561
|
+
MemoryOptionsWidget = MemoryOptionsWidget_1 = __decorate([
|
|
562
|
+
(0, inversify_1.injectable)()
|
|
563
|
+
], MemoryOptionsWidget);
|
|
564
|
+
exports.MemoryOptionsWidget = MemoryOptionsWidget;
|
|
565
565
|
//# sourceMappingURL=memory-options-widget.js.map
|