@theia/memory-inspector 1.53.0-next.5 → 1.53.0-next.55
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/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
package/README.md
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
<div align='center'>
|
|
2
|
-
|
|
3
|
-
<br />
|
|
4
|
-
|
|
5
|
-
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
-
|
|
7
|
-
<h2>ECLIPSE THEIA - MEMORY-INSPECTOR EXTENSION</h2>
|
|
8
|
-
|
|
9
|
-
<hr />
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
## Description
|
|
14
|
-
|
|
15
|
-
This extension contributes a set of widgets for viewing memory in different ways.
|
|
16
|
-
|
|
17
|
-
## Requirements
|
|
18
|
-
|
|
19
|
-
This extension must be used in conjunction with a Debug Adapter that implements a `ReadMemoryRequest` handler or alternative custom request that returns memory data.
|
|
20
|
-
It has been tested against the [CDT-GDB Adapter](https://github.com/eclipse-cdt/cdt-gdb-adapter) used as the backend for the
|
|
21
|
-
[CDT-GDB VSCode](https://github.com/eclipse-cdt/cdt-gdb-vscode) plugin. This repository is configured to download that plugin as part of its build routine.
|
|
22
|
-
If you intend to use this extension with a different debug adapter, you may need to implement a custom
|
|
23
|
-
[`MemoryProvider`](./src/browser/memory-provider/memory-provider-service.ts) to handle any peculiarities of the requests and responses used by your adapter.
|
|
24
|
-
|
|
25
|
-
## Widgets
|
|
26
|
-
|
|
27
|
-
### Memory Widget
|
|
28
|
-
|
|
29
|
-
The basic [`MemoryWidget` class](./src/browser/memory-widget/memory-widget.ts) is a wrapper around two functional widgets, a `MemoryOptionsWidget` and
|
|
30
|
-
a`MemoryTableWidget`. The [`MemoryOptionsWidget`](./src/browser/memory-widget/memory-options-widget.tsx) is responsible for configuring the display
|
|
31
|
-
and fetching memory, and the [`MemoryTableWidget`](./src/browser/memory-widget/memory-table-widget.tsx) renders the memory according to the options
|
|
32
|
-
specified by the user in the `MemoryOptionsWidget`. The basic combination of these three classes offers variable highlighting, ascii display, and
|
|
33
|
-
dynamic updating in response to events from the debug session, as well as the option to lock the view to ignore changes from the session.
|
|
34
|
-
|
|
35
|
-
### Diff Widget
|
|
36
|
-
|
|
37
|
-
The [`MemoryDiffWidget`](./src/browser/diff-widget/memory-diff-widget-types.ts) is an elaboration of the `MemoryWidget` type that allows side-by-side
|
|
38
|
-
comparison of the contents of two `MemoryWidgets`.
|
|
39
|
-
|
|
40
|
-
### Register Widget
|
|
41
|
-
|
|
42
|
-
The [`RegisterWidget`](./src/browser/register-widget/register-widget-types.ts) offers functionality to view and
|
|
43
|
-
manipulate those values when using a debug adapter that reports register contents.
|
|
44
|
-
|
|
45
|
-
### Editable Widget
|
|
46
|
-
|
|
47
|
-
The [`MemoryEditableTableWidget`](./src/browser/editable-widget/memory-editable-table-widget.tsx) adds UI functionality to allow users to modify values in
|
|
48
|
-
the table display and send them to a backend that supports that operation.
|
|
49
|
-
|
|
50
|
-
## Using the Widgets
|
|
51
|
-
|
|
52
|
-
The widgets are created by the [`MemoryWidgetManager`](./src/browser/utils/memory-widget-manager.ts), and modifying the `createNewMemoryWidget()`
|
|
53
|
-
method of that service allows you to change what kind of widget is instantiated and under what circumstances. The widgets get memory through the
|
|
54
|
-
[`MemoryProviderService`](./src/browser/memory-provider/memory-provider-service.ts), which delegates to implementations `MemoryProvider` interface
|
|
55
|
-
that are bound as `MemoryProvider` contributions.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## Additional Information
|
|
59
|
-
|
|
60
|
-
- [API documentation for `@theia/getting-started`](https://eclipse-theia.github.io/theia/docs/next/modules/getting_started.html)
|
|
61
|
-
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
62
|
-
- [Theia - Website](https://theia-ide.org/)
|
|
63
|
-
|
|
64
|
-
## License
|
|
65
|
-
|
|
66
|
-
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
67
|
-
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
68
|
-
|
|
69
|
-
## Trademark
|
|
70
|
-
"Theia" is a trademark of the Eclipse Foundation
|
|
71
|
-
https://www.eclipse.org/theia
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - MEMORY-INSPECTOR EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
This extension contributes a set of widgets for viewing memory in different ways.
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
This extension must be used in conjunction with a Debug Adapter that implements a `ReadMemoryRequest` handler or alternative custom request that returns memory data.
|
|
20
|
+
It has been tested against the [CDT-GDB Adapter](https://github.com/eclipse-cdt/cdt-gdb-adapter) used as the backend for the
|
|
21
|
+
[CDT-GDB VSCode](https://github.com/eclipse-cdt/cdt-gdb-vscode) plugin. This repository is configured to download that plugin as part of its build routine.
|
|
22
|
+
If you intend to use this extension with a different debug adapter, you may need to implement a custom
|
|
23
|
+
[`MemoryProvider`](./src/browser/memory-provider/memory-provider-service.ts) to handle any peculiarities of the requests and responses used by your adapter.
|
|
24
|
+
|
|
25
|
+
## Widgets
|
|
26
|
+
|
|
27
|
+
### Memory Widget
|
|
28
|
+
|
|
29
|
+
The basic [`MemoryWidget` class](./src/browser/memory-widget/memory-widget.ts) is a wrapper around two functional widgets, a `MemoryOptionsWidget` and
|
|
30
|
+
a`MemoryTableWidget`. The [`MemoryOptionsWidget`](./src/browser/memory-widget/memory-options-widget.tsx) is responsible for configuring the display
|
|
31
|
+
and fetching memory, and the [`MemoryTableWidget`](./src/browser/memory-widget/memory-table-widget.tsx) renders the memory according to the options
|
|
32
|
+
specified by the user in the `MemoryOptionsWidget`. The basic combination of these three classes offers variable highlighting, ascii display, and
|
|
33
|
+
dynamic updating in response to events from the debug session, as well as the option to lock the view to ignore changes from the session.
|
|
34
|
+
|
|
35
|
+
### Diff Widget
|
|
36
|
+
|
|
37
|
+
The [`MemoryDiffWidget`](./src/browser/diff-widget/memory-diff-widget-types.ts) is an elaboration of the `MemoryWidget` type that allows side-by-side
|
|
38
|
+
comparison of the contents of two `MemoryWidgets`.
|
|
39
|
+
|
|
40
|
+
### Register Widget
|
|
41
|
+
|
|
42
|
+
The [`RegisterWidget`](./src/browser/register-widget/register-widget-types.ts) offers functionality to view and
|
|
43
|
+
manipulate those values when using a debug adapter that reports register contents.
|
|
44
|
+
|
|
45
|
+
### Editable Widget
|
|
46
|
+
|
|
47
|
+
The [`MemoryEditableTableWidget`](./src/browser/editable-widget/memory-editable-table-widget.tsx) adds UI functionality to allow users to modify values in
|
|
48
|
+
the table display and send them to a backend that supports that operation.
|
|
49
|
+
|
|
50
|
+
## Using the Widgets
|
|
51
|
+
|
|
52
|
+
The widgets are created by the [`MemoryWidgetManager`](./src/browser/utils/memory-widget-manager.ts), and modifying the `createNewMemoryWidget()`
|
|
53
|
+
method of that service allows you to change what kind of widget is instantiated and under what circumstances. The widgets get memory through the
|
|
54
|
+
[`MemoryProviderService`](./src/browser/memory-provider/memory-provider-service.ts), which delegates to implementations `MemoryProvider` interface
|
|
55
|
+
that are bound as `MemoryProvider` contributions.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## Additional Information
|
|
59
|
+
|
|
60
|
+
- [API documentation for `@theia/getting-started`](https://eclipse-theia.github.io/theia/docs/next/modules/getting_started.html)
|
|
61
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
62
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
67
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
68
|
+
|
|
69
|
+
## Trademark
|
|
70
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
71
|
+
https://www.eclipse.org/theia
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/memory-inspector",
|
|
3
|
-
"version": "1.53.0-next.
|
|
3
|
+
"version": "1.53.0-next.55+d1a989a68c",
|
|
4
4
|
"description": "Theia - Memory Inspector",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theia-extension"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"watch": "theiaext watch"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@theia/core": "1.53.0-next.
|
|
31
|
-
"@theia/debug": "1.53.0-next.
|
|
30
|
+
"@theia/core": "1.53.0-next.55+d1a989a68c",
|
|
31
|
+
"@theia/debug": "1.53.0-next.55+d1a989a68c",
|
|
32
32
|
"@vscode/debugprotocol": "^1.51.0",
|
|
33
33
|
"long": "^4.0.0",
|
|
34
34
|
"tslib": "^2.6.2"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "d1a989a68c1b5ec1f9098e9126653c6346844769"
|
|
48
48
|
}
|
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (C) 2021 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 { Key, KeyCode } from '@theia/core/lib/browser';
|
|
18
|
-
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
19
|
-
import * as React from '@theia/core/shared/react';
|
|
20
|
-
import { ThemeType } from '@theia/core/lib/common/theme';
|
|
21
|
-
import { LENGTH_FIELD_ID, LOCATION_OFFSET_FIELD_ID, MemoryOptionsWidget } from '../memory-widget/memory-options-widget';
|
|
22
|
-
import { MWInput } from '../utils/memory-widget-components';
|
|
23
|
-
import { Interfaces, MemoryDiffWidgetData, Utils } from '../utils/memory-widget-utils';
|
|
24
|
-
import { DiffLabels } from './memory-diff-widget-types';
|
|
25
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
26
|
-
|
|
27
|
-
export interface DiffMemoryOptions extends Interfaces.MemoryOptions {
|
|
28
|
-
beforeOffset: number;
|
|
29
|
-
afterOffset: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@injectable()
|
|
33
|
-
export class MemoryDiffOptionsWidget extends MemoryOptionsWidget {
|
|
34
|
-
@inject(MemoryDiffWidgetData) protected override memoryWidgetOptions: MemoryDiffWidgetData;
|
|
35
|
-
|
|
36
|
-
protected themeType: ThemeType;
|
|
37
|
-
|
|
38
|
-
override get options(): DiffMemoryOptions {
|
|
39
|
-
return this.storeState();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
updateDiffData(newDiffData: Partial<MemoryDiffWidgetData>): void {
|
|
43
|
-
this.memoryWidgetOptions = { ...this.memoryWidgetOptions, ...newDiffData };
|
|
44
|
-
this.init();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@postConstruct()
|
|
48
|
-
protected override init(): void {
|
|
49
|
-
this.addClass(MemoryOptionsWidget.ID);
|
|
50
|
-
this.addClass('diff-options-widget');
|
|
51
|
-
const { identifier, beforeBytes, afterBytes } = this.memoryWidgetOptions;
|
|
52
|
-
|
|
53
|
-
this.id = `${MemoryDiffOptionsWidget.ID}-${identifier}`;
|
|
54
|
-
this.title.label = nls.localize('theia/memory-inspector/diff/label', 'Diff: {0}', identifier);
|
|
55
|
-
this.title.caption = this.title.label;
|
|
56
|
-
this.title.iconClass = this.iconClass;
|
|
57
|
-
this.title.closable = true;
|
|
58
|
-
|
|
59
|
-
this.toDispose.push(this.onOptionsChanged(() => this.update()));
|
|
60
|
-
|
|
61
|
-
beforeBytes.label = DiffLabels.Before;
|
|
62
|
-
afterBytes.label = DiffLabels.After;
|
|
63
|
-
|
|
64
|
-
this.columnsDisplayed = {
|
|
65
|
-
beforeAddress: {
|
|
66
|
-
label: nls.localizeByDefault('Address'),
|
|
67
|
-
doRender: true
|
|
68
|
-
},
|
|
69
|
-
beforeData: {
|
|
70
|
-
label: this.memoryWidgetOptions.titles[0],
|
|
71
|
-
doRender: true
|
|
72
|
-
},
|
|
73
|
-
afterAddress: {
|
|
74
|
-
label: nls.localizeByDefault('Address'),
|
|
75
|
-
doRender: true
|
|
76
|
-
},
|
|
77
|
-
afterData: {
|
|
78
|
-
label: this.memoryWidgetOptions.titles[1],
|
|
79
|
-
doRender: true
|
|
80
|
-
},
|
|
81
|
-
variables: {
|
|
82
|
-
label: nls.localizeByDefault('Variables'),
|
|
83
|
-
doRender: false
|
|
84
|
-
},
|
|
85
|
-
ascii: {
|
|
86
|
-
label: nls.localize('theia/memory-inspector/ascii', 'ASCII'),
|
|
87
|
-
doRender: false
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
this.update();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
protected override acceptFocus(): void {
|
|
95
|
-
const settingsCog = this.node.querySelector('.toggle-settings-click-zone') as HTMLDivElement;
|
|
96
|
-
settingsCog?.focus();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
protected override renderMemoryLocationGroup(): React.ReactNode {
|
|
100
|
-
const { titles: [beforeTitle, afterTitle] } = this.memoryWidgetOptions;
|
|
101
|
-
return (
|
|
102
|
-
<div className='t-mv-group view-group'>
|
|
103
|
-
<MWInput
|
|
104
|
-
id={LOCATION_OFFSET_FIELD_ID}
|
|
105
|
-
label={nls.localize('theia/memory-inspector/diff-widget/offset-label', '{0} Offset', beforeTitle)}
|
|
106
|
-
title={nls.localize('theia/memory-inspector/diff-widget/offset-title', 'Bytes to offset the memory from {0}', beforeTitle)}
|
|
107
|
-
defaultValue='0'
|
|
108
|
-
passRef={this.assignOffsetRef}
|
|
109
|
-
onChange={Utils.validateNumericalInputs}
|
|
110
|
-
onKeyDown={this.doRefresh}
|
|
111
|
-
/>
|
|
112
|
-
<MWInput
|
|
113
|
-
id={LENGTH_FIELD_ID}
|
|
114
|
-
label={nls.localize('theia/memory-inspector/diff-widget/offset-label', '{0} Offset', afterTitle)}
|
|
115
|
-
title={nls.localize('theia/memory-inspector/diff-widget/offset-title', 'Bytes to offset the memory from {0}', afterTitle)}
|
|
116
|
-
defaultValue='0'
|
|
117
|
-
passRef={this.assignReadLengthRef}
|
|
118
|
-
onChange={Utils.validateNumericalInputs}
|
|
119
|
-
onKeyDown={this.doRefresh}
|
|
120
|
-
/>
|
|
121
|
-
<button
|
|
122
|
-
type='button'
|
|
123
|
-
className='theia-button main view-group-go-button'
|
|
124
|
-
title={nls.localizeByDefault('Go')}
|
|
125
|
-
onClick={this.doRefresh}
|
|
126
|
-
>
|
|
127
|
-
{nls.localizeByDefault('Go')}
|
|
128
|
-
</button>
|
|
129
|
-
</div>
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
protected override getObligatoryColumnIds(): string[] {
|
|
134
|
-
return ['beforeAddress', 'beforeData', 'afterAddress', 'afterData'];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
protected override doRefresh = (event: React.KeyboardEvent<HTMLInputElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>): void => {
|
|
138
|
-
if ('key' in event && KeyCode.createKeyCode(event.nativeEvent).key?.keyCode !== Key.ENTER.keyCode) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
this.fireDidChangeOptions();
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
override storeState(): DiffMemoryOptions {
|
|
145
|
-
return {
|
|
146
|
-
...super.storeState(),
|
|
147
|
-
// prefix a 0. It'll do nothing if it's a number, but if it's an empty string or garbage, it'll make parseInt return 0.
|
|
148
|
-
beforeOffset: parseInt(`0${this.offsetField?.value ?? 0}`),
|
|
149
|
-
afterOffset: parseInt(`0${this.readLengthField?.value ?? 0}`),
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2021 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 { Key, KeyCode } from '@theia/core/lib/browser';
|
|
18
|
+
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
19
|
+
import * as React from '@theia/core/shared/react';
|
|
20
|
+
import { ThemeType } from '@theia/core/lib/common/theme';
|
|
21
|
+
import { LENGTH_FIELD_ID, LOCATION_OFFSET_FIELD_ID, MemoryOptionsWidget } from '../memory-widget/memory-options-widget';
|
|
22
|
+
import { MWInput } from '../utils/memory-widget-components';
|
|
23
|
+
import { Interfaces, MemoryDiffWidgetData, Utils } from '../utils/memory-widget-utils';
|
|
24
|
+
import { DiffLabels } from './memory-diff-widget-types';
|
|
25
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
26
|
+
|
|
27
|
+
export interface DiffMemoryOptions extends Interfaces.MemoryOptions {
|
|
28
|
+
beforeOffset: number;
|
|
29
|
+
afterOffset: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@injectable()
|
|
33
|
+
export class MemoryDiffOptionsWidget extends MemoryOptionsWidget {
|
|
34
|
+
@inject(MemoryDiffWidgetData) protected override memoryWidgetOptions: MemoryDiffWidgetData;
|
|
35
|
+
|
|
36
|
+
protected themeType: ThemeType;
|
|
37
|
+
|
|
38
|
+
override get options(): DiffMemoryOptions {
|
|
39
|
+
return this.storeState();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
updateDiffData(newDiffData: Partial<MemoryDiffWidgetData>): void {
|
|
43
|
+
this.memoryWidgetOptions = { ...this.memoryWidgetOptions, ...newDiffData };
|
|
44
|
+
this.init();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@postConstruct()
|
|
48
|
+
protected override init(): void {
|
|
49
|
+
this.addClass(MemoryOptionsWidget.ID);
|
|
50
|
+
this.addClass('diff-options-widget');
|
|
51
|
+
const { identifier, beforeBytes, afterBytes } = this.memoryWidgetOptions;
|
|
52
|
+
|
|
53
|
+
this.id = `${MemoryDiffOptionsWidget.ID}-${identifier}`;
|
|
54
|
+
this.title.label = nls.localize('theia/memory-inspector/diff/label', 'Diff: {0}', identifier);
|
|
55
|
+
this.title.caption = this.title.label;
|
|
56
|
+
this.title.iconClass = this.iconClass;
|
|
57
|
+
this.title.closable = true;
|
|
58
|
+
|
|
59
|
+
this.toDispose.push(this.onOptionsChanged(() => this.update()));
|
|
60
|
+
|
|
61
|
+
beforeBytes.label = DiffLabels.Before;
|
|
62
|
+
afterBytes.label = DiffLabels.After;
|
|
63
|
+
|
|
64
|
+
this.columnsDisplayed = {
|
|
65
|
+
beforeAddress: {
|
|
66
|
+
label: nls.localizeByDefault('Address'),
|
|
67
|
+
doRender: true
|
|
68
|
+
},
|
|
69
|
+
beforeData: {
|
|
70
|
+
label: this.memoryWidgetOptions.titles[0],
|
|
71
|
+
doRender: true
|
|
72
|
+
},
|
|
73
|
+
afterAddress: {
|
|
74
|
+
label: nls.localizeByDefault('Address'),
|
|
75
|
+
doRender: true
|
|
76
|
+
},
|
|
77
|
+
afterData: {
|
|
78
|
+
label: this.memoryWidgetOptions.titles[1],
|
|
79
|
+
doRender: true
|
|
80
|
+
},
|
|
81
|
+
variables: {
|
|
82
|
+
label: nls.localizeByDefault('Variables'),
|
|
83
|
+
doRender: false
|
|
84
|
+
},
|
|
85
|
+
ascii: {
|
|
86
|
+
label: nls.localize('theia/memory-inspector/ascii', 'ASCII'),
|
|
87
|
+
doRender: false
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
this.update();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
protected override acceptFocus(): void {
|
|
95
|
+
const settingsCog = this.node.querySelector('.toggle-settings-click-zone') as HTMLDivElement;
|
|
96
|
+
settingsCog?.focus();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
protected override renderMemoryLocationGroup(): React.ReactNode {
|
|
100
|
+
const { titles: [beforeTitle, afterTitle] } = this.memoryWidgetOptions;
|
|
101
|
+
return (
|
|
102
|
+
<div className='t-mv-group view-group'>
|
|
103
|
+
<MWInput
|
|
104
|
+
id={LOCATION_OFFSET_FIELD_ID}
|
|
105
|
+
label={nls.localize('theia/memory-inspector/diff-widget/offset-label', '{0} Offset', beforeTitle)}
|
|
106
|
+
title={nls.localize('theia/memory-inspector/diff-widget/offset-title', 'Bytes to offset the memory from {0}', beforeTitle)}
|
|
107
|
+
defaultValue='0'
|
|
108
|
+
passRef={this.assignOffsetRef}
|
|
109
|
+
onChange={Utils.validateNumericalInputs}
|
|
110
|
+
onKeyDown={this.doRefresh}
|
|
111
|
+
/>
|
|
112
|
+
<MWInput
|
|
113
|
+
id={LENGTH_FIELD_ID}
|
|
114
|
+
label={nls.localize('theia/memory-inspector/diff-widget/offset-label', '{0} Offset', afterTitle)}
|
|
115
|
+
title={nls.localize('theia/memory-inspector/diff-widget/offset-title', 'Bytes to offset the memory from {0}', afterTitle)}
|
|
116
|
+
defaultValue='0'
|
|
117
|
+
passRef={this.assignReadLengthRef}
|
|
118
|
+
onChange={Utils.validateNumericalInputs}
|
|
119
|
+
onKeyDown={this.doRefresh}
|
|
120
|
+
/>
|
|
121
|
+
<button
|
|
122
|
+
type='button'
|
|
123
|
+
className='theia-button main view-group-go-button'
|
|
124
|
+
title={nls.localizeByDefault('Go')}
|
|
125
|
+
onClick={this.doRefresh}
|
|
126
|
+
>
|
|
127
|
+
{nls.localizeByDefault('Go')}
|
|
128
|
+
</button>
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
protected override getObligatoryColumnIds(): string[] {
|
|
134
|
+
return ['beforeAddress', 'beforeData', 'afterAddress', 'afterData'];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected override doRefresh = (event: React.KeyboardEvent<HTMLInputElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>): void => {
|
|
138
|
+
if ('key' in event && KeyCode.createKeyCode(event.nativeEvent).key?.keyCode !== Key.ENTER.keyCode) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.fireDidChangeOptions();
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
override storeState(): DiffMemoryOptions {
|
|
145
|
+
return {
|
|
146
|
+
...super.storeState(),
|
|
147
|
+
// prefix a 0. It'll do nothing if it's a number, but if it's an empty string or garbage, it'll make parseInt return 0.
|
|
148
|
+
beforeOffset: parseInt(`0${this.offsetField?.value ?? 0}`),
|
|
149
|
+
afterOffset: parseInt(`0${this.readLengthField?.value ?? 0}`),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|