2015-08-31 26 views
0

我已經編譯了一個使用asl_log的小程序,並且在lldb中運行時,雖然我在調試模式下編譯(''),但它無法打印來自'aslclient'類型的全局變量的內容。 -g'標誌)。lldb調試器不能打印結構內容

也許你能告訴我,這是關係到下面的錯誤,以及如何解決這一問題

[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 

感謝,

回答

1

調試信息具有正向參考__asl_object_s的記錄,而不是完整的類型。這不是在該特定情況下完全出乎意料,因爲在__asl_object_s OS X上的公共頭文件的唯一外觀:

typedef struct __asl_object_s *asl_object_t; 

,所以這是一個不透明的參考結構,並且不存在真正的定義隨處據推測,__asl_object_s是一個佔位符,指針被轉換爲它在使用時的真實屬性。

無論如何,調試器不會拒絕給你展示一些東西,實際上沒有什麼可以看到的...