When print a value in lldb, I got the following error
error: no member named 'rec' in namespace '$__lldb_local_vars'
My code was compiled by -g. Why is lldb not able to print values?
What is LLDB? A low-level debugger (LLDB) is the default debugger used in Xcode and is part of the LLVM project. LLDB replaced GDB in XCode 5 and has several advantages, such as performance and scriptability.
LLDB is improving on Linux. Linux is nearing feature completeness with Darwin to debug x86_64, i386, ARM, AArch64, IBM POWER (ppc64), IBM Z (s390x), and MIPS64 programs. For more details, see the Features by OS section below.
LLDB supports debugging of programs written in C, Objective-C, and C++. The Swift community maintains a version which adds support for the language. It is known to work on macOS, Linux, FreeBSD, NetBSD and Windows, and supports i386, x86-64, and ARM instruction sets. LLDB is the default debugger for Xcode 5 and later.
$__lldb_local_vars
was a bit of a hack to work around some problems in the name lookup affordances provided by clang for lldb's expression parser. The hack tries to promote local variables to the head of name lookup (ahead of locally visible class and namespace lookups) by injecting local variables into a namespace that is then imported into the expression. This has some performance issues, and it is also fragile since it requires realizing all visible locals. We did a bunch of work to remove locals that we can tell we won't be able to realize, but it still didn't work very reliably.
This hack is off by default in all the lldb's that Apple releases, and is controlled by setting:
(lldb) set list target.experimental.inject-local-vars
target.experimental.inject-local-vars -- If true, inject local variables explicitly into the
expression text. This will fix symbol resolution
when there are name collisions between ivars and
local variables. But it can make expressions run
much more slowly.
You can use settings show
to show the current value of this setting, and settings set
to change it.
If you can make available an example showing this failure, it would be helpful to file a bug with the llvm bug reporter: https://bugs.llvm.org.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With