-
Notifications
You must be signed in to change notification settings - Fork 184
fix: add VM Execution State #2043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The changelog needs to be updated. |
Hi @crStiv, could you share a bit more information on the usecases of this new structure? Why are those particular fields necessary? |
@JulianGCalderon
I picked these specijfic fields after some trial and error - they're the minimum set that actualy gives you the full picture of what's hapening in the VM. Happy to go deeper if needed. |
@FrancoGiachetta got you, changelog is updated now, and deleted comments to the test as well |
Is it possible for you to tell us what you are doing that needs this information at some point in the program? |
@FrancoGiachetta |
@FrancoGiachetta hi, just wonder what's the status of my PR |
Hi @crStiv! We've taken a look at this. You can already almost all the information (except for with pub struct ExecutionState {
/// Current program counter (Program Counter)
pub pc: Relocatable,
/// Current allocation pointer (Allocation Pointer)
pub ap: usize,
/// Current frame pointer (Frame Pointer)
pub fp: usize,
/// Current execution step
pub current_step: usize,
/// Number of memory segments
pub memory_segments_count: usize,
/// Information about active built-ins
pub active_builtins: Vec<String>,
}
...
let state = ExecutionState {
pc: vm.get_pc(),
ap: vm.get_ap().offset,
fp: vm.get_fp().offset,
current_step: vm.get_current_step(),
memory_segments_count: vm.segments.num_segments(),
active_builtins: vm.get_builtin_runners()
.iter()
.map(|runner| runner.name().to_string())
.collect(),
} The only attribute you cannot retrieve from the vm would be run_finished. This is a boolean which is used to prevent marking a range memory cells as accessed, which can only be done if the execution has finished. Is it possible to know why do you need to read that attribute? |
@FrancoGiachetta Thanks for your feedback! While assembling this data manually is possible, having a dedicated method provides:
Without run_finished, my tool can't reliably determine when it's safe to perform certain operations, leading to potential issues. Would you consider keeping this PR or making that attribute public separately? |
The thing is that this method would be public, and thus it would increase the size of the api exposed. Any change to this method or the struct would be a breaking. Since you can already get almost all of these attributes by your self, it wouldn't be appropriate. Talking about |
@FrancoGiachetta Fair point about the API surface. Looking back at it, my use case probably isn't strong enough to justify this addition. Feel free to close this PR if you don't see value in it. If there's any part worth salvaging or other ways I could help instead, just let me know. |
Add VM Execution State
Description
Added ExecutionState structure and get_execution_state() method to capture current VM state. Helps with debugging and simplifies integration with external tools.
What's included:
Checklist