2011-05-26 41 views
0

我可以檢查非結構類型,但檢查時結構,總是得到「Function "struct" not defined.」:如何在gdb中列出結構信息?

(gdb) l ngx_http_request_t 
10 
11 #include <ngx_config.h> 
12 #include <ngx_core.h> 
13 
14 
15 typedef struct ngx_http_request_s  ngx_http_request_t; 
16 typedef struct ngx_http_upstream_s ngx_http_upstream_t; 
17 typedef struct ngx_http_cache_s  ngx_http_cache_t; 
18 typedef struct ngx_http_file_cache_s ngx_http_file_cache_t; 
19 typedef struct ngx_http_log_ctx_s  ngx_http_log_ctx_t; 
(gdb) l struct ngx_http_request_s 
Function "struct" not defined. 

是否有可能在gdb?

回答

4

嘗試ptype ngx_http_request_t

+0

對於lldb,該命令是'im loo -t ngx_http_request_t'(對於ldb用戶而言,Google代表gdb) – holgac 2015-06-30 09:17:31

0

可以打印與該類型中聲明的變量的值:

ngx_http_request_t foo; 

(GDB)打印FOO

+0

如果我找不到使用該類型聲明的變量,該怎麼辦? – DriverBoy 2011-05-26 02:52:19

+0

yakatz是正確的。你需要一個這種類型的變量來檢查它。 – 2011-05-26 03:02:42

+0

可以在gdb中手動創建該類型的變量嗎? – DriverBoy 2011-05-26 03:09:07

2

l通常與一個行號用於查看一個特定的代碼行,儘管它可以和一個函數名一起使用。
由於struct不是行號或函數名稱,因此無法查看其定義。
你期待什麼類型的輸出?
看起來您確實需要struct中的數據值,這意味着您必須首先創建該類型的結構。