@@ -341,7 +341,7 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
341341 with owner: CSSymbolOwnerRef ,
342342 isInline: Bool ,
343343 symbol: CSSymbolRef ,
344- sourceInfo: CSSourceInfoRef ,
344+ sourceInfo: CSSourceInfoRef ? ,
345345 images: [ Backtrace . Image ] ) -> Frame {
346346 if CSIsNull ( symbol) {
347347 return Frame ( captured: capturedFrame, symbol: nil )
@@ -354,7 +354,7 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
354354
355355 let location : SourceLocation ?
356356
357- if !CSIsNull( sourceInfo) {
357+ if let sourceInfo = sourceInfo , !CSIsNull( sourceInfo) {
358358 let path = CSSourceInfoGetPath ( sourceInfo) ?? " <unknown> "
359359 let line = CSSourceInfoGetLineNumber ( sourceInfo)
360360 let column = CSSourceInfoGetColumn ( sourceInfo)
@@ -395,6 +395,7 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
395395 images: [ Backtrace . Image ] ? ,
396396 sharedCacheInfo: Backtrace . SharedCacheInfo ? ,
397397 showInlineFrames: Bool ,
398+ showSourceLocations: Bool ,
398399 useSymbolCache: Bool )
399400 -> SymbolicatedBacktrace ? {
400401
@@ -454,7 +455,7 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
454455
455456 first = false
456457 }
457- } else {
458+ } else if showSourceLocations {
458459 let symbol = CSSymbolOwnerGetSymbolWithAddress ( owner, address)
459460 let sourceInfo = CSSymbolOwnerGetSourceInfoWithAddress ( owner,
460461 address)
@@ -465,6 +466,15 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
465466 symbol: symbol,
466467 sourceInfo: sourceInfo,
467468 images: theImages) )
469+ } else {
470+ let symbol = CSSymbolOwnerGetSymbolWithAddress ( owner, address)
471+
472+ frames. append ( buildFrame ( from: frame,
473+ with: owner,
474+ isInline: false ,
475+ symbol: symbol,
476+ sourceInfo: nil ,
477+ images: theImages) )
468478 }
469479 }
470480 }
@@ -505,21 +515,29 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
505515 }
506516
507517 if let theSymbol = elf32Image? . lookupSymbol ( address: relativeAddress) {
508- var location = try ? elf32Image! . sourceLocation ( for : relativeAddress )
518+ var location : SourceLocation ?
509519
510- for inline in elf32Image!. inlineCallSites ( at: relativeAddress) {
511- let fakeSymbol = Symbol ( imageIndex: imageNdx,
512- imageName: theImages [ imageNdx] . name,
513- rawName: inline. rawName ?? " <unknown> " ,
514- offset: 0 ,
515- sourceLocation: location)
516- frames. append ( Frame ( captured: frame,
517- symbol: fakeSymbol,
518- inlined: true ) )
519-
520- location = SourceLocation ( path: inline. filename,
521- line: inline. line,
522- column: inline. column)
520+ if showSourceLocations || showInlineFrames {
521+ location = try ? elf32Image!. sourceLocation ( for: relativeAddress)
522+ } else {
523+ location = nil
524+ }
525+
526+ if showInlineFrames {
527+ for inline in elf32Image!. inlineCallSites ( at: relativeAddress) {
528+ let fakeSymbol = Symbol ( imageIndex: imageNdx,
529+ imageName: theImages [ imageNdx] . name,
530+ rawName: inline. rawName ?? " <unknown> " ,
531+ offset: 0 ,
532+ sourceLocation: location)
533+ frames. append ( Frame ( captured: frame,
534+ symbol: fakeSymbol,
535+ inlined: true ) )
536+
537+ location = SourceLocation ( path: inline. filename,
538+ line: inline. line,
539+ column: inline. column)
540+ }
523541 }
524542
525543 symbol = Symbol ( imageIndex: imageNdx,
@@ -528,21 +546,29 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
528546 offset: theSymbol. offset,
529547 sourceLocation: location)
530548 } else if let theSymbol = elf64Image? . lookupSymbol ( address: relativeAddress) {
531- var location = try ? elf64Image! . sourceLocation ( for : relativeAddress )
549+ var location : SourceLocation ?
532550
533- for inline in elf64Image!. inlineCallSites ( at: relativeAddress) {
534- let fakeSymbol = Symbol ( imageIndex: imageNdx,
535- imageName: theImages [ imageNdx] . name,
536- rawName: inline. rawName ?? " <unknown> " ,
537- offset: 0 ,
538- sourceLocation: location)
539- frames. append ( Frame ( captured: frame,
540- symbol: fakeSymbol,
541- inlined: true ) )
542-
543- location = SourceLocation ( path: inline. filename,
544- line: inline. line,
545- column: inline. column)
551+ if showSourceLocations || showInlineFrames {
552+ location = try ? elf64Image!. sourceLocation ( for: relativeAddress)
553+ } else {
554+ location = nil
555+ }
556+
557+ if showInlineFrames {
558+ for inline in elf64Image!. inlineCallSites ( at: relativeAddress) {
559+ let fakeSymbol = Symbol ( imageIndex: imageNdx,
560+ imageName: theImages [ imageNdx] . name,
561+ rawName: inline. rawName ?? " <unknown> " ,
562+ offset: 0 ,
563+ sourceLocation: location)
564+ frames. append ( Frame ( captured: frame,
565+ symbol: fakeSymbol,
566+ inlined: true ) )
567+
568+ location = SourceLocation ( path: inline. filename,
569+ line: inline. line,
570+ column: inline. column)
571+ }
546572 }
547573
548574 symbol = Symbol ( imageIndex: imageNdx,
0 commit comments