gdbgdb-python

calling gdb print from python script


I have a python gdb script that finds a pointer to some important value.

I want to call gdb print command to have this value assigned to value history for future references in other debug commands.

How to do it?

I know that I can define python function that will return this value - but I really want gdb command for backward compatibility with old gdb scripts.


Solution

  • Generate python string and call gdb.execute

    tmpVal = long(pointer)
    tmpStr = "print (Xxxx *)0x{:x}".format(tmpVal)
    gdb.execute(tmpStr)