0

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.

1
  • This question is similar to: Redirecting/storing output of shell into GDB variable?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Oct 25, 2024 at 2:47

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.