Skip to content

Add Show in Memory Inspector entry to Watch view context menu#166

Open
xoriath wants to merge 1 commit into
eclipse-cdt-cloud:mainfrom
xoriath:feature/issue-165-watch-context-menu
Open

Add Show in Memory Inspector entry to Watch view context menu#166
xoriath wants to merge 1 commit into
eclipse-cdt-cloud:mainfrom
xoriath:feature/issue-165-watch-context-menu

Conversation

@xoriath
Copy link
Copy Markdown

@xoriath xoriath commented Apr 24, 2026

What it does

Mirror the debug/variables/context menu entries under debug/watch/context in package.json so show-variable, go-to-value and store-file are offered on watch items when the debug adapter supports reading memory.

How to test

Simply add a a watch variable and right click; should behave identical to the variables view

Review checklist

Reminder for reviewers

Fixes: #165

@jreineckearm jreineckearm self-requested a review April 24, 2026 16:44
Copy link
Copy Markdown
Contributor

@jreineckearm jreineckearm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xoriath , thanks a lot again for your contribution! And apologies for taking a bit more time with the initial review. See some comments. I haven't tried building yet due to the comments around the yarn hash and base URLs in package.json.

Will do some local modifications later to test the functionality while waiting for responses.

Comment thread src/common/external-views.spec.ts Outdated
Comment thread src/common/external-views.ts Outdated
Comment thread src/plugin/memory-webview-main.ts
Comment thread package.json Outdated
Comment thread yarn.lock Outdated
Comment thread package.json Outdated
@xoriath xoriath force-pushed the feature/issue-165-watch-context-menu branch 5 times, most recently from 1678772 to 29201f3 Compare April 29, 2026 12:59
@xoriath
Copy link
Copy Markdown
Author

xoriath commented Apr 29, 2026

@xoriath , thanks a lot again for your contribution! And apologies for taking a bit more time with the initial review. See some comments. I haven't tried building yet due to the comments around the yarn hash and base URLs in package.json.

Will do some local modifications later to test the functionality while waiting for responses.

Think I got all your points done :)

Sorry for the corepack change; I have it turned on in my system so I just glance over it when I see it being added to package.json these days :)

Copy link
Copy Markdown
Contributor

@jreineckearm jreineckearm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @xoriath, for the swift updates! Much appreciated.

Good to go with what looks like new prettier changes in src/common/debug-requests.ts.
And various new dependency updates in yarn.lock.

My only remaining question before I build and try is whether to keep the "packageManager" entry. It sounded like you were planning to remove. Which I'd support.

@xoriath
Copy link
Copy Markdown
Author

xoriath commented Apr 29, 2026

.. it snuck in AGAIN!

Yes the debug-requests should just be prettier changing a bit ... I lost the fight against prettier a long time ago :)

@xoriath xoriath force-pushed the feature/issue-165-watch-context-menu branch from 29201f3 to c23265c Compare April 29, 2026 13:57
Copy link
Copy Markdown
Contributor

@jreineckearm jreineckearm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks, @xoriath !

May I also ask if you tested the changes interactively? If so, which Debug Adapter did you use? I am using a solution that builds on gdbtarget type. But if I add it, I don't see the entries in the Watch window context menus.

@xoriath
Copy link
Copy Markdown
Author

xoriath commented Apr 29, 2026

I tested it on the mplab-core-da adapter... However we should not key of anything that is debug adapter specific... do you use an older vscode? (it's a fairly new contributes segment)

@jreineckearm
Copy link
Copy Markdown
Contributor

I see for mplab-core-da the setting mplab.coreDebugger.registerWithEclipseCdtCloudMemoryInspector.
And the following release notes:

[0.12.0] - 2024-11
Added
Memory View: Support for [Eclipse CDT Memory Inspector extension](https://marketplace.visualstudio.com/items?itemName=eclipse-cdt.memory-inspector)

Do you register AdapterCapabilities through the Memory Inspector extension API? This maybe provides functionality that enables watch expressions for the Memory Inspector contexts that get checked in package.json.

@xoriath
Copy link
Copy Markdown
Author

xoriath commented Apr 29, 2026

nothing more than declaring us as a DA , rest is normal memoryRead/memoryWrite capabilities in DAP ... let me check when I get into the office tomorrow with another debug adapter and see what's falling apart there

@jreineckearm
Copy link
Copy Markdown
Contributor

Awesome, thanks!
I am positive some more work is needed here for the more "standard" use cases like gdbtarget. Which may need to go into a separate PR if it currently works for your adapter. Need to understand first though what it is except from adding gdbtarget (which is an Eclipse CDT Cloud adapter) here:

export const DEFAULT_DEBUG_TYPES = ['gdb', 'embedded-debug', 'arm-debugger'];

@xoriath
Copy link
Copy Markdown
Author

xoriath commented Apr 29, 2026

So the debug adapter needs to provider 2 supports messages in the capability exchange.

However; just to get bearings; do you have the option to watch in the variables view? If you don't then I think we're on solid ground; i.e gdbtarget does not announce memory access at all ? If you see it in variables but not in watch... then ... then I've borked something royally :)

@jreineckearm
Copy link
Copy Markdown
Contributor

These are the capabilities for gdb and gdbtarget: https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter/blob/daf5f75b15acda22dc5f651cf04d17db91b885fb/src/gdb/GDBDebugSessionBase.ts#L407
this.isRemote means gdbtarget only. I think it got to do with the collection and analysis of variables here:

async getLocals(session: vscode.DebugSession): Promise<VariableRange[]> {

Where this.variablesTree gets filled here by a debug tracker here:
onDidSendMessage(message: unknown): void {

That is only looking out for scopes and variables requests.

IIRC, that part is also used to determine the memory-inspector.variable.isPointer context. But the watch window uses evaluate requests, at least on the parent expression level. Having said all of this, it's been a while, so I'd need to get my head back into the specifics to give further guidance. 😞

VS Code 1.103 introduced the debug/watch/context menu extension point (microsoft/vscode#237751), which lets extensions contribute actions to the Watch view context menu. The Watch view passes the IExpression instance directly as the command argument instead of the wrapped {sessionId, container, variable} shape used by the Variables view, so a separate type guard is required.

- Add WatchView.IWatchItemContext type and isWatchItemContext guard in src/common/external-views.ts.

- Teach the show-variable and go-to-value command handlers in memory-webview-main.ts to accept the Watch view argument shape, resolving the memory reference from memoryReference (always populated when canViewMemory is true) with a fallback to getAddressOfVariable(evaluateName ?? name).

- Mirror the debug/variables/context menu entries under debug/watch/context in package.json so show-variable, go-to-value and store-file are offered on watch items when the debug adapter supports reading memory.

- Wire up mocha + ts-node + chai test infrastructure and add unit tests for isVariablesContext and isWatchItemContext covering wrapper contexts, root/child watch expressions, primitives and discrimination between the two shapes.

Fixes: eclipse-cdt-cloud#165

Signed-off-by: Morten Engelhardt Olsen <MortenEngelhardt.Olsen@microchip.com>
@xoriath xoriath force-pushed the feature/issue-165-watch-context-menu branch from c23265c to c2379b4 Compare April 30, 2026 05:18
@xoriath
Copy link
Copy Markdown
Author

xoriath commented Apr 30, 2026

Alright so with our (normal) debug adapter and cortex-debug (we're and embedded shop so what I have handy :)):
image

Works straight out of the box... And I can't see anything special happening between the debug adapter and the memory-inspector... it's entirely feature/capability based...

@jreineckearm
Copy link
Copy Markdown
Contributor

OK, thanks for double-checking. Will give it another try then to see if I did something wrong when I set up my test environment.

@jreineckearm
Copy link
Copy Markdown
Contributor

Still no joy with making it work with the VSIX build from CI. I'll see if can debug into it next week. Got a public holiday tomorrow. Have a good weekend!

@xoriath
Copy link
Copy Markdown
Author

xoriath commented Apr 30, 2026

Same here! Have a great weekend!

@jreineckearm
Copy link
Copy Markdown
Contributor

Sorry, haven't forgotten about this. But super-busy this week. And now on holiday until 18.05. 🙁
@omarArm , I know you are super busy next week. But maybe you can give it a try when you are done with other tasks early.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Show in Memory Inspector" context menu entry for Watch window

2 participants