How do I show what fields a struct has in GDB?

前端 未结 7 1540
不知归路
不知归路 2020-12-22 23:31

I came upon a struct (called ngx_http_variable_value_t) in my GDB (debugger) session and I would like to print what fields it has in the console.

Is tha

7条回答
  •  猫巷女王i
    2020-12-23 00:15

    set print pretty on

    This option also gives newlines and indentation for p *my_struct_pointer.

    Which do you prefer:

    $2 = {path = {mnt = 0xffff8800070ce1a0, dentry = 0xffff880006850600},last = {{{hash = 3537271320, len = 2}, hash_len = 12127205912}, name = 0xffff88000659501c "../b.out"}
    

    or:

    $3 = {
      path = {
        mnt = 0xffff8800070ce1a0, 
        dentry = 0xffff880006850600
      }, 
      last = {
        {
          {
            hash = 3537271320, 
            len = 2
          }, 
          hash_len = 12127205912
        }, 
        name = 0xffff88000659501c "../b.out"
      },
    }
    

提交回复
热议问题