From 2300577b5640efb84e51255e14566784cb68fa32 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Tue, 21 Jan 2025 19:03:51 +0000 Subject: [PATCH] [Backtracing] Fix symbol lookup on Linux. Also removed a spurious `print()` that got left in by accident, and disabled the `CodableBacktrace.swift` test on Linux since we need Foundation and we don't have it there. rdar://124913332 --- stdlib/public/RuntimeModule/Backtrace.swift | 2 -- stdlib/public/RuntimeModule/Elf.swift | 4 ++-- test/Backtracing/CodableBacktrace.swift | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/stdlib/public/RuntimeModule/Backtrace.swift b/stdlib/public/RuntimeModule/Backtrace.swift index 7a26e693b40..b79dc4bc871 100644 --- a/stdlib/public/RuntimeModule/Backtrace.swift +++ b/stdlib/public/RuntimeModule/Backtrace.swift @@ -415,8 +415,6 @@ extension Backtrace { memoryReader: memoryReader) if let limit = limit { - print("limit = \(limit), offset = \(offset), top = \(top)") - let limited = LimitSequence(unwinder, limit: limit, offset: offset, diff --git a/stdlib/public/RuntimeModule/Elf.swift b/stdlib/public/RuntimeModule/Elf.swift index c603d3d92a6..d2501b33d25 100644 --- a/stdlib/public/RuntimeModule/Elf.swift +++ b/stdlib/public/RuntimeModule/Elf.swift @@ -1156,13 +1156,13 @@ struct ElfSymbolTable: ElfSymbolTableProtocol { nextValue = _symbols[mid + 1].value } - if symbol.value <= address && nextValue >= address { + if symbol.value <= address && nextValue > address { var ndx = mid while ndx > 0 && _symbols[ndx - 1].value == address { ndx -= 1 } return _symbols[ndx] - } else if symbol.value < address { + } else if symbol.value <= address { min = mid + 1 } else if symbol.value > address { max = mid diff --git a/test/Backtracing/CodableBacktrace.swift b/test/Backtracing/CodableBacktrace.swift index daef88a1c51..47e4a4ba790 100644 --- a/test/Backtracing/CodableBacktrace.swift +++ b/test/Backtracing/CodableBacktrace.swift @@ -5,7 +5,7 @@ // REQUIRES: executable_test // REQUIRES: backtracing -// REQUIRES: OS=macosx || OS=linux-gnu +// REQUIRES: OS=macosx // UNSUPPORTED: use_os_stdlib // UNSUPPORTED: back_deployment_runtime