Ramdinesh J P
Ramdinesh J P

Reputation: 139

How to extract value of structure member using GDB

Suppose I have a Kernel structure struct thread_info, I would like to get the value of preempt_count variable from thread_info struct using GDB.

I am able to get the below info by de-referencing the 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}

Now, I would like to extract the preempt_count value alone. How it can be achieved using GDB.

Upvotes: 0

Views: 193

Answers (1)

Employed Russian
Employed Russian

Reputation: 213516

I would like to extract the preempt_count value alone

This should work:

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

Upvotes: 1

Related Questions