Skip to content

[IDE debugging] Introduce DebugValue for structured value representation for debugging#19791

Closed
mkurnikov wants to merge 2 commits into
mainfrom
debug-value
Closed

[IDE debugging] Introduce DebugValue for structured value representation for debugging#19791
mkurnikov wants to merge 2 commits into
mainfrom
debug-value

Conversation

@mkurnikov

@mkurnikov mkurnikov commented May 16, 2026

Copy link
Copy Markdown
Collaborator

Extracted from #19766


Note

Low Risk
Changes are confined to debugging/diagnostic paths (stack traces, enriched locals) with broad unit tests; normal transaction execution is unaffected unless debugging is enabled.

Overview
Introduces a DebugValue tree and typed serialization path for Move VM debugging, replacing the large inline debug printer in values_impl.rs with a dedicated values_impl/debug.rs module and a TypeResolver hook for ADT/enum/struct names.

Runtime wiring: source_locator::print_locals_enriched now builds per-slot LocalInfo (name + Type), uses LocatorTypeResolver (source maps + RuntimeEnvironment) with serialize_value_for_debug, and falls back to local[idx] when names are missing. The interpreter exposes get_stack_depth() on InterpreterDebugInterface for stack traces and VM error dumps.

Cleanup: Operand-stack traces still call values::debug::print_value (untyped resolver). debug_write! / debug_writeln! macros use fully qualified PartialVMError paths.

Reviewed by Cursor Bugbot for commit 502545a. Bugbot is set up for automated code reviews on this repo. Configure here.

@mkurnikov mkurnikov requested a review from a team as a code owner May 16, 2026 18:20
Comment thread third_party/move/move-vm/runtime/src/source_locator.rs Outdated
Comment thread third_party/move/move-vm/runtime/src/source_locator.rs Outdated
@mkurnikov mkurnikov force-pushed the debug-value branch 2 times, most recently from 0f313fd to 327627d Compare May 16, 2026 18:53

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 4 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 327627d. Configure here.

Comment thread third_party/move/move-vm/runtime/src/source_locator.rs Outdated
Comment thread third_party/move/move-vm/types/src/values/values_impl/debug.rs
@mkurnikov mkurnikov force-pushed the debug-value branch 2 times, most recently from 179c698 to dc8bf8e Compare May 16, 2026 20:26
@mkurnikov mkurnikov requested a review from rahxephon89 May 16, 2026 20:34
Comment thread third_party/move/move-vm/runtime/src/debug/interpreter.rs Outdated
};

#[derive(Debug, Clone)]
pub enum DebugValue {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

design question: why is this needed? In general, adding a new value type makes maintenance harder.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Local values in the debugger are presented as a trees, think "struct fields", "vector elements", etc.
This struct is a representation of said tree.

It's hard to understand it's usefulness without the general DAP context, I agree. In the original PR (#19580), this data then serialized into JSON and passed to VSCode (or any DAP client) to show to the user.

image

The alternative would be to add a bunch of pub modifiers in values_impl.rs, and serialize Value straight into JSON, without intermediate DebugValue struct.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually, there's a cross-thread communication happens.
Currently whole DebugContext is Send, if we'd try to pass Value straight to DAP server for serialization, DebugContext would stop being Send which creates a bunch of hard to resolve issues.

So serialization must happen in move-vm-types crate.
What I can do is to make DebugValue an untyped tree type instead, i.e. DapNode { item: String, children: Vec<DapNode> } which would get rid of the typed DebugValue. But implementation would mostly stay the same, there's still going to be recursive walk through the values to collect a value tree.

Comment thread third_party/move/move-vm/runtime/src/source_locator.rs Outdated
}
}

fn is_type(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

from this name, it is a general function but it seems only used in serialize_adt? Will this be used anywhere else? If not, maybe we don't this abstraction?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking of special-casing Object<Type> in the future. But for now it can be removed, you're right.

pub type FieldInfo = (String, Option<Type>);

#[derive(Clone)]
pub enum AdtInfo {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Adt is not explained anywhere and it is actually structs or enum. Maybe just use StructTypeInfo?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it's for the Abstract Data Type.

Comment thread third_party/move/move-vm/runtime/src/source_locator.rs Outdated
.collect();
DebugValue::Struct(children)
},
Container::Locals(_) => DebugValue::Error("...".into()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what is "..." here? Maybe add a meaningful error message instead?

Comment thread third_party/move/move-vm/runtime/src/debug/interpreter.rs Outdated
Comment thread third_party/move/move-vm/runtime/src/source_locator.rs
@mkurnikov

Copy link
Copy Markdown
Collaborator Author

Superseded by #19899

@mkurnikov mkurnikov closed this May 27, 2026
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.

2 participants