Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Macros/Sources/SwiftMacros/DebugDescriptionMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,17 @@ extension _DebugDescriptionPropertyMacro: PeerMacro {

// Serialize the type summary into a global record, in a custom section, for LLDB to load.
let decl: DeclSyntax = """
#if !os(Windows)
#if os(Linux)
@_section(".lldbsummaries")
#elseif os(Windows)
@_section(".lldbsummaries")
#else
@_section("__TEXT,__lldbsummaries")
#endif
@_used
static let _lldb_summary = (
\(raw: encodeTypeSummaryRecord(typeIdentifier, summaryString))
)
#endif
"""

return [decl]
Expand Down
9 changes: 7 additions & 2 deletions test/Macros/DebugDescription/linkage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
struct MyStruct: CustomDebugStringConvertible {
var debugDescription: String { "thirty" }
}
// CHECK: #if !os(Windows)
// CHECK: #if os(Linux)
// CHECK: @_section(".lldbsummaries")
// CHECK: #elseif os(Windows)
// CHECK: @_section(".lldbsummaries")
// CHECK: #else
// CHECK: @_section("__TEXT,__lldbsummaries")
// CHECK: #endif
// CHECK: @_used
// CHECK: static let _lldb_summary = (
// CHECK: /* version */ 1 as UInt8,
// CHECK: /* record size */ 23 as UInt8,
// CHECK: /* "main.MyStruct" */ 14 as UInt8, 109 as UInt8, 97 as UInt8, 105 as UInt8, 110 as UInt8, 46 as UInt8, 77 as UInt8, 121 as UInt8, 83 as UInt8, 116 as UInt8, 114 as UInt8, 117 as UInt8, 99 as UInt8, 116 as UInt8, 0 as UInt8,
// CHECK: /* "thirty" */ 7 as UInt8, 116 as UInt8, 104 as UInt8, 105 as UInt8, 114 as UInt8, 116 as UInt8, 121 as UInt8, 0 as UInt8
// CHECK: )
// CHECK: #endif