import os
import sys
import socket
-import re
def _string_bytearray(s):
# gets us bytes in py2 and py3
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
-
class DonorStructLayout():
def __init__(l, typename):
x = gdb.lookup_type(typename)
return 1
def _errno_save(di):
- # incomprehensibly, gdb.parse_and_eval('errno') can sometimes
- # fail with
- # gdb.error: Cannot find thread-local variables on this target
- # even though plain gdb `print errno' works.
- # OMG. This may be related to:
- # https://github.com/cloudburst/libheap/issues/24
- # although I can't find it in the gdb bug db (which is half-broken
- # in my browser)
- # Anyway:
- di._saved_errno = parse_eval_via_print('errno')
+ di._saved_errno = parse_eval('errno')
def _errno_restore(di):
to_restore = di._saved_errno
di._saved_errno = None
if to_restore is not None:
- parse_eval_via_print('errno = %d' % to_restore)
+ parse_eval('errno = %d' % to_restore)
def _result(di, output):
sys.stderr.write("#> %s" % output)