@@ -68,61 +68,67 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
6868 return false ;
6969 }
7070
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 ;
71+ if cfg ! ( feature = "backtrace-trace-only" ) {
72+ const HEX_WIDTH : usize = 2 + 2 * core:: mem:: size_of :: < usize > ( ) ;
73+ let frame_ip = frame. ip ( ) ;
74+ res = writeln ! ( bt_fmt. formatter( ) , "{idx:4}: {frame_ip:HEX_WIDTH$?}" ) ;
75+ } else {
76+ let mut hit = false ;
77+ backtrace_rs:: resolve_frame_unsynchronized ( frame, |symbol| {
78+ hit = true ;
79+
80+ // `__rust_end_short_backtrace` means we are done hiding symbols
81+ // for now. Print until we see `__rust_begin_short_backtrace`.
82+ if print_fmt == PrintFmt :: Short {
83+ if let Some ( sym) = symbol. name ( ) . and_then ( |s| s. as_str ( ) ) {
84+ if sym. contains ( "__rust_end_short_backtrace" ) {
85+ print = true ;
86+ return ;
87+ }
88+ if print && sym. contains ( "__rust_begin_short_backtrace" ) {
89+ print = false ;
90+ return ;
91+ }
92+ if !print {
93+ omitted_count += 1 ;
94+ }
8995 }
9096 }
91- }
9297
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- ) ;
98+ if print {
99+ if omitted_count > 0 {
100+ debug_assert ! ( print_fmt == PrintFmt :: Short ) ;
101+ // only print the message between the middle of frames
102+ if !first_omit {
103+ let _ = writeln ! (
104+ bt_fmt. formatter( ) ,
105+ " [... omitted {} frame{} ...]" ,
106+ omitted_count,
107+ if omitted_count > 1 { "s" } else { "" }
108+ ) ;
109+ }
110+ first_omit = false ;
111+ omitted_count = 0 ;
104112 }
105- first_omit = false ;
106- omitted_count = 0 ;
113+ res = bt_fmt. frame ( ) . symbol ( frame, symbol) ;
107114 }
108- res = bt_fmt. frame ( ) . symbol ( frame, symbol) ;
115+ } ) ;
116+ #[ cfg( target_os = "nto" ) ]
117+ if libc:: __my_thread_exit as * mut libc:: c_void == frame. ip ( ) {
118+ if !hit && print {
119+ use crate :: backtrace_rs:: SymbolName ;
120+ res = bt_fmt. frame ( ) . print_raw (
121+ frame. ip ( ) ,
122+ Some ( SymbolName :: new ( "__my_thread_exit" . as_bytes ( ) ) ) ,
123+ None ,
124+ None ,
125+ ) ;
126+ }
127+ return false ;
109128 }
110- } ) ;
111- #[ cfg( target_os = "nto" ) ]
112- if libc:: __my_thread_exit as * mut libc:: c_void == frame. ip ( ) {
113129 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- ) ;
130+ res = bt_fmt. frame ( ) . print_raw ( frame. ip ( ) , None , None , None ) ;
121131 }
122- return false ;
123- }
124- if !hit && print {
125- res = bt_fmt. frame ( ) . print_raw ( frame. ip ( ) , None , None , None ) ;
126132 }
127133
128134 idx += 1 ;
0 commit comments