2011-05-26 36 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中的数据值,这意味着您必须首先创建该类型的结构。