eclipse-cdt-cloud / vscode-memory-inspector

vscode memory inspector
https://open-vsx.org/extension/eclipse-cdt/memory-inspector
Eclipse Public License 2.0
6 stars 10 forks source link

Enhances the context data of the context menu #135

Closed planger closed 3 months ago

planger commented 4 months ago

What it does

Extends the VS Code context to augment the information available to context menus. In particular:

How to test

The easiest way to test this is to print out the arguments of a context menu command, e.g. in memory-webview-main.ts:112:

vscode.commands.registerCommand(MemoryWebview.ToggleRadixPrefixCommandType, (ctx: WebviewContext) => {
        console.log('args', ctx);
        this.setMemoryViewSettings(ctx.messageParticipant, { showRadixPrefix: !ctx.showRadixPrefix });
}),

And observe the data in the ctx object. Here is a break down of what it currently contains.

Context menu somewhere in the upper part of the memory inspector (now contains `endianness` and `bytesPerMau`) ```json { "messageParticipant": { "type": "webview", "webviewId": "memory-inspector.memory_2" }, "showRadixPrefix": true, "showAsciiColumn": false, "showVariablesColumn": true, "endianness": "Little Endian", "bytesPerMau": 1, "activeReadArguments": { "memoryReference": "0x20001c2c", "offset": 0, "count": 256 }, "webviewSection": "optionsWidget", "preventDefaultContextMenuItems": true, "memory-inspector.messageParticipant.type": "webview", "memory-inspector.messageParticipant.webviewId": "memory-inspector.memory_2", "memory-inspector.showRadixPrefix": true, "memory-inspector.showAsciiColumn": false, "memory-inspector.showVariablesColumn": true, "memory-inspector.endianness": "Little Endian", "memory-inspector.bytesPerMau": 1, "memory-inspector.activeReadArguments.memoryReference": "0x20001c2c", "memory-inspector.activeReadArguments.offset": 0, "memory-inspector.activeReadArguments.count": 256, "memory-inspector.webviewSection": "optionsWidget", "memory-inspector.preventDefaultContextMenuItems": true, "webview": "memory-inspector.memory" } ```
Context menu on a specific group in the memory data (now contains start and size of the group) ```json { "messageParticipant": { "type": "webview", "webviewId": "memory-inspector.memory_2" }, "showRadixPrefix": false, "showAsciiColumn": false, "showVariablesColumn": true, "endianness": "Little Endian", "bytesPerMau": 2, "activeReadArguments": { "memoryReference": "0x20001c2c", "offset": 0, "count": 256 }, "webviewSection": "memoryTable", "preventDefaultContextMenuItems": true, "memory-inspector.messageParticipant.type": "webview", "memory-inspector.messageParticipant.webviewId": "memory-inspector.memory_2", "memory-inspector.showRadixPrefix": false, "memory-inspector.showAsciiColumn": false, "memory-inspector.showVariablesColumn": true, "memory-inspector.endianness": "Little Endian", "memory-inspector.bytesPerMau": 2, "memory-inspector.activeReadArguments.memoryReference": "0x20001c2c", "memory-inspector.activeReadArguments.offset": 0, "memory-inspector.activeReadArguments.count": 256, "memory-inspector.webviewSection": "memoryTable", "memory-inspector.preventDefaultContextMenuItems": true, "column": "data", "memory-inspector.column": "data", "value": "000000000000aa810000000020001c90", "memoryData": { "group": { "startAddress": "0x20001c2c", "length": 4 } }, "memory-inspector.memoryData.group.startAddress": "0x20001c2c", "memory-inspector.memoryData.group.length": 4, "webview": "memory-inspector.memory" } ```
Context menu on a specific variable (already contained this information before this PR) ```json { "messageParticipant": { "type": "webview", "webviewId": "memory-inspector.memory_2" }, "showRadixPrefix": true, "showAsciiColumn": false, "showVariablesColumn": true, "endianness": "Little Endian", "bytesPerMau": 2, "activeReadArguments": { "memoryReference": "0x20001c2c", "offset": 0, "count": 256 }, "webviewSection": "memoryTable", "preventDefaultContextMenuItems": true, "memory-inspector.messageParticipant.type": "webview", "memory-inspector.messageParticipant.webviewId": "memory-inspector.memory_2", "memory-inspector.showRadixPrefix": true, "memory-inspector.showAsciiColumn": false, "memory-inspector.showVariablesColumn": true, "memory-inspector.endianness": "Little Endian", "memory-inspector.bytesPerMau": 2, "memory-inspector.activeReadArguments.memoryReference": "0x20001c2c", "memory-inspector.activeReadArguments.offset": 0, "memory-inspector.activeReadArguments.count": 256, "memory-inspector.webviewSection": "memoryTable", "memory-inspector.preventDefaultContextMenuItems": true, "column": "variables", "memory-inspector.column": "variables", "value": "arg", "variable": { "name": "arg", "type": "void*", "value": "(void*) 0x0", "isPointer": true }, "memory-inspector.variable.name": "arg", "memory-inspector.variable.type": "void*", "memory-inspector.variable.value": "(void*) 0x0", "memory-inspector.variable.isPointer": true, "webview": "memory-inspector.memory" } ```

Review checklist

Reminder for reviewers

colin-grant-work commented 4 months ago

Not opposed to the change, but at the moment, it doesn't look like there's a consumer for the new data?

planger commented 4 months ago

@colin-grant-work Wow that fast! I wasn't even finished updating the comment yet :-)

Not opposed to the change, but at the moment, it doesn't look like there's a consumer for the new data?

The requirement is to prepare for external context menus that would need this context information (e.g. to properly react to context menu on a specific memory data group). A context menu item that'll likely come soon is to add data breakpoints, which also needs the start and end address of a selected group.

But I'll better let @jreineckearm give the full picture on the future requirements that necessitate this change.

colin-grant-work commented 4 months ago

I think I mistook a repo watch generated email for a review request email - sorry!

planger commented 3 months ago

@haydar-metin confirmed that what is specified in this PR is sufficient to be used and extended for #102. So we consider this to be ready for final review. Thank you!

planger commented 3 months ago

Thank you both @colin-grant-work and @jreineckearm for your review!