DriverBoy
DriverBoy

Reputation: 997

How to list struct information in gdb?

I can check non-struct types,but when checking struct,always getting a "Function "struct" not defined.":

(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.

Is it possible in gdb?

Upvotes: 1

Views: 3468

Answers (3)

Employed Russian
Employed Russian

Reputation: 213516

Try ptype ngx_http_request_t

Upvotes: 5

yakatz
yakatz

Reputation: 2282

l is usually used with a line number to view a particular line of code, although it can be used with a function name.
Because struct is not a line number or a function name, you can not view its definition.
What type of output are you expecting?
It looks like you really want the values of the data in the struct, meaning you have to create a struct of that type first.

Upvotes: 2

Richard Pennington
Richard Pennington

Reputation: 19965

You can print the value of the variable declared with that type:

ngx_http_request_t foo;

(gdb) print foo

Upvotes: 0

Related Questions