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-9928] lldb Xcode 10.2 regression: lldb does not show source file when using target.source-map with breakpoints #4608

Open
swift-ci opened this issue Feb 14, 2019 · 9 comments
Labels
bug Something isn't working LLDB for Swift

Comments

@swift-ci
Copy link

Previous ID SR-9928
Radar rdar://47642498
Original Reporter Davidee (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 10.2 and Swift Development Snapshot 2018-12-18 (a) Toolchain, possibly due to

apple/swift-lldb@327df73#diff-d2637d31d2f0d43dbf858b42da33f62d?

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug
Assignee None
Priority Medium

md5: cc3d12117e1dd112d037d37f12268568

Issue Description:

As of Xcode 10.2, lldb only shows assembly for files compiled with `-fdebug-prefix-map=$(PROJECT_DIR)=.` (which makes debug info relative to the source root) which are then remapped to the proper PROJECT_DIR via ~/.lldbinit's `target.source-map` setting (e.g. `settings set target.source-map "./" "/SOURCE_ROOT/"`).

With Xcode 10, the source file properly shows up instead of assembly (e.g. `main.m` in the attached Xcode project).

Steps to Reproduce:

1) Unzip attached Xcodeproj

2) Modify your ~/.lldbinit to be `settings set target.source-map "./" "<path to TargetSourceMapIssue folder>/"`

3) Open Xcodeproj with Xcode 10.2 and set a breakpoint on main.m:21 via the Xcode UI.

4) Run.

5) Note that the breakpoint hits but the source file does not resolve - only assembly is shown.

Other information:

It looks as if target.source-map somehow is being applied to flags:

In ~/.lldbinit:

settings set target.source-map "./" "/SOURCE_ROOT/" (after `log enable lldb types`)

In Xcode's LLDB (after `log enable lldb types`):

```

remapped -iquote/BUILD_ROOT -> /SOURCE_ROOT-iquote/BUILD_ROOT
remapped -O0 -> /SOURCE_ROOT-O0
remapped -DDEBUG=1 -> /SOURCE_ROOT-DDEBUG=1
remapped -fstack-protector -> /SOURCE_ROOT-fstack-protector
remapped -fstack-protector-all -> /SOURCE_ROOT-fstack-protector-all
remapped -fdebug-prefix-map=/BUILD_ROOT=. -> /SOURCE_ROOT-fdebug-prefix-map=/BUILD_ROOT=.
remapped -iquote/BUILD_ROOT/folder -> /SOURCE_ROOT-iquote/BUILD_ROOT/folder
remapped -iquote/BUILD_ROOT -> /SOURCE_ROOT-iquote/BUILD_ROOT
remapped -O0 -> /SOURCE_ROOT-O0
remapped -fstack-protector -> /SOURCE_ROOT-fstack-protector
remapped -fstack-protector-all -> /SOURCE_ROOT-fstack-protector-all
remapped -fdebug-prefix-map=/BUILD_ROOT=. -> /SOURCE_ROOT-fdebug-prefix-map=/BUILD_ROOT=.
((Target*)0x7f8c686dbe00)->GetSwiftASTContext() returning NULL - couldn't create a ClangImporter

```

@belkadan
Copy link

This isn't really the place to report LLDB bugs that aren't about Swift, but I'll tag one of them anyway: @adrian-prantl

@adrian-prantl
Copy link
Member

Should be fixed by apple/swift-lldb#1302

@adrian-prantl
Copy link
Member

FYI @belkadan this is actually a Swift bug although the description mentions a .m file.

@belkadan
Copy link

Ah, sorry for being overzealous, then, David!

@swift-ci
Copy link
Author

swift-ci commented Mar 6, 2019

Comment by David Goldman (JIRA)

Still showing assembly with Xcode 10.2 beta 4

@adrian-prantl
Copy link
Member

What does the types log say?

@swift-ci
Copy link
Author

swift-ci commented Mar 6, 2019

Comment by David Goldman (JIRA)

Perhaps there were two different errors? I don't see the remapping in the types log anymore, but I do still see assembly instead of the source file for the example project.

@swift-ci
Copy link
Author

Comment by David Goldman (JIRA)

@adrian-prantl My bad, it looks as if I was using the wrong version of Xcode. I'm no longer seeing issues with breakpoints with Xcode 10.2 beta 4, but I'm still seeing issues with `po <variable>`, I believe you might have missed the `-fmodule-map-file=` flag in your change.

@swift-ci
Copy link
Author

Comment by Nicholas Levin (JIRA)

I can't recreate the po issues with the sample project that was given.

~/.lldbinit contents:

settings set target.source-map "./" "/Users/nglevin/Downloads/TargetSourceMapIssue"

LLDB output:

(lldb) p argc
(int) $0 = 1
(lldb) expr @import Foundation
(lldb) po [NSMessagePortNameServer sharedInstance]
<NSMessagePortNameServer: 0x100700b80>``(lldb)

I think the specific issue outlined by the sample project has been fully resolved.

Working with David right now to see if an -fmodulemap-file based sample Xcode project can be made for a new Xcode 10.2/Swift 5 bug.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LLDB for Swift
Projects
None yet
Development

No branches or pull requests

3 participants