Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-6046] DWARF generated by llvm-dsymutil missing AT_location for swift variables #4503

Closed
swift-ci opened this issue Oct 3, 2017 · 5 comments
Labels
bug Something isn't working Compiler LLDB for Swift

Comments

@swift-ci
Copy link

swift-ci commented Oct 3, 2017

Previous ID SR-6046
Radar None
Original Reporter fjricci (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

macOS 10.12, Xcode 9.0.0

Additional Detail from JIRA
Votes 0
Component/s Compiler, LLDB for Swift
Labels Bug
Assignee fjricci (JIRA)
Priority Medium

md5: 09f90002185afba619fe232e126ea900

Issue Description:

Xcode's dsymutil creates DWARF locations correctly for swift variables, while llvm-dsymutil does not. This breaks debugging in swift-lldb, as variables without locations will fail to print.

$ cat /tmp/test.swift
let x = 42
print("x = (x)")

$ swiftc /tmp/test.swift  -g -Onone -sdk "/Applications/Xcode_9.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" -o /tmp/test -save-temps

$ llvm-dsymutil /tmp/test -o /tmp/test-llvm.dSYM

$ "/Applications/Xcode_9.0.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil"  /tmp/test -o /tmp/test-xcode.dSYM

$ dwarfdump /tmp/test-llvm.dSYM/Contents/Resources/DWARF/test | grep "AT_name( \"x\" )" -A5
                     AT_name( "x" )
                     AT_type( {0x00000093} ( Int ) )
                     AT_external( true )
                     AT_decl_file( "/private/tmp/test.swift" )
                     AT_decl_line( 1 )
                     AT_location( [0x0000000000000000] )

$ dwarfdump /tmp/test-xcode.dSYM/Contents/Resources/DWARF/test | grep "AT_name( \"x\" )" -A5
                     AT_name( "x" )
                     AT_type( {0x00000093} ( Int ) )
                     AT_external( true )
                     AT_decl_file( "/private/tmp/test.swift" )
                     AT_decl_line( 1 )
                     AT_location( [0x0000000100004628] )
@swift-ci
Copy link
Author

swift-ci commented Oct 3, 2017

Comment by Francis Ricci (JIRA)

Looks like the issue is an incorrect binAddr, from dsymutil -verbose:

llvm-dsymutil:

  • { sym: __Tv14test1xSi, objAddr: 0x0000000000000B10, binAddr: 0x0000000000000000, size: 0x00000000 }

xcode dsymutil:

  • { sym: __Tv14test1xSi, objAddr: 0x0000000000000B10, binAddr: 0x0000000100004628, size: 0x00000000 }

@swift-ci
Copy link
Author

swift-ci commented Oct 3, 2017

Comment by Francis Ricci (JIRA)

0x0000000100004628 looks like the start of _DATA,_common:

$ llvm-readobj /tmp/test -macho-segment -sections | grep 100004628 -B4
Section {
Index: 21
Name: __common (5F 5F 63 6F 6D 6D 6F 6E 00 00 00 00 00 00 00 00)
Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00)
Address: 0x100004628

@swift-ci
Copy link
Author

swift-ci commented Oct 3, 2017

Comment by Francis Ricci (JIRA)

Appears to be because MachOObjectFile::symbols().getFlags() is returning SymbolRef::SF_None for all of the global symbols, which means they don't end up in the global symbol mapping.

@swift-ci
Copy link
Author

swift-ci commented Oct 5, 2017

Comment by Francis Ricci (JIRA)

https://reviews.llvm.org/D38587

@swift-ci
Copy link
Author

swift-ci commented Oct 6, 2017

Comment by Francis Ricci (JIRA)

Committed as llvm revision r315082

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 7, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Compiler LLDB for Swift
Projects
None yet
Development

No branches or pull requests

1 participant