Skip to content

Commit

Permalink
refactor(debugger): rewrite draw code (#6522)
Browse files Browse the repository at this point in the history
* chore: enable unreachable_pub

* chore: use Debugger::builder()

* test: add a simple debuggable test

* refactor: use let-else to reduce indentation

* fix: debugger panic handler

* test: update debugger test

* fix: solc artifact absolute path

* refactor: src_text

* refactor: add a wrapper for source lines

* feat: minimum terminal size

* refactor: rest of the draw functions

* chore: explain panic hook

* chore: remove whitespace hack

* chore: clippy
  • Loading branch information
DaniPopes authored Dec 6, 2023
1 parent 5a4daaf commit bacacce
Show file tree
Hide file tree
Showing 23 changed files with 711 additions and 614 deletions.
15 changes: 5 additions & 10 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
[alias]
cheats = "test -p foundry-cheatcodes-spec --features schema tests::"
test-debugger = "test -p forge --test cli manual_debug_setup -- --include-ignored --nocapture"

# Increase the stack size to 10MB for Windows targets, which is in line with Linux
# (whereas default for Windows is 1MB).
[target.x86_64-pc-windows-msvc]
rustflags = [
# Increases the stack size to 10MB, which is
# in line with Linux (whereas default for Windows is 1MB)
"-Clink-arg=/STACK:10000000",
]
rustflags = ["-Clink-arg=/STACK:10000000"]

[target.i686-pc-windows-msvc]
rustflags = [
# Increases the stack size to 10MB, which is
# in line with Linux (whereas default for Windows is 1MB)
"-Clink-arg=/STACK:10000000",
]
rustflags = ["-Clink-arg=/STACK:10000000"]
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/cli/src/utils/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use foundry_compilers::{
Artifact, ProjectCompileOutput,
};
use foundry_config::{error::ExtractConfigError, figment::Figment, Chain, Config, NamedChain};
use foundry_debugger::DebuggerBuilder;
use foundry_debugger::Debugger;
use foundry_evm::{
debug::DebugArena,
executors::{DeployResult, EvmError, ExecutionErr, RawCallResult},
Expand Down Expand Up @@ -404,7 +404,7 @@ pub async fn handle_traces(

if debug {
let sources = etherscan_identifier.get_compiled_contracts().await?;
let mut debugger = DebuggerBuilder::new()
let mut debugger = Debugger::builder()
.debug_arena(&result.debug)
.decoder(&decoder)
.sources(sources)
Expand Down
3 changes: 2 additions & 1 deletion crates/debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ homepage.workspace = true
repository.workspace = true

[dependencies]
foundry-common.workspace = true
foundry-compilers.workspace = true
foundry-evm-core.workspace = true
foundry-evm-traces.workspace = true
foundry-common.workspace = true

alloy-primitives.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/debugger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Interactive Solidity TUI debugger.

#![warn(unused_crate_dependencies)]
#![warn(unused_crate_dependencies, unreachable_pub)]

#[macro_use]
extern crate tracing;
Expand Down
8 changes: 4 additions & 4 deletions crates/debugger/src/op.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/// Named parameter of an EVM opcode.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct OpcodeParam {
pub(crate) struct OpcodeParam {
/// The name of the parameter.
pub name: &'static str,
pub(crate) name: &'static str,
/// The index of the parameter on the stack. This is relative to the top of the stack.
pub index: usize,
pub(crate) index: usize,
}

impl OpcodeParam {
/// Returns the list of named parameters for the given opcode.
#[inline]
pub fn of(op: u8) -> &'static [Self] {
pub(crate) fn of(op: u8) -> &'static [Self] {
MAP[op as usize]
}
}
Expand Down
Loading

0 comments on commit bacacce

Please sign in to comment.