lldb 调试器无法打印结构内容

lldb debugger cannot print structure contents

我编译了一个使用 asl_log 的小程序,当在 lldb 中使用 运行 时,它无法打印 'aslclient' 类型的全局变量的内容,尽管我在调试模式下编译('-g' 标志)。

也许你可以告诉我这是否与以下错误有关,以及如何解决这个问题

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

来自调试器的输入:

(lldb) print log_asl_client
(aslclient)  = 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

我的编译命令:

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

代码:

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.

我使用的版本:

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

谢谢,

调试信息中有前向引用__asl_object_s的记录,但没有完整类型的记录。在这种特殊情况下,这并不完全令人惊讶,因为 __asl_object_s 在 OS X 上的 public 头文件中的唯一出现是:

typedef struct __asl_object_s *asl_object_t;

所以这是对结构的不透明引用,并且在任何地方都没有真正的定义。大概 __asl_object_s 是一个占位符,指针在使用时被强制转换为它的实际位置。

无论如何,调试器并没有拒绝向您展示一些东西,实际上没有什么可看的...