diff --git a/docs/CompactBacktraceFormat.md b/docs/CompactBacktraceFormat.md index c527cfbb266..eef81c3a889 100644 --- a/docs/CompactBacktraceFormat.md +++ b/docs/CompactBacktraceFormat.md @@ -57,6 +57,10 @@ The following instructions are currently defined | `1000xxxx` | `rep` | Repeat the previous frame | | `1xxxxxxx` | reserved | Reserved for future expansion | +If the bit labelled `a` is set, it means that the address computation +is absolute rather than being relative to the previously computed +address. + ### `end`/`trunc` #### Encoding diff --git a/stdlib/public/RuntimeModule/Address.swift b/stdlib/public/RuntimeModule/Address.swift index 5f2f22c8531..24a8a0a7557 100644 --- a/stdlib/public/RuntimeModule/Address.swift +++ b/stdlib/public/RuntimeModule/Address.swift @@ -148,13 +148,13 @@ extension Backtrace.Address { return T(0) case let .sixteenBit(addr): guard T.bitWidth >= 16 else { return nil } - return T(addr) + return T(truncatingIfNeeded: addr) case let .thirtyTwoBit(addr): guard T.bitWidth >= 32 else { return nil } - return T(addr) + return T(truncatingIfNeeded: addr) case let .sixtyFourBit(addr): guard T.bitWidth >= 64 else { return nil } - return T(addr) + return T(truncatingIfNeeded: addr) } } } @@ -204,11 +204,11 @@ extension Backtrace.Address { public init?(_ value: T) { switch T.bitWidth { case 16: - self.init(UInt16(value)) + self.init(UInt16(truncatingIfNeeded: value)) case 32: - self.init(UInt32(value)) + self.init(UInt32(truncatingIfNeeded: value)) case 64: - self.init(UInt64(value)) + self.init(UInt64(truncatingIfNeeded: value)) default: return nil } diff --git a/stdlib/public/RuntimeModule/CompactImageMap.swift b/stdlib/public/RuntimeModule/CompactImageMap.swift index 74a50aab817..f76233ebbdd 100644 --- a/stdlib/public/RuntimeModule/CompactImageMap.swift +++ b/stdlib/public/RuntimeModule/CompactImageMap.swift @@ -16,6 +16,9 @@ import Swift +private let slash = UInt8(ascii: "/") +private let backslash = UInt8(ascii: "\\") + @_spi(Internal) public enum CompactImageMapFormat { @@ -58,7 +61,7 @@ public enum CompactImageMapFormat { while pos < end { let ch = str[pos] - if pos > base && (ch == 0x2f || ch == 0x5c) { + if pos > base && (ch == slash || ch == backslash) { let range = base.. stringBase! && (char == 0x2f || char == 0x5c) { + if base + n > stringBase! && (char == slash + || char == backslash) { let prefix = String(decoding: resultBytes[stringBase!...passRetained(ElfImageCache()) - pthread_setspecific(key!, cache.toOpaque()) + pthread_setspecific(key, cache.toOpaque()) return cache.takeUnretainedValue() } let cache = Unmanaged.fromOpaque(rawPtr) diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt index 7c9a8532913..407382ff6b3 100644 --- a/stdlib/public/runtime/CMakeLists.txt +++ b/stdlib/public/runtime/CMakeLists.txt @@ -144,6 +144,10 @@ foreach(sdk ${SWIFT_SDKS}) endif() endforeach() +# In modern CMake, we would be able to use the previous name `swiftRuntime` +# without clashing with the `Runtime` module, but the current build system +# is architected in such a way that we had to rename this to `swiftRuntimeCore` +# in order to avoid a clash with the new Swift module. add_swift_target_library(swiftRuntimeCore OBJECT_LIBRARY ${swift_runtime_sources} ${swift_runtime_objc_sources} @@ -323,4 +327,3 @@ if(static_binary_lnk_file_list) add_dependencies(stdlib ${static_binary_lnk_file_list}) add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list}) endif() -