25

I would like to know how it is possible to know the current system architecture in GDB and store this information into a variable for later evaluation.

Something like:

set variable $x=`shell uname -m`
vburdon
  • 251
  • 3
  • 3

1 Answers1

22

theres 2 ways:

the older way:

(gdb) shell echo set \$x=\"$(uname -m)\" >/tmp/foo.gdb
(gdb) source /tmp/foo.gdb

newer with python:

(gdb) python gdb.execute("set $y=\"" + os.uname()[4] + "\"")
matt
  • 5,364
  • 1
  • 25
  • 25
  • 1
    @hellow I don't believe so, but not positive, however there is this patch, most recently updated yesterday, which is undergoing review, try it out! https://sourceware.org/ml/gdb-patches/2019-05/msg00130.html – matt May 06 '19 at 03:50