chiark / gitweb /
Revert "fishdescriptor: try parse_eval_via_print"
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 24 Oct 2017 16:00:50 +0000 (17:00 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 24 Oct 2017 16:00:50 +0000 (17:00 +0100)
This reverts commit 33545a21597767a50443a717b015fc9e3c8dd553.

fishdescriptor/py/fishdescriptor/indonor.py

index f701434540d9d56b88237228e1fb195e88c4d54a..f01f9eb0c6e910de98ee65c8c654de3f8d091325 100644 (file)
@@ -6,7 +6,6 @@ import copy
 import os
 import sys
 import socket
-import re
 
 def _string_bytearray(s):
     # gets us bytes in py2 and py3
@@ -57,15 +56,6 @@ def parse_eval(expr):
     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)
@@ -182,22 +172,13 @@ class DonorImplementation():
         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)