-
Notifications
You must be signed in to change notification settings - Fork 223
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
feat: Instrument AST in debug mode to track variable state #3523
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2433740
feat: instrumentation for runtime variable inspection in debug mode
nthiad 705e1be
move fild_ids back to a BTreeSet to get deduplication
nthiad 953a89a
constrained debug function with an extra wrapper
nthiad 966bb88
pass through let statement span and set the other injected spans to e…
nthiad addd08f
assign variables by integer, fn params, and implement drops for fn scope
nthiad f8c0100
factor out fn scope handling to also use for blocks
nthiad f59a1e9
plain case for mutable assignment updates
nthiad 8dda4ca
walk all expressions for debug instrumentation
nthiad 31812fb
collect and display type info for the debugger
nthiad cd88fa1
move default foreign call executor internal debug methods
nthiad 8b88af9
cargo fmt
nthiad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
use acvm::acir::circuit::OpcodeLocation; | ||
use acvm::compiler::AcirTransformationMap; | ||
use fm::FileId; | ||
|
||
use serde_with::serde_as; | ||
use serde_with::DisplayFromStr; | ||
use std::collections::BTreeMap; | ||
use std::collections::HashMap; | ||
use std::collections::{BTreeMap, HashMap}; | ||
use std::mem; | ||
|
||
use crate::Location; | ||
use noirc_printable_type::PrintableType; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub type Variables = Vec<(u32, (String, u32))>; | ||
pub type Types = Vec<(u32, PrintableType)>; | ||
pub type VariableTypes = (Variables, Types); | ||
|
||
#[serde_as] | ||
#[derive(Default, Debug, Clone, Deserialize, Serialize)] | ||
pub struct DebugInfo { | ||
|
@@ -18,6 +23,8 @@ pub struct DebugInfo { | |
/// that they should be serialized to/from strings. | ||
#[serde_as(as = "BTreeMap<DisplayFromStr, _>")] | ||
pub locations: BTreeMap<OpcodeLocation, Vec<Location>>, | ||
pub variables: HashMap<u32, (String, u32)>, // var_id => (name, type_id) | ||
pub types: HashMap<u32, PrintableType>, // type_id => printable type | ||
} | ||
|
||
/// Holds OpCodes Counts for Acir and Brillig Opcodes | ||
|
@@ -29,8 +36,15 @@ pub struct OpCodesCount { | |
} | ||
|
||
impl DebugInfo { | ||
pub fn new(locations: BTreeMap<OpcodeLocation, Vec<Location>>) -> Self { | ||
DebugInfo { locations } | ||
pub fn new( | ||
locations: BTreeMap<OpcodeLocation, Vec<Location>>, | ||
var_types: VariableTypes, | ||
) -> Self { | ||
Self { | ||
locations, | ||
variables: var_types.0.into_iter().collect(), | ||
types: var_types.1.into_iter().collect(), | ||
} | ||
} | ||
|
||
/// Updates the locations map when the [`Circuit`][acvm::acir::circuit::Circuit] is modified. | ||
|
@@ -85,4 +99,11 @@ impl DebugInfo { | |
|
||
counted_opcodes | ||
} | ||
|
||
pub fn get_file_ids(&self) -> Vec<FileId> { | ||
self.locations | ||
.values() | ||
.filter_map(|call_stack| call_stack.last().map(|location| location.file)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure we can't have empty callstacks so this filtering may be unnecessary. |
||
.collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self to look at how this acts when we're not in a debug context. Should we make this optional?