[Lldb-commits] [lldb] [lldb] Lookup static const members in FindGlobalVariables (PR #111859)
Ilia Kuklin via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 16 12:38:45 PDT 2024
kuilpd wrote:
> I think we may want to implement this in a slightly different matter: find the unique definition DIE for the given type (we use that concept when parsing types) and then search for child inside that -- instead of searching through all (possibly one per CU) definitions of that type.
I am a bit confused here, don't we need to look through all the debug information to find the type anyway? Could you please point me to the code with type parsing you are referring to?
> However, before we go down that path, I want to note that something like what you want is already possible using the python API:
>
> ```
> (lldb) target var Vars::static_constexpr
> error: can't find global variable 'Vars::static_constexpr'
> (lldb) script lldb.target.FindFirstType("Vars").GetStaticFieldWithName("static_constexpr").GetConstantValue(lldb.target)
> (const int) static_constexpr = 2
> ```
The custom formatter's expression is an example of how I found this bug, but I think it should be fixed regardless, this function can be used from API in other circumstances.
> It would still be nice if the "target variable" command worked as well, but:
>
> * I'm a little less concerned about that given that it works for dwarf v5 (clang default)
>
> * you should be using the python API (instead of expression evaluation) in the data formatter anyway, as it's faster and more reliable
Would checking the DWARF version and doing the search only on v4 and earlier improve the situation somewhat?
https://github.com/llvm/llvm-project/pull/111859
More information about the lldb-commits
mailing list