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-7565] LLDB print fails to unmask extra inhabitants in enums #4371
Comments
jingham@apple.com (JIRA User), @dcci, is there a dup of this? |
Looking! |
@swift-ci create |
This reproduces on top-of-tree lldb. (lldb) p y
(blah.A) $R2 = {
variant = y {
y = 0x4000000100a00350 (yy = Swift.Int @ )
}
}
(lldb) frame var y
(blah.A) y = {
variant = y {
y = 0x4000000100a00350 (yy = Swift.Int @ )
}
} It's not `expr` being broken (only), as this also shows up in the `frame var` path. I'll investigate further. Thanks for your report! |
(lldb) frame var --raw y
(blah.A) y = {
variant = y {
x = 0x4000000100a00240 {
xx = {
_value = <read memory from 0x4000000100a00250 failed (0 of 8 bytes read)>
}
}
y = 0x4000000100a00240 {...}
}
} And `log types`: ADT-style enum - inspecting data to find enum case for type Variant
tag_bits = 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0011
current_payload = 0000 1011 0000 0000 0000 0011 0000 0000 1000 0000 0000 0000 0000 0000 0000 0010
discriminator value of 1 acceptable, case y matched
C-style enum - inspecting data to find enum case for type Variant
m_nopayload_elems_bitmask = 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111
current_payload = 0000 1011 0000 0000 0000 0011 0000 0000 1000 0000 0000 0000 0000 0000 0000 0010
masked current_payload = 0000 1011 0000 0000 0000 0011 0000 0000 1000 0000 0000 0000 0000 0000 0000 0010
bitmask search failed
ADT-style enum - inspecting data to find enum case for type Variant
tag_bits = 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0011
current_payload = 0000 1011 0000 0000 0000 0011 0000 0000 1000 0000 0000 0000 0000 0000 0000 0010
discriminator value of 1 acceptable, case y matched
[MemoryReader] asked to read 8 bytes at address 0x4000000100c000d0
[MemoryReader] memory read returned fewer bytes than asked for
could not read heap metadata for object at 4611686022734938320: an unknown failure occurred |
This is going to be tricky to fix for the general case, I had a discussion with Slava about it. Possible solutions:
Currently mirrors and RemoteAST don’t support enums. So, this turns out to be a fair bif ot work. |
Fixed in: apple/swift-lldb#1165 |
Attachment: Download
Environment
Apple Swift version 4.1.1 (swiftlang-902.0.50 clang-902.0.39.1)
Xcode Version 9.3 (9E145)
macOS 10.13.4 (17E202)
Additional Detail from JIRA
md5: d1b8968f72279b4b25fc63113511b141
Issue Description:
See attached file.
A type contains a non-generic multipayload enum, two of which have associated values. On Darwin, this enum lays out its discriminator using spare bits. The printer of LLDB doesn't unmask these properly, yielding invalid subsequent children.
If you breakpoint where indicated in the attached file, and `p x` and `p y`, you'll see this:
(lldb) p x
(Debug.A) $R0 = {
{{ variant = x {}}
{{ x = 0x0000000100e4a950 (xx = 42)}}
{{ }}}
{{}}}
(lldb) p y
(Debug.A) $R1 = {
{{ variant = y {}}
{{ y = 0x4000000100e4c580 (yy = Swift.Int @ )}}
{{ }}}
{{}}}
Notice "0x4" at the start of `y` and how it can't read the memory for `yy`.
The text was updated successfully, but these errors were encountered: