[cfe-users] why is lldb unable to debug any gcc -O$n compiled code, what can be done about it
Jason Vas Dias via cfe-users
cfe-users at lists.llvm.org
Thu Jan 31 03:18:53 PST 2019
Good day -
I have to use a MacOSX 10.14.3 (mojave) laptop for work,
and am having issues adjusting after having used mostly
Linux and UNIX over the past 20 years.
Chief among them is the inability to debug any code I build -
which usually is optimized in some way with a -O[0-3] gcc
flag. I use mainly MacPorts' GCC 8.2.0 .
With any -O optimization flag given to gcc / g++ ,
{ -O , -O1, -O2, -O3 ...}, and any '-g' flag (-g , -g3)
any attempt to examine data in a debugged process
with lldb results in the lldb error :
" (lldb) p any_symbol
Warning: hit breakpoint while running function, skipping commands and
conditions to prevent recursion.warning: could not execute support
code to read Objective-C class data in the process. This may reduce
the quality of type information available.
Process 19062 exited with status = 0 (0x00000000)
error: Couldn't materialize: couldn't get the value of any_symbol:
extracting data from value failed
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
"
If ALL code in the process is compiled without ANY -O flags,
then lldb is able to set breakpoints and examine data OK.
But this is a very unrealistic - most code should be and is
compiled with optimizations. Optimized code is very
different than non-optimized - an optimized version
of a program is a different program . I need to be
able to debug core dumps from other users, and
since they invariably contain optimized code, lldb
is of no use for this purpose.
So, I am trying to set up a Linux VM to do most of
my development on, purely because of this issue -
the MacOSX laptop is effectively useless to me
because of this issue.
GDB also may have some issues with debugging
heavily optimized code, it may get things wrong
sometimes for -O3 compiled code, but it least
it gets much farther than lldb , which cannot
get off the ground at all with an optimized process.
Is there any workaround for this issue / any
special debugging format I could use to
get lldb on MacOSX to be able to debug
optimized code ?
Any advice much appreciated.
Thanks & Best Regards,
Jason Vas Dias
More information about the cfe-users
mailing list