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

LLDB typedefs are too lazy #91186

Open
labath opened this issue May 6, 2024 · 1 comment
Open

LLDB typedefs are too lazy #91186

labath opened this issue May 6, 2024 · 1 comment
Labels

Comments

@labath
Copy link
Collaborator

labath commented May 6, 2024

$ cat /tmp/a.cc
struct X {
  typedef int InX;
};

X a;
X::InX b;

int main() {
  return b;
}
$ g++ /tmp/a.cc -g -o /tmp/a.out
$ bin/lldb /tmp/a.out
(lldb) target create "/tmp/a.out"
Current executable set to '/tmp/a.out' (x86_64).
(lldb) expr -- X::InX a; a
error: <user expression 0>:1:4: no member named 'InX' in 'X'
    1 | X::InX a; a
      | ~~~^
(lldb) expr b
(X::InX) $0 = 0
(lldb) expr -- X::InX a; a
(X::InX) $1 = 0

This happens because lldb does not construct the clang ast type (only lldb_private::Type) when parsing the dwarf. The clang ast is contructed only when something references the lldb_private::Type -- which can sometimes be too late. Also see #90958 for another issue with lazy typedef parsing (however, unlike this issue, I know how to work around the other one).

labath added a commit to labath/llvm-project that referenced this issue May 6, 2024
The implementation is straight-forward, but comes with a big disclaimer.
See llvm#91186 for details.
@llvmbot
Copy link
Member

llvmbot commented May 6, 2024

@llvm/issue-subscribers-lldb

Author: Pavel Labath (labath)

``` $ cat /tmp/a.cc struct X { typedef int InX; };

X a;
X::InX b;

int main() {
return b;
}
$ g++ /tmp/a.cc -g -o /tmp/a.out
$ bin/lldb /tmp/a.out
(lldb) target create "/tmp/a.out"
Current executable set to '/tmp/a.out' (x86_64).
(lldb) expr -- X::InX a; a
error: <user expression 0>:1:4: no member named 'InX' in 'X'
1 | X::InX a; a
| ~~~^
(lldb) expr b
(X::InX) $0 = 0
(lldb) expr -- X::InX a; a
(X::InX) $1 = 0


This happens because lldb does not construct the clang ast type (only lldb_private::Type) when parsing the dwarf. The clang ast is contructed only when something references the lldb_private::Type -- which can sometimes be too late. Also see #<!-- -->90958 for another issue with lazy typedef parsing (however, unlike this issue, I know how to work around the other one).
</details>

labath added a commit that referenced this issue May 9, 2024
…91189)

The implementation is straight-forward, but comes with a big disclaimer.
See #91186 for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants