Problems printing local variables with LLDB

How do I ensure that I can print all local variables from within LLDB?

When I use LLDB, more than half the time when I try to print a local variable I get an error and “frame variable” shows the variable as being

I’m compiling all of my source with “-O0 -g”.

I have not been able to create a small test case where this happens - all of my attempts at small test cases print local variables just fine.

Here is a typical compiler invocation for my debug build:

“clang++” -x c++ -O0 -g -Warray-bounds -Wgnu-array-member-paren-init -Wno-deprecated-register -mmacosx-version-min=10.7 -fvisibility=default -std=c++11 -stdlib=libc++ -DCONFIG_VAR_COOL -DDEBUG_ASSERTS -DDEBUG_MPS_AMS_POOL -DEXPAT -DINCLUDED_FROM_CLASP -DINHERITED_FROM_SRC -DREADLINE -DUSE_BOEHM -D_ADDRESS_MODEL_64 -D_DEBUG_BUILD -D_TARGET_OS_DARWIN -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I"…/…/src" -I"…/…/src/core" -I"…/…/src/core/bin/boehm/clang-darwin-4.2.1/debug/link-static" -I"/Library/Frameworks/EPD64.framework/Versions/7.2/include/python2.7" -I"/Users/meister/Development/cando/clasp/build/" -I"/Users/meister/Development/cando/clasp/build/" -c -o “…/…/src/core/bin/boehm/clang-darwin-4.2.1/debug/link-static/evaluator.o” “…/…/src/core/

Here’s an example of what I run into all the time with LLDB:

frame #12: 0x000000010119800e clasp_boehm_d`core::SpecialForm_O::evaluate(mem::smart_ptrcore::Cons_O, mem::smart_ptrcore::Environment_O) + 542 at /Users/meister/Development/cando/clasp/src/core/…/…/src/core/
38 T_mv SpecialForm_O::evaluate( Cons_sp args, Environment_sp environment )
39 {_OF();
40 ASSERTP(this->_fptr!=NULL,“Functoid can not be NULL”);
→ 41 return (this->_fptr)(args,environment);
42 }
(lldb) frame variable
frame variable
(core::SpecialForm_O *) this = 0x00000001067d4008
(core::Cons_sp) args =

(core::Environment_sp) environment =

(lldb) print args
print args
error: Couldn’t materialize struct: size of variable args (8) disagrees with the ValueObject’s size (0)
Errored out in Execute, couldn’t PrepareToExecuteJITExpression

File a compiler bug with your source file. At -O0 you should always have access to your variables. LLDB is just showing you what the compiler tells us.

Greg Clayton

Thank you, it is helpful to have it confirmed that at “-O0” I should have access to my variables.

Unfortunately, I’ve had this problem since I switched to LLDB two years ago and I only see it (always see it) when I’m debugging my full application (165 source files, about 150,000 lines of code). So far, my several attempts at developing small test cases have been fruitless - small examples debug fine and all variables are visible.



If you don't mind letting somebody see the code in one of your bad source files, then you can preprocess a source file containing a function that shows the problem, and that plus "what function shows the missing variable" what variable was missing, and where you were in the code (line number is fine) should be enough for the compiler folks to reproduce and diagnose the problem. They don't need to build your whole app, just build that source file & look at the resultant debug info.



Thanks! I just uploaded a bug report with the info that you asked for.
It is at: