Repository navigation
Add support for snapshots in "Run And Debug" view. - #38
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Defer approval because the new SimUtils snapshot protocol and stateful history behavior require runtime validation against supported Simics TCF agents, including resume ordering and undo/redo races not covered by the repository’s fakes.
No open issues 🎉
What changed in this PR
Adds Simics snapshot management and step-history undo/redo support to the Run and Debug experience. The PR also migrates the launch-settings webview to React and updates the build/type-check configuration.
Changes:
- Adds SimUtils snapshot commands, DAP requests, automatic step/run history, and undo/redo behavior.
- Adds the Snapshots tree view, commands, menus, settings, documentation, and changelog entries.
- Replaces the legacy launch-settings webview with a React implementation and updates bundling.
| File | Description |
|---|---|
| tsconfig.json | Excludes the browser React webview from the main TypeScript project. |
| src/webview/launchSettings/vscode.ts | Provides VS Code webview messaging and persisted-state helpers. |
| src/webview/launchSettings/styles.css | Removes styles for controls no longer used by the migrated form. |
| src/webview/launchSettings/index.tsx | Adds the React entry point for launch settings. |
| src/webview/launchSettings/components/controls.tsx | Implements reusable React launch-configuration controls. |
| src/webview/launchSettings/App.tsx | Implements the React launch-configuration editor. |
| src/test/snapshots.test.ts | Adds coverage for snapshot operations and step-history behavior. |
| src/test/schema.test.ts | Updates schema tests after removing legacy webview field features. |
| src/tcfDebugSession.ts | Integrates snapshot services, custom requests, and automatic history capture with stepping and running. |
| src/tcf/services/simUtils.ts | Adds the SimUtils TCF service wrapper for snapshot commands and events. |
| src/snapshotsView.ts | Implements the Snapshots tree view and associated commands. |
| src/snapshots.ts | Implements snapshot state management, naming, retention, and undo/redo logic. |
| src/settings.ts | Maps step-history settings into debug-session arguments. |
| src/launchSettings/webview/tsconfig.json | Removes the obsolete legacy webview TypeScript configuration. |
| src/launchSettings/webview/launchSettings.ts | Removes the legacy launch-settings DOM implementation. |
| src/launchSettings/webview/controls.ts | Removes the legacy launch-settings control implementation. |
| src/launchSettings/schema.ts | Simplifies schema field kinds for the new form implementation. |
| src/extension.ts | Registers the Snapshots view during extension activation. |
| README.md | Documents snapshot commands, step history, settings, and architecture. |
| package.json | Registers the Snapshots view, commands, menus, settings, and updated type-check script. |
| esbuild.mjs | Builds the new React launch-settings webview entry point. |
| CHANGELOG.md | Records the new snapshot and step-history features. |
Review effort: Lite
| ## Source layout | ||
|
|
||
| - `src/extension.ts` – VS Code entry point, registers the `simics-target-debug` | ||
| debug type. | ||
| - `src/tcfDebugSession.ts` – DAP implementation (no `vscode` dependency, so it | ||
| can also be run as a standalone debug adapter later). | ||
| - `src/contextSession.ts` – adapter of the child sessions that show the | ||
| threads of a container context; passes requests on to the root session's | ||
| adapter. | ||
| - `src/contextSessionManager.ts` – starts the child sessions in VS Code and | ||
| maps them to their root session for the extension's views and commands. | ||
| - `src/breakpointManager.ts` – keeps the agent's breakpoint table in sync with | ||
| VS Code. | ||
| - `src/variables.ts` – local variables and expressions through the | ||
| `Expressions` and `Symbols` services. | ||
| - `src/pathMapper.ts` – path mapping between compiled and host paths. | ||
| - `src/symbolFiles.ts` – symbol files from the debug configuration, sent to | ||
| the agent's memory map. | ||
| - `src/targetMemory/` – Target Memory panels and commands (extension side). | ||
| - `src/webview/targetMemory/` – Target Memory UI (React), bundled to | ||
| `out/target-memory.{js,css}`. | ||
| - `src/shared/targetMemory/` – code shared by the Target Memory extension | ||
| side, webview and debug adapter: messages, formatting, search needles and | ||
| the memory search. | ||
| - `src/tcfRequests.ts` – custom DAP requests used by the Target Memory view. | ||
| - `src/simicsConsole.ts` – the Simics console: keys to `CommandLine` key | ||
| presses, events to VT text (no `vscode` dependency). | ||
| - `src/simicsConsoleManager.ts` – the Simics CLI terminals and their commands. | ||
| - `src/consolesView.ts` – the Consoles view. | ||
| - `src/snapshots.ts` – Simics snapshots in the adapter, and the custom | ||
| requests of the Snapshots view (no `vscode` dependency). | ||
| - `src/snapshotsView.ts` – the Snapshots view and its commands. | ||
| - `src/launchSettings/` – the TCF Launch Configurations editor: reading and editing | ||
| `launch.json` (`launchJson.ts`), form fields from `package.json` | ||
| (`schema.ts`), the custom editor (`editorProvider.ts`) and the form in its | ||
| webview (`webview/`). | ||
| - `src/tcf/channel.ts` – TCF TCP channel: framing, escaping, tokens, events. | ||
| - `src/tcf/json.ts` – JSON parsing that keeps 64-bit integers exact (`bigint`). | ||
| - `src/tcf/services/` – typed wrappers for TCF services. | ||
| - `src/test/` – unit tests (`node:test`), they need no TCF agent. |
There was a problem hiding this comment.
I suggest we should remove this from the README since it's not very useful for a human. It's easier to just ask the agent to summarize the code structure (and easier to keep that up to date) and ask it what goes where.
If we want it for agents (to give them a cheap/fast context of the source code), then we could move it to a copilot instruction (or similar). But honestly, I'm not sure it's needed - the agents are so good/cheap to run nowadays.
There was a problem hiding this comment.
I agree, can be done in a separate patch.
|
Looks like you need to rebase your PR. Two of the commits in your PR have already been merged to main |
| - Undo Step and Redo Step in the Snapshots view: with the setting | ||
| `simics-target-debug.stepHistory.size`, a snapshot is taken before each | ||
| step and continue, to go back and forward through. Off by default. | ||
| Recording can be paused for a session, and the step snapshots cleared | ||
| without deleting the others. `simics-target-debug.stepHistory.includeRuns` | ||
| leaves continues out. |
There was a problem hiding this comment.
I would think it's useful if this was controllable per debug session (but the default can be in the settings). Can we perhaps add a toggle button for it in the debug pane?
There was a problem hiding this comment.
Yes, probably, this depends a bit on target as discussed below. Some targets support snapshotting better than others. I think I'll back out the step-undo and maybe re-add it later when it's been though thru.
| "type": "integer", | ||
| "order": 1, | ||
| "minimum": 0, | ||
| "maximum": 100, |
There was a problem hiding this comment.
Why not always have this enabled? I guess it takes a lot of space? If so, how does a user know how "large" they should set the step history to? Why is 100 the max?
There was a problem hiding this comment.
Great questions (as AI would say). For why it's partly because it consumes a lot of memory, but also that platforms don't always support snapshotting perfectly (lots of logs etc when restoring snapshots). It can be considered a bit experimental.
The question about what is a good value is interesting and should be documented, suggested somehow. I have used 5 myself when testing. But larger "undo-buffer" can of course be wanted. And the hard limit of 100 is something Claude came up with. Really hard to say where one should put the limit.
We could potentially skip this whole feature of step undo. It's mainly something I have though of for some time (since we removed reverse execution in 7) and that I now took the time to try it out. Should probably be supported in CLI as well if we want it.
If kept it should probably be marked as experimental somehow. It's a cool feature, though. But can be added later after it's been further discussed.
Users want to take, restore and delete Simics snapshots from VS Code, without typing commands in the Simics CLI. The view uses the snapshot commands of the Simics SimUtils service, and follows its snapshotsChanged event, so snapshots taken elsewhere show up too. A Delete All button clears them all at once, after asking. The debug adapter owns the TCF connection and answers custom requests from the view, like for the Path Maps view. This keeps the adapter free of vscode code. Unnamed snapshots get a free name like take-snapshot gives them. Changes run one at a time, so two quick takes do not pick the same name. SimUtils is internal to Simics and older versions lack the snapshot commands. Then the view says that snapshots are not available and the take buttons are disabled. Restore and delete have no enablement condition: VS Code kept their buttons on the snapshot rows greyed out. Those rows only exist when snapshots are supported anyway. Signed-off-by: Andreas Ragnerstam <andreas.ragnerstam@intel.com>
|
I reduced this to only be for adding snapshots support, not the undo-step part as that is more of an experimental feature that can be its own patch. |
emanuelen5
left a comment
There was a problem hiding this comment.
I haven't tried it, but sounds useful.
| this.sendEvent(new Event("symbolFilesChanged")); | ||
| this.sendEvent(new Event("pathMapChanged")); |
There was a problem hiding this comment.
For a follow-up PR: we should probably refactor these plain strings so the debug adapter events are typed and defined in one place. And in such a way that we can use type narrowing (i.e. so that the receiver of the event can know what data it has attached).
There was a problem hiding this comment.
Sounds good.
I'll try to fix your good suggestions. I have a few other PRs I would like to commit, but waited with them until this had landed due to CHANGLOG conflicts. But I can put the rest in one PR.
And then do follow ups with the cleanups in README and strings in another PR.
Uh oh!
There was an error while loading. Please reload this page.