@@ -336,7 +336,7 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
336
336
with owner: CSSymbolOwnerRef ,
337
337
isInline: Bool ,
338
338
symbol: CSSymbolRef ,
339
- sourceInfo: CSSourceInfoRef ,
339
+ sourceInfo: CSSourceInfoRef ? ,
340
340
images: [ Backtrace . Image ] ) -> Frame {
341
341
if CSIsNull ( symbol) {
342
342
return Frame ( captured: capturedFrame, symbol: nil )
@@ -349,7 +349,7 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
349
349
350
350
let location : SourceLocation ?
351
351
352
- if !CSIsNull( sourceInfo) {
352
+ if let sourceInfo = sourceInfo , !CSIsNull( sourceInfo) {
353
353
let path = CSSourceInfoGetPath ( sourceInfo) ?? " <unknown> "
354
354
let line = CSSourceInfoGetLineNumber ( sourceInfo)
355
355
let column = CSSourceInfoGetColumn ( sourceInfo)
@@ -390,6 +390,7 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
390
390
images: [ Backtrace . Image ] ? ,
391
391
sharedCacheInfo: Backtrace . SharedCacheInfo ? ,
392
392
showInlineFrames: Bool ,
393
+ showSourceLocations: Bool ,
393
394
useSymbolCache: Bool )
394
395
-> SymbolicatedBacktrace ? {
395
396
@@ -449,7 +450,7 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
449
450
450
451
first = false
451
452
}
452
- } else {
453
+ } else if showSourceLocations {
453
454
let symbol = CSSymbolOwnerGetSymbolWithAddress ( owner, address)
454
455
let sourceInfo = CSSymbolOwnerGetSourceInfoWithAddress ( owner,
455
456
address)
@@ -460,6 +461,15 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
460
461
symbol: symbol,
461
462
sourceInfo: sourceInfo,
462
463
images: theImages) )
464
+ } else {
465
+ let symbol = CSSymbolOwnerGetSymbolWithAddress ( owner, address)
466
+
467
+ frames. append ( buildFrame ( from: frame,
468
+ with: owner,
469
+ isInline: false ,
470
+ symbol: symbol,
471
+ sourceInfo: nil ,
472
+ images: theImages) )
463
473
}
464
474
}
465
475
}
@@ -500,21 +510,29 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
500
510
}
501
511
502
512
if let theSymbol = elf32Image? . lookupSymbol ( address: relativeAddress) {
503
- var location = try ? elf32Image! . sourceLocation ( for : relativeAddress )
513
+ var location : SourceLocation ?
504
514
505
- for inline in elf32Image!. inlineCallSites ( at: relativeAddress) {
506
- let fakeSymbol = Symbol ( imageIndex: imageNdx,
507
- imageName: theImages [ imageNdx] . name,
508
- rawName: inline. rawName ?? " <unknown> " ,
509
- offset: 0 ,
510
- sourceLocation: location)
511
- frames. append ( Frame ( captured: frame,
512
- symbol: fakeSymbol,
513
- inlined: true ) )
514
-
515
- location = SourceLocation ( path: inline. filename,
516
- line: inline. line,
517
- column: inline. column)
515
+ if showSourceLocations || showInlineFrames {
516
+ location = try ? elf32Image!. sourceLocation ( for: relativeAddress)
517
+ } else {
518
+ location = nil
519
+ }
520
+
521
+ if showInlineFrames {
522
+ for inline in elf32Image!. inlineCallSites ( at: relativeAddress) {
523
+ let fakeSymbol = Symbol ( imageIndex: imageNdx,
524
+ imageName: theImages [ imageNdx] . name,
525
+ rawName: inline. rawName ?? " <unknown> " ,
526
+ offset: 0 ,
527
+ sourceLocation: location)
528
+ frames. append ( Frame ( captured: frame,
529
+ symbol: fakeSymbol,
530
+ inlined: true ) )
531
+
532
+ location = SourceLocation ( path: inline. filename,
533
+ line: inline. line,
534
+ column: inline. column)
535
+ }
518
536
}
519
537
520
538
symbol = Symbol ( imageIndex: imageNdx,
@@ -523,21 +541,29 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
523
541
offset: theSymbol. offset,
524
542
sourceLocation: location)
525
543
} else if let theSymbol = elf64Image? . lookupSymbol ( address: relativeAddress) {
526
- var location = try ? elf64Image! . sourceLocation ( for : relativeAddress )
544
+ var location : SourceLocation ?
527
545
528
- for inline in elf64Image!. inlineCallSites ( at: relativeAddress) {
529
- let fakeSymbol = Symbol ( imageIndex: imageNdx,
530
- imageName: theImages [ imageNdx] . name,
531
- rawName: inline. rawName ?? " <unknown> " ,
532
- offset: 0 ,
533
- sourceLocation: location)
534
- frames. append ( Frame ( captured: frame,
535
- symbol: fakeSymbol,
536
- inlined: true ) )
537
-
538
- location = SourceLocation ( path: inline. filename,
539
- line: inline. line,
540
- column: inline. column)
546
+ if showSourceLocations || showInlineFrames {
547
+ location = try ? elf64Image!. sourceLocation ( for: relativeAddress)
548
+ } else {
549
+ location = nil
550
+ }
551
+
552
+ if showInlineFrames {
553
+ for inline in elf64Image!. inlineCallSites ( at: relativeAddress) {
554
+ let fakeSymbol = Symbol ( imageIndex: imageNdx,
555
+ imageName: theImages [ imageNdx] . name,
556
+ rawName: inline. rawName ?? " <unknown> " ,
557
+ offset: 0 ,
558
+ sourceLocation: location)
559
+ frames. append ( Frame ( captured: frame,
560
+ symbol: fakeSymbol,
561
+ inlined: true ) )
562
+
563
+ location = SourceLocation ( path: inline. filename,
564
+ line: inline. line,
565
+ column: inline. column)
566
+ }
541
567
}
542
568
543
569
symbol = Symbol ( imageIndex: imageNdx,
0 commit comments