@@ -43,7 +43,12 @@ impl BacktraceLock<'_> {
4343 }
4444}
4545
46- unsafe fn _print_fmt ( fmt : & mut fmt:: Formatter < ' _ > , print_fmt : PrintFmt ) -> fmt:: Result {
46+ unsafe fn _print_fmt ( fmt : & mut fmt:: Formatter < ' _ > , mut print_fmt : PrintFmt ) -> fmt:: Result {
47+ // If we're printing without symbols then always print full backtraces
48+ // as otherwise there's no useful information to show.
49+ if cfg ! ( feature = "backtrace-trace-only" ) {
50+ print_fmt = PrintFmt :: Full ;
51+ }
4752 // Always 'fail' to get the cwd when running under Miri -
4853 // this allows Miri to display backtraces in isolation mode
4954 let cwd = if !cfg ! ( miri) { env:: current_dir ( ) . ok ( ) } else { None } ;
@@ -68,61 +73,65 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
6873 return false ;
6974 }
7075
71- let mut hit = false ;
72- backtrace_rs:: resolve_frame_unsynchronized ( frame, |symbol| {
73- hit = true ;
74-
75- // `__rust_end_short_backtrace` means we are done hiding symbols
76- // for now. Print until we see `__rust_begin_short_backtrace`.
77- if print_fmt == PrintFmt :: Short {
78- if let Some ( sym) = symbol. name ( ) . and_then ( |s| s. as_str ( ) ) {
79- if sym. contains ( "__rust_end_short_backtrace" ) {
80- print = true ;
81- return ;
82- }
83- if print && sym. contains ( "__rust_begin_short_backtrace" ) {
84- print = false ;
85- return ;
86- }
87- if !print {
88- omitted_count += 1 ;
76+ if cfg ! ( feature = "backtrace-trace-only" ) {
77+ res = bt_fmt. frame ( ) . print_raw ( frame. ip ( ) , None , None , None ) ;
78+ } else {
79+ let mut hit = false ;
80+ backtrace_rs:: resolve_frame_unsynchronized ( frame, |symbol| {
81+ hit = true ;
82+
83+ // `__rust_end_short_backtrace` means we are done hiding symbols
84+ // for now. Print until we see `__rust_begin_short_backtrace`.
85+ if print_fmt == PrintFmt :: Short {
86+ if let Some ( sym) = symbol. name ( ) . and_then ( |s| s. as_str ( ) ) {
87+ if sym. contains ( "__rust_end_short_backtrace" ) {
88+ print = true ;
89+ return ;
90+ }
91+ if print && sym. contains ( "__rust_begin_short_backtrace" ) {
92+ print = false ;
93+ return ;
94+ }
95+ if !print {
96+ omitted_count += 1 ;
97+ }
8998 }
9099 }
91- }
92100
93- if print {
94- if omitted_count > 0 {
95- debug_assert ! ( print_fmt == PrintFmt :: Short ) ;
96- // only print the message between the middle of frames
97- if !first_omit {
98- let _ = writeln ! (
99- bt_fmt. formatter( ) ,
100- " [... omitted {} frame{} ...]" ,
101- omitted_count,
102- if omitted_count > 1 { "s" } else { "" }
103- ) ;
101+ if print {
102+ if omitted_count > 0 {
103+ debug_assert ! ( print_fmt == PrintFmt :: Short ) ;
104+ // only print the message between the middle of frames
105+ if !first_omit {
106+ let _ = writeln ! (
107+ bt_fmt. formatter( ) ,
108+ " [... omitted {} frame{} ...]" ,
109+ omitted_count,
110+ if omitted_count > 1 { "s" } else { "" }
111+ ) ;
112+ }
113+ first_omit = false ;
114+ omitted_count = 0 ;
104115 }
105- first_omit = false ;
106- omitted_count = 0 ;
116+ res = bt_fmt. frame ( ) . symbol ( frame, symbol) ;
107117 }
108- res = bt_fmt. frame ( ) . symbol ( frame, symbol) ;
118+ } ) ;
119+ #[ cfg( target_os = "nto" ) ]
120+ if libc:: __my_thread_exit as * mut libc:: c_void == frame. ip ( ) {
121+ if !hit && print {
122+ use crate :: backtrace_rs:: SymbolName ;
123+ res = bt_fmt. frame ( ) . print_raw (
124+ frame. ip ( ) ,
125+ Some ( SymbolName :: new ( "__my_thread_exit" . as_bytes ( ) ) ) ,
126+ None ,
127+ None ,
128+ ) ;
129+ }
130+ return false ;
109131 }
110- } ) ;
111- #[ cfg( target_os = "nto" ) ]
112- if libc:: __my_thread_exit as * mut libc:: c_void == frame. ip ( ) {
113132 if !hit && print {
114- use crate :: backtrace_rs:: SymbolName ;
115- res = bt_fmt. frame ( ) . print_raw (
116- frame. ip ( ) ,
117- Some ( SymbolName :: new ( "__my_thread_exit" . as_bytes ( ) ) ) ,
118- None ,
119- None ,
120- ) ;
133+ res = bt_fmt. frame ( ) . print_raw ( frame. ip ( ) , None , None , None ) ;
121134 }
122- return false ;
123- }
124- if !hit && print {
125- res = bt_fmt. frame ( ) . print_raw ( frame. ip ( ) , None , None , None ) ;
126135 }
127136
128137 idx += 1 ;
0 commit comments