Reputation: 159
I'm trying to store the output of a gdb command into a gdb variable. I'm following the instruction from here. But when I print the variable it shows empty.
My pop_stack file contains this
20
268435372
I use the following command to store the value 268435372 from the pop_stack into gdb variable $pop_ele. And try to print the value as hexadecimal. But the $pop_ele shows empty.
(gdb) shell echo set \$pop_ele=\"$(tail -n 1 pop_stack)\"
(gdb) p/x $pop_ele
output:
set $pop_ele="268435372"
$8 = 0x0
My desire output for p/x $pop_ele command is 0xfffffac
Please help.
Upvotes: 0
Views: 1745
Reputation: 14452
With gdb 8.X, possible to use shell
and source
to execute commands that depends on external data.
shell echo set \$pop_ele=$(tail -n1 pop_stack) > gdb.tmp
source gdb.tmp
Upvotes: 1