zemse / forge-flamegraph

🔥 flamegraphs for solidity
https://ethglobal.com/showcase/not-decided-0gr0p
35 stars 1 forks source link

bug: panics with option name clash #2

Closed aodhgan closed 2 months ago

aodhgan commented 2 months ago

build the tool by cloning and running cargo build

forge --version forge 0.2.0 (ee47bb0 2024-04-16T00:22:03.703537000Z)

getting the following error:

aodhgan@aodhgans-MBP ff_evm_contracts % forge-flamegraph -t test_battleWithoutValidation --open
The application panicked (crashed).
Message:  Command forge-flamegraph: Short option names must be unique for each argument, but '-o' is in use by both 'open' and 'out_path'
Location: /Users/aodhgan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.2/src/builder/debug_asserts.rs:112

This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 13 frames hidden ⋮                              
  14: clap_builder::builder::debug_asserts::assert_app::h6cfa9744a0e88128
      at /Users/aodhgan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.2/src/builder/debug_asserts.rs:112
       110 │         if let Some(s) = arg.get_short() {
       111 │             if let Some((first, second)) = cmd.two_args_of(|x| x.get_short() == Some(s)) {
       112 >                 panic!(
       113 │                     "Command {}: Short option names must be unique for each argument, \
       114 │                             but '-{}' is in use by both '{}' and '{}'{}",
  15: clap_builder::builder::command::Command::_build_self::haaf4c7c85eb83fcf
      at /Users/aodhgan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.2/src/builder/command.rs:4123
      4121 │ 
      4122 │             #[cfg(debug_assertions)]
      4123 >             assert_app(self);
      4124 │             self.settings.set(AppSettings::Built);
      4125 │         } else {
  16: clap_builder::builder::command::Command::_do_parse::h1942a895e37ed06c
      at /Users/aodhgan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.2/src/builder/command.rs:3994
      3992 │         // If there are global arguments, or settings we need to propagate them down to subcommands
      3993 │         // before parsing in case we run into a subcommand
      3994 >         self._build_self(false);
      3995 │ 
      3996 │         let mut matcher = ArgMatcher::new(self);
  17: clap_builder::builder::command::Command::try_get_matches_from_mut::h47bf96e26219b838
      at /Users/aodhgan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.2/src/builder/command.rs:830
       828 │         }
       829 │ 
       830 >         self._do_parse(&mut raw_args, cursor)
       831 │     }
       832 │ 
  18: clap_builder::builder::command::Command::get_matches_from::hb451137047b70318
      at /Users/aodhgan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.2/src/builder/command.rs:701
       699 │         T: Into<OsString> + Clone,
       700 │     {
       701 >         self.try_get_matches_from_mut(itr).unwrap_or_else(|e| {
       702 │             drop(self);
       703 │             e.exit()
  19: clap_builder::builder::command::Command::get_matches::h4c81105614f27ea1
      at /Users/aodhgan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.2/src/builder/command.rs:610
       608 │     #[inline]
       609 │     pub fn get_matches(self) -> ArgMatches {
       610 >         self.get_matches_from(env::args_os())
       611 │     }
       612 │ 
  20: clap_builder::derive::Parser::parse::h009d4f8c5b2f0c18
      at /Users/aodhgan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.2/src/derive.rs:27
        25 │     /// Parse from `std::env::args_os()`, [exit][Error::exit] on error.
        26 │     fn parse() -> Self {
        27 >         let mut matches = <Self as CommandFactory>::command().get_matches();
        28 │         let res = <Self as FromArgMatches>::from_arg_matches_mut(&mut matches)
        29 │             .map_err(format_error::<Self>);
  21: forge_flamegraph::main::hebebc34533028c3c
      at /Users/aodhgan/forge-flamegraph/src/main.rs:14
        12 │     foundry_cli::utils::enable_paint();
        13 │ 
        14 >     let flamegraph = FlamegraphArgs::parse();
        15 │     set_execution_context(ForgeContext::Test);
        16 │ 
  22: core::ops::function::FnOnce::call_once::h46dfe4321bb5c6c9
      at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250
                                ⋮ 13 frames hidden ⋮                              

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
aodhgan commented 2 months ago

ah nvm, just omitting the --open flag may solve this

zemse commented 2 months ago

Hey @aodhgan, would like to mention this PR https://github.com/foundry-rs/foundry/pull/8640

The internal function decoding is more accurate there. Would love your feedback!

aodhgan commented 2 months ago

great - excited to see this integrated natively.

yeah was running it with --decode-internal - even more useful

one problem I'm having is with viewing large graphs (think millions of gas) - most SVG viewers ive tried struggle with this. any recommendations?

zemse commented 2 months ago

I mostly use a browser, it works great as long as enough RAM. Which SVG viewer are you using?

On macOS, one thing you can try is Safari, it gives better performance.