+def parse_eval(expr):
+ sys.stderr.write("## EVAL %s\n" % repr(expr))
+ x = gdb.parse_and_eval(expr)
+ sys.stderr.write('## => %s\n' % x)
+ sys.stderr.flush()
+ return x
+
+def parse_eval_via_print(expr):
+ # works only with things whose value is an int and where expr is simple
+ sys.stderr.write("## EVAL-VIA-PRINT %s\n" % repr(expr))
+ x = gdb.execute('print %s' % expr, to_string=True)
+ m = re.match('\$\d+ = (\d+)\n$', x) # seriously !
+ r = int(m.group(1))
+ sys.stderr.write('## => %s\n' % r)
+ return 4
+