如何使用GDB提取结构成员的值

时间:2018-09-06 12:20:56

标签: linux linux-kernel gdb

假设我有一个内核结构struct thread_info,我想使用GDB从thread_info结构中获取preempt_count变量的值。

我可以通过取消引用thread_info

来获取以下信息
(gdb) p (struct thread_info *)0x8785A000

{task = 0x70617261, exec_domain = 0x6d657465, flags = 1920139264, tp_value = 4294967295, cpu = 4294967295, preempt_count = -1, addr_limit = {seg = 4294967295}, restart_block = {fn = 0xffffffff, {
      futex = {uaddr = 0xffffffff, val = 4294967295, flags = 4294967295, bitset = 4294967295, time = 18446744073709551615, uaddr2 = 0xffffffff}, nanosleep = {clockid = -1, rmtp = 0xffffffff,
        expires = 18446744073709551615}, poll = {ufds = 0xffffffff, nfds = -1, has_timeout = -1, tv_sec = 4294967295, tv_nsec = 4294967295}}}, regs = 0xffffffff}

现在,我想单独提取preempt_count值。使用GDB如何实现。

1 个答案:

答案 0 :(得分:1)

  

我想单独提取preempt_count值

这应该有效:

(gdb) p ((struct thread_info *)0x8785A000)->preempt_count