Noob_learner_90
Noob_learner_90

Reputation: 61

how to save gdb command result in a variable and reuse it again inside gdb?

in GDB , i want to save the result of x/x $rsp command , the value inside the address showing

example: the result of the command

 x/x $rsp   is    0xffffaaaa : (0x00400b)

i want to save that address 0x00400b that i highlighted between brackets inside a variable , and reuse that variable that contain 0x00400b inside another GDB command. example dump binary memory from that place when a breakpoint hits.

Upvotes: 0

Views: 421

Answers (1)

Andrew
Andrew

Reputation: 4751

You can do what you want like this:

(gdb) x/x $rsp
0x7fffffffb000: 0x004011e0
(gdb) set $foo=*((int*) $rsp)
(gdb) p/x $foo
$2 = 0x4011e0

Upvotes: 2

Related Questions