Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lldb cannot print values in debug code

Tags:

lldb

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?

like image 283
Joe C Avatar asked Apr 11 '17 05:04

Joe C


People also ask

What does LLDB mean in Xcode?

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.

Does LLDB work on Linux?

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.

What is LLDB Linux?

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.


1 Answers

$__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.

like image 164
Jim Ingham Avatar answered Dec 23 '22 10:12

Jim Ingham