@@ -43,7 +43,12 @@ impl BacktraceLock<'_> {
43
43
}
44
44
}
45
45
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
+ }
47
52
// Always 'fail' to get the cwd when running under Miri -
48
53
// this allows Miri to display backtraces in isolation mode
49
54
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::
68
73
return false ;
69
74
}
70
75
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
+ }
89
98
}
90
99
}
91
- }
92
100
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 ;
104
115
}
105
- first_omit = false ;
106
- omitted_count = 0 ;
116
+ res = bt_fmt. frame ( ) . symbol ( frame, symbol) ;
107
117
}
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 ;
109
131
}
110
- } ) ;
111
- #[ cfg( target_os = "nto" ) ]
112
- if libc:: __my_thread_exit as * mut libc:: c_void == frame. ip ( ) {
113
132
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 ) ;
121
134
}
122
- return false ;
123
- }
124
- if !hit && print {
125
- res = bt_fmt. frame ( ) . print_raw ( frame. ip ( ) , None , None , None ) ;
126
135
}
127
136
128
137
idx += 1 ;
0 commit comments