3

I had some scripts in Python to help me debugging with GDB that used the function gdb.parse_and_eval (still documented) to get the inferior values from the arguments passed to a scripted command, and now the module doesn't seem to have any trace of that function. Doing python import gdb; print dir(gdb) from GDB clearly shows that this function is missing.

I wrote the scripts some time ago for the GDB 6.8 in the archer branch, and now I cannot find any information about if it's been deprecated or what happened in GDB 7.

Any information about it?

Thanks!

fortran
  • 74,053
  • 25
  • 135
  • 175

2 Answers2

4

I don't know where it went or why, but Qt implemented this workaround in their code, which may be practically useful to you:

def parseAndEvaluate(exp):
        if gdb.VERSION.startswith("6.8.50.2009"):
            return gdb.parse_and_eval(exp)
        # Work around non-existing gdb.parse_and_eval as in released 7.0
        gdb.execute("set logging redirect on")
        gdb.execute("set logging on")
        gdb.execute("print %s" % exp)
        gdb.execute("set logging off")
        return gdb.history(0)
ire_and_curses
  • 68,372
  • 23
  • 116
  • 141
4

parse_and_eval was checked in on the Archer branch, but has not been merged into mainline in time for 7.0 release. It has been merged now:

2009-12-03  Tom Tromey  <tromey@redhat.com>

        * python/python.c (gdbpy_parse_and_eval): New function.
        (GdbMethods): Add "parse_and_eval".

and will be available in the upcoming 7.1 release.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362