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-9092] Could Not Resolve Type during swift Foundation debugging #3603
Comments
@swift-ci create |
Whatever the resolution of this, this seems pretty basic. Could we get an integration test for this? |
Sure. |
Comment by Jim Ingham (JIRA) It isn't a matter of ADDING tests. We have lots of regression tests that create a swift module which imports Foundation, and then examines Foundation derived objects. It's just that all those tests are Darwin only at present. What Michael is really asking for - though he didn't know it 😉 - was for us to go sort out which of our Foundation tests run on Linux, and turn those tests on... |
I'll try to take a look at this as soon as I can, but levivic (JIRA User) if you feel really adventurous, you might consider trying to fix this yourself, and I can probably give you some guidance (if you're up to it). |
Comment by Leo Z (JIRA) @dcci I don't mind looking into it. But at this moment i have no clue at all on how to fix this, please advise. thx |
The first thing we might consider looking at is the type logs in ldlb. log enable lldb types -f ~/lldb-log.txt and then attach ~/lldb-log.txt to this SR, so we can have at least a clue of what's failing, and go from there. |
(type that, then execute the commands that are failing, that is). |
Comment by Leo Z (JIRA) lldb-log.txt see the log file attached. |
The log contains the culprit. lldb ((SwiftASTContext*)0x3ff6e5c6370)->GetTypeFromMangledTypename('$S10Foundation16NSDateComponentsCD')
lldb ((SwiftASTContext*)0x3ff6e5c6370)->GetTypeFromMangledTypename('$S10Foundation16NSDateComponentsCD') -- not cached, searching
lldb ((SwiftASTContext*)0x3ff6e5c6370)->GetTypeFromMangledTypename('$S10Foundation16NSDateComponentsCD') -- error: type for symbolname '' was not found |
What I would start from is setting a breakpoint in |
Comment by Leo Z (JIRA) @dcci I have used gdb to debug swift compiler before. But these errors are from lldb. Suppose I have the problematic code example.swift as import Foundation
let c1 = NSDateComponents()
let c2 = NSDateComponents()
c2.calendar = c1.calendar
let c1a = c1.calendar as Any
print(c1a)
let c2a = c2.calendar as Any
print(c2a) And compile it to executable example. Then i try to debug lldb using gdb by gdb lldb, followed by r example and then r. However, it never hits the breakpoint SwiftASTContext::GetTypeFromMangledTypename. Another question, as you mentioned debug `swiftc`, how can i debug `lldb` and `swiftc` at the same time? |
You don't need to debug lldb and swiftc at the same time. Just attach to lldb. |
If you're not able to hit that breakpoint, still, let me know and I'll take a look. Please note that you need a debug build both of the compiler and the debugger to be effective (i.e. you need to run ./build-script -d -lldb). |
Comment by Leo Z (JIRA) Following the step provided above, i still don't hit the breakpoint. Both the compiler and debugger are built in debug mode. |
OK, I'll try to take a look at this myself today. I'll let you know, and thanks for your attempts! |
I can't reproduce this on Linux x86/64. |
Comment by Leo Z (JIRA) @dcciCan you provide your building steps? |
./swift/utils/build-script --foundation --libdispatch --release --lldb --test --build-ninja -- --reconfigure --skip-test-cmark --skip-test-swift --skip-build-benchmarks --skip-test-foundation=1 I'm building on ubuntu 16.04 (x86_64) |
I can't reproduce this either: (lldb) n
|
How did you build swift / which version are you using? For reference, I tried this on master using
|
Comment by Leo Z (JIRA) ./utils/build-script -j 2 -d --lldb --foundation --xctest --llbuild --swiftpm --libdispatch -- --verbose-build=1 --install-swift --install-foundation --install-xctest --install-llbuild --install-swiftpm --install-libdispatch --install-lldb --swift-install-components='autolink-driver;compiler;clang-builtin-headers;stdlib;sdk-overlay;license' --build-swift-static-stdlib=1 --install-prefix=/usr --install-destdir=$MYDESTDIR This is what i have been using for the build. And my version is 4.2. |
I see. It's totally possible that this is broken in swift-4.2-branch. There have been a lot of improvements in that area since. Does it work for you on stable / swift-5.0-branch? |
Comment by Leo Z (JIRA) I haven't tried that since we are not working on the new branch at this moment. But thanks for mentioning it @adrian-prantl |
Attachment: Download
Environment
Linux
Additional Detail from JIRA
md5: d7450fcc100c91a81b47f645eb0f3fe4
Issue Description:
Hi guys, i am trying to debug swift-corelibs-foundatin with lldb in Linux. However, it keeps giving me "<could not resolve type>" when I try to access a variable. Here is my testing example:
I have set breakpoint at `c2.calendar = c1.calendar`. When i step in, at some point it reaches `NSCalendar.swift` under Foundation as follows:
Then when i tried to use `fr v` to access variables, the debugger would show me `could not resolve type`. It looks like lldb won't print any variables when it gets into the Foundation code. Any ideas how to fix this?
The text was updated successfully, but these errors were encountered: