简体   繁体   中英

lldb debugger cannot print structure contents

I've compiled a small program that uses asl_log, and when running in lldb, it failed to print the contents of a global variable from type 'aslclient', although i compiled in debug mode ('-g' flag).

perhaps you can tell me if this is related to the following bug, and how to workaround this problem

[lldb-dev] [Bug 16191] New: LLDB fails to evaluate expressions that 
dereference a struct when inferior is built with recent Clang

the input from debugger :

(lldb) print log_asl_client
(aslclient) $5 = 0x0000000100200000
(lldb) print *log_asl_client
(lldb) print *log_asl_client
error: incomplete type '__asl_object_s' where a complete type is required
note: forward declaration of '__asl_object_s'
error: 1 errors parsing expression

my compilation command :

clang -g -c -Wall -DDEBUG=1 example.c -o example.o
clang  example.o -o example

the code :

aslclient log_asl_client;
...
int main(int argc, char * const *argv) {
...
log_asl_client = asl_open(identity, facility, client_opts);
... 
--> at this point i initiate the print command in debug mode.

the version i use :

clang --version
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

thanks,

The debug information has a record for the forward reference to __asl_object_s , but not for the full type. This isn't entirely surprising in this particular case, since the only appearance of __asl_object_s in the public header files on OS X is:

typedef struct __asl_object_s *asl_object_t;

so this is an opaque reference to the struct, and there isn't a real definition anywhere. Presumably __asl_object_s is a placeholder and the pointer gets cast to whatever it really is when it is used.

Anyway, the debugger isn't refusing to show you something, there's actually nothing there to see...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM