0

I'd like to use a gdb command script to automatically run commands, and I need it to have a unique id. This can be done manually via:

set $a = [unique id]

However, I'd like to do this programatically, somehting like:

set $a = shell myid.sh

where myid.sh prints a unique id.

However, I can't figure out how to load a gdb convenience var from the results of a shell command.

SRobertJames
  • 8,210
  • 14
  • 60
  • 107
  • So I'm guessing the [shell exit code](https://sourceware.org/gdb/current/onlinedocs/gdb/Convenience-Vars.html#index-shell-command_002c-exit-code) isn't enough for you. In that case I would use python, e.g. like [this answer](https://stackoverflow.com/a/47144897/1983398). – ssbssa Oct 31 '21 at 22:57
  • 1
    Do you just need an integer? `python import random; gdb.set_convenience_variable("a", str(random.randint(1,32000)))` – Mark Plotnick Nov 01 '21 at 19:56

0 Answers0