Skip to content
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

Remove backtrace #1464

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion soroban-env-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ default-features = false
features = ["arbitrary"]

[features]
testutils = ["soroban-env-common/testutils", "recording_mode", "dep:backtrace"]
testutils = ["soroban-env-common/testutils", "recording_mode"]
backtrace = ["dep:backtrace"]
next = ["soroban-env-common/next", "stellar-xdr/next"]
tracy = ["dep:tracy-client", "soroban-env-common/tracy"]
recording_mode = []
Expand Down
15 changes: 9 additions & 6 deletions soroban-env-host/src/host/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
ConversionError, EnvBase, Error, Host, TryFromVal, U32Val, Val,
};

#[cfg(any(test, feature = "testutils"))]
#[cfg(any(test, feature = "backtrace"))]
use backtrace::{Backtrace, BacktraceFrame};
use core::fmt::Debug;
use std::{
Expand All @@ -18,7 +18,7 @@ use super::metered_clone::MeteredClone;
#[derive(Clone)]
pub(crate) struct DebugInfo {
events: Events,
#[cfg(any(test, feature = "testutils"))]
#[cfg(any(test, feature = "backtrace"))]
backtrace: Backtrace,
}

Expand Down Expand Up @@ -67,12 +67,12 @@ impl DebugInfo {
Ok(())
}

#[cfg(not(any(test, feature = "testutils")))]
#[cfg(not(any(test, feature = "backtrace")))]
fn write_backtrace(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Ok(())
}

#[cfg(any(test, feature = "testutils"))]
#[cfg(any(test, feature = "backtrace"))]
fn write_backtrace(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// We do a little trimming here, skipping the first two frames (which
// are always into, from, and one or more Host::err_foo calls) and all
Expand Down Expand Up @@ -296,8 +296,11 @@ impl Host {
self.with_debug_mode(|| {
if let Ok(events_ref) = self.0.events.try_borrow() {
let events = events_ref.externalize(self)?;
let backtrace = Backtrace::new_unresolved();
res = Some(Box::new(DebugInfo { backtrace, events }));
res = Some(Box::new(DebugInfo {
#[cfg(any(test, feature = "backtrace"))]
backtrace: Backtrace::new_unresolved(),
events,
}));
}
Ok(())
});
Expand Down
Loading