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-3420] lldb - "frame variable" does not return list of variables #4646

Closed
swift-ci opened this issue Dec 14, 2016 · 2 comments
Closed

[SR-3420] lldb - "frame variable" does not return list of variables #4646

swift-ci opened this issue Dec 14, 2016 · 2 comments
Labels
bug Something isn't working LLDB for Swift

Comments

@swift-ci
Copy link

Previous ID SR-3420
Radar None
Original Reporter rolivieri (JIRA User)
Type Bug
Status Closed
Resolution Invalid

Attachment: Download

Environment

As mentioned above, this issue is reproducible on both platforms, Linux (Ubuntu 14.04 LTS) and macOS (El Capitan - 10.11.6 (15G1212)).
Swift version is 3.0.2 (release)

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

md5: 47c07a7e6380c4d56a8b10b2b8832cd8

Issue Description:

Linux flavor: Ubuntu 14.04 LTS
macOS: El Capitan (10.11.6 (15G1212))
Swift flavor: Swift Release v3.0.2

Using lldb and executing “frame variable” when a breakpoint is hit does not return the list of variables that are available. Now, if “frame variable” is executed targeting a specific variable and then after that “frame variable” is executed again, then the expected list of variables is returned. To reproduce this issue, the following steps can be followed:

1) Unzip the sample project and build it on an Ubuntu 14.04 system (swift build) or a macOS (El Capitan) system.
2) Launch the lldb program and execute these commands:

$ lldb
(lldb) platform select host
Platform: host
Triple: x86_64h-apple-macosx
OS Version: 10.11.6 (15G1212)
Kernel: Darwin Kernel Version 15.6.0: Wed Nov 2 20:30:56 PDT 2016; root:xnu-3248.60.11.1.2~2/RELEASE_X86_64
Hostname: 127.0.0.1
WorkingDir: /Users/olivieri/git/swift-tst
(lldb) target create .build/debug/swift-tst
Current executable set to '.build/debug/swift-tst' (x86_64).
(lldb) b main.swift:15
Breakpoint 1: where = swift-tst`main + 106 at main.swift:15, address = 0x0000000100001c8a
(lldb) run
Process 3142 launched: '/Users/olivieri/git/swift-tst/.build/debug/swift-tst' (x86_64)
In initializer()...
Process 3142 stopped

  • thread [DON'T MERGE] Test pull request #1: tid = 0x27f97, 0x0000000100001c8a swift-tst`main + 106 at main.swift:15, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100001c8a swift-tst`main + 106 at main.swift:15
    12 var counter = 0
    13 let myObj = MyClass()
    14 while (true) {
    -> 15 counter += 1
    16 print("Hello, world!")
    17 myObj.xyz()
    18 print("counter: (counter)")
    (lldb) frame variable
    (lldb) frame variable
    (lldb) frame variable counter
    (Int) counter = 0
    (lldb) frame variable
    (Int) counter = 0
    (swift_tst.MyClass) myObj = 0x0000000101400270 (myStr = "a string")
    lldb) c
    Process 3227 resuming
    Hello, world!
    In xyz()... a string
    counter: 2
    Process 3227 stopped

  • thread [DON'T MERGE] Test pull request #1: tid = 0x2a23d, 0x0000000100001c8a swift-tst`main + 106 at main.swift:15, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100001c8a swift-tst`main + 106 at main.swift:15
    12 var counter = 0
    13 let myObj = MyClass()
    14 while (true) {
    -> 15 counter += 1
    16 print("Hello, world!")
    17 myObj.xyz()
    18 print("counter: (counter)")
    (lldb) frame variable
    (lldb) frame variable
    (lldb) frame variable counter
    (Int) counter = 2
    (lldb) frame variable
    (Int) counter = 2
    (swift_tst.MyClass) myObj = 0x0000000101106a00 (myStr = "a string")
    (lldb)

As shown above, the when we hit the breakpoint (line 15) and run "frame variable", nothing is returned. However, after running “frame variable counter” and then “frame variable”, we get the expected list of variables.

As mentioned above, this issue is reproducible on both platforms, Linux (Ubuntu 14.04 LTS) and macOS (El Capitan).

Here’s the execution on Linux:

$ lldb
(lldb) platform select host
Platform: host
Triple: x86_64-*-linux-gnu
OS Version: 4.2.0
Hostname: 127.0.0.1
WorkingDir: /home/ricardo/tmp/swift-tst
Kernel: Linux
Release: 4.2.0-42-generic
Version: #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016
(lldb) target create .build/debug/swift-tst
Current executable set to '.build/debug/swift-tst' (x86_64).
(lldb) b main.swift:15
Breakpoint 1: where = swift-tst`main + 96 at main.swift:15, address = 0x0000000000401140
(lldb) run
Process 4571 launched: '/home/ricardo/tmp/swift-tst/.build/debug/swift-tst' (x86_64)
In initializer()...
Process 4571 stopped

  • thread [DON'T MERGE] Test pull request #1: tid = 4571, 0x0000000000401140 swift-tst`main + 96 at main.swift:15, name = 'swift-tst', stop reason = breakpoint 1.1
    frame #0: 0x0000000000401140 swift-tst`main + 96 at main.swift:15
    12 var counter = 0
    13 let myObj = MyClass()
    14 while (true) {
    -> 15 counter += 1
    16 print("Hello, world!")
    17 myObj.xyz()
    18 print("counter: (counter)")
    (lldb) frame variable
    (lldb) frame variable counter
    (Int) counter = 0
    (lldb) frame variable
    (Int) counter = 0
    (swift_tst.MyClass) myObj = 0x0000000000404030 (myStr = "a string")
    (lldb) c
    Process 4571 resuming
    Hello, world!
    In xyz()... a string
    counter: 1
    Process 4571 stopped

  • thread [DON'T MERGE] Test pull request #1: tid = 4571, 0x0000000000401140 swift-tst`main + 96 at main.swift:15, name = 'swift-tst', stop reason = breakpoint 1.1
    frame #0: 0x0000000000401140 swift-tst`main + 96 at main.swift:15
    12 var counter = 0
    13 let myObj = MyClass()
    14 while (true) {
    -> 15 counter += 1
    16 print("Hello, world!")
    17 myObj.xyz()
    18 print("counter: (counter)")
    (lldb) frame variable
    (lldb) frame variable counter
    (Int) counter = 1
    (lldb) frame variable
    (Int) counter = 1
    (swift_tst.MyClass) myObj = 0x0000000000404030 (myStr = "a string")
    (lldb)

@swift-ci
Copy link
Author

swift-ci commented Mar 8, 2017

Comment by Ricardo Olivieri (JIRA)

After getting more information, this is working as designed. Hence, closing this issue. As reference, here are some details we received from folks with more experienced using the lldb debugger:

"In Swift, top-level variables aren’t actually in a frame; they’re globals. Xcode knows about this and fakes the frame for appearance purposes. If you ask LLDB for to show the globals it works:

(lldb) target variable
Global variables for /Volumes/work/gclayton/Documents/src/swiftcmd/swiftcmd/main.swift in /Volumes/work/gclayton/Documents/src/swiftcmd/build/Debug/swiftcmd:
(Int) counter = 0
(swiftcmd.MyClass) myObj = 0x00000001007031c0 (myStr = "a string")

LLDB project policy has generally been to reflect actual machine-level details accurately as one would expect from a low-level debugger. While it’s possible to do the same faking that Xcode does in it’s presentation, the team would prefer not to violate that general policy.
"

@swift-ci
Copy link
Author

swift-ci commented Mar 8, 2017

Comment by Ricardo Olivieri (JIRA)

See comment above.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 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 LLDB for Swift
Projects
None yet
Development

No branches or pull requests

1 participant