@@ -88,13 +88,15 @@ mod tests;
88
88
// `Backtrace`, but that's a relatively small price to pay relative to capturing
89
89
// a backtrace or actually symbolizing it.
90
90
91
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
91
92
use crate :: backtrace_rs:: { self , BytesOrWideString } ;
92
93
use crate :: env;
93
94
use crate :: ffi:: c_void;
94
95
use crate :: fmt;
95
96
use crate :: panic:: UnwindSafe ;
96
97
use crate :: sync:: atomic:: { AtomicU8 , Ordering :: Relaxed } ;
97
98
use crate :: sync:: LazyLock ;
99
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
98
100
use crate :: sys_common:: backtrace:: { lock, output_filename, set_image_base} ;
99
101
100
102
/// A captured OS thread stack backtrace.
@@ -154,6 +156,7 @@ pub struct BacktraceFrame {
154
156
155
157
#[ derive( Debug ) ]
156
158
enum RawFrame {
159
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
157
160
Actual ( backtrace_rs:: Frame ) ,
158
161
#[ cfg( test) ]
159
162
Fake ,
@@ -173,6 +176,7 @@ enum BytesOrWide {
173
176
174
177
#[ stable( feature = "backtrace" , since = "1.65.0" ) ]
175
178
impl fmt:: Debug for Backtrace {
179
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
176
180
fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
177
181
let capture = match & self . inner {
178
182
Inner :: Unsupported => return fmt. write_str ( "<unsupported>" ) ,
@@ -196,17 +200,29 @@ impl fmt::Debug for Backtrace {
196
200
197
201
dbg. finish ( )
198
202
}
203
+
204
+ #[ cfg( any( target_arch = "bpf" , target_arch = "sbf" ) ) ]
205
+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
206
+ write ! ( fmt, "<unsupported>" )
207
+ }
199
208
}
200
209
201
210
#[ unstable( feature = "backtrace_frames" , issue = "79676" ) ]
202
211
impl fmt:: Debug for BacktraceFrame {
212
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
203
213
fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
204
214
let mut dbg = fmt. debug_list ( ) ;
205
215
dbg. entries ( & self . symbols ) ;
206
216
dbg. finish ( )
207
217
}
218
+
219
+ #[ cfg( any( target_arch = "bpf" , target_arch = "sbf" ) ) ]
220
+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
221
+ write ! ( fmt, "<unsupported>" )
222
+ }
208
223
}
209
224
225
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
210
226
impl fmt:: Debug for BacktraceSymbol {
211
227
fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
212
228
// FIXME: improve formatting: https://github.com/rust-lang/rust/issues/65280
@@ -233,6 +249,7 @@ impl fmt::Debug for BacktraceSymbol {
233
249
}
234
250
}
235
251
252
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
236
253
impl fmt:: Debug for BytesOrWide {
237
254
fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
238
255
output_filename (
@@ -250,6 +267,7 @@ impl fmt::Debug for BytesOrWide {
250
267
impl Backtrace {
251
268
/// Returns whether backtrace captures are enabled through environment
252
269
/// variables.
270
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
253
271
fn enabled ( ) -> bool {
254
272
// Cache the result of reading the environment variables to make
255
273
// backtrace captures speedy, because otherwise reading environment
@@ -271,6 +289,11 @@ impl Backtrace {
271
289
enabled
272
290
}
273
291
292
+ #[ cfg( any( target_arch = "bpf" , target_arch = "sbf" ) ) ]
293
+ fn enabled ( ) -> bool {
294
+ false
295
+ }
296
+
274
297
/// Capture a stack backtrace of the current thread.
275
298
///
276
299
/// This function will capture a stack backtrace of the current OS thread of
@@ -322,6 +345,7 @@ impl Backtrace {
322
345
323
346
// Capture a backtrace which start just before the function addressed by
324
347
// `ip`
348
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
325
349
fn create ( ip : usize ) -> Backtrace {
326
350
let _lock = lock ( ) ;
327
351
let mut frames = Vec :: new ( ) ;
@@ -355,6 +379,13 @@ impl Backtrace {
355
379
Backtrace { inner }
356
380
}
357
381
382
+ #[ cfg( any( target_arch = "bpf" , target_arch = "sbf" ) ) ]
383
+ fn create ( ip : usize ) -> Backtrace {
384
+ Backtrace {
385
+ inner : Inner :: Unsupported
386
+ }
387
+ }
388
+
358
389
/// Returns the status of this backtrace, indicating whether this backtrace
359
390
/// request was unsupported, disabled, or a stack trace was actually
360
391
/// captured.
@@ -380,6 +411,7 @@ impl<'a> Backtrace {
380
411
381
412
#[ stable( feature = "backtrace" , since = "1.65.0" ) ]
382
413
impl fmt:: Display for Backtrace {
414
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
383
415
fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
384
416
let capture = match & self . inner {
385
417
Inner :: Unsupported => return fmt. write_str ( "unsupported backtrace" ) ,
@@ -426,6 +458,11 @@ impl fmt::Display for Backtrace {
426
458
f. finish ( ) ?;
427
459
Ok ( ( ) )
428
460
}
461
+
462
+ #[ cfg( any( target_arch = "bpf" , target_arch = "sbf" ) ) ]
463
+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
464
+ write ! ( fmt, "<unsupported>" )
465
+ }
429
466
}
430
467
431
468
type LazyResolve = impl ( FnOnce ( ) -> Capture ) + Send + Sync + UnwindSafe ;
@@ -460,8 +497,18 @@ fn lazy_resolve(mut capture: Capture) -> LazyResolve {
460
497
461
498
capture
462
499
}
500
+
501
+ #[ cfg ( any ( target_arch = "bpf" , target_arch = "sbf" ) ) ]
502
+ fn resolve( & mut self ) {
503
+ // If we're already resolved, nothing to do!
504
+ if self . resolved {
505
+ return ;
506
+ }
507
+ self . resolved = true ;
508
+ }
463
509
}
464
510
511
+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
465
512
impl RawFrame {
466
513
fn ip ( & self ) -> * mut c_void {
467
514
match self {
0 commit comments