-
Notifications
You must be signed in to change notification settings - Fork 387
feat: optionally output a debug artifact on compile #2260
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b999b23
wip: debug
sirasistant 97efaf4
Merge branch 'master' into arv/debug_symbols
sirasistant a2cc192
feat: first impl of debug artifact
sirasistant 8a489c8
fix: use debug_ prefix
sirasistant 09eea07
Merge branch 'master' into arv/debug_symbols
sirasistant e6adb6c
Update crates/nargo_cli/src/cli/compile_cmd.rs
sirasistant 4e89750
fix: use pathbuf instead of string for paths
sirasistant d4f38da
Merge branch 'arv/debug_symbols' of github.com:noir-lang/noir into ar…
sirasistant 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| use serde::{Deserialize, Serialize}; | ||
| use std::{ | ||
| collections::{BTreeMap, BTreeSet}, | ||
| path::PathBuf, | ||
| }; | ||
|
|
||
| use fm::FileId; | ||
| use noirc_errors::debug_info::DebugInfo; | ||
| use noirc_frontend::hir::Context; | ||
|
|
||
| /// For a given file, we store the source code and the path to the file | ||
| /// so consumers of the debug artifact can reconstruct the original source code structure. | ||
| #[derive(Debug, Serialize, Deserialize)] | ||
| pub struct DebugFile { | ||
| pub source: String, | ||
| pub path: PathBuf, | ||
| } | ||
|
|
||
| /// A Debug Artifact stores, for a given program, the debug info for every function | ||
| /// along with a map of file Id to the source code so locations in debug info can be mapped to source code they point to. | ||
| #[derive(Debug, Serialize, Deserialize)] | ||
sirasistant marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pub struct DebugArtifact { | ||
| pub debug_symbols: Vec<DebugInfo>, | ||
| pub file_map: BTreeMap<FileId, DebugFile>, | ||
| } | ||
|
|
||
| impl DebugArtifact { | ||
| pub fn new(debug_symbols: Vec<DebugInfo>, compilation_context: &Context) -> Self { | ||
| let mut file_map = BTreeMap::new(); | ||
|
|
||
| let files_with_debug_symbols: BTreeSet<FileId> = debug_symbols | ||
| .iter() | ||
| .flat_map(|function_symbols| function_symbols.locations.values().map(|loc| loc.file)) | ||
| .collect(); | ||
|
|
||
| for file_id in files_with_debug_symbols { | ||
| let file_source = compilation_context.file_manager.fetch_file(file_id).source(); | ||
|
|
||
| file_map.insert( | ||
| file_id, | ||
| DebugFile { | ||
| source: file_source.to_string(), | ||
| path: compilation_context.file_manager.path(file_id).to_path_buf(), | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| Self { debug_symbols, file_map } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.