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

lldb debugger cannot print structure contents

本文关键字:结构 打印 调试器 LLDB      更新时间:2023-10-16

我编译了一个使用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) $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
我的编译命令:
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的公共头文件中的唯一出现是:

typedef struct __asl_object_s *asl_object_t;

所以这是对结构体的不透明引用,没有真正的定义。据推测,__asl_object_s是一个占位符,指针在使用时被强制转换为它实际是什么。

无论如何,调试器并没有拒绝显示一些东西,实际上那里没有什么可看的…