chiark / gitweb /
fishdescriptor: fix error handling
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 24 Oct 2017 16:56:39 +0000 (17:56 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 24 Oct 2017 16:56:39 +0000 (17:56 +0100)
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
fishdescriptor/fishdescriptor
fishdescriptor/py/fishdescriptor/fish.py
fishdescriptor/py/fishdescriptor/indonor.py

index 20eddfef05936e38aa17a0bc29bcd8f8ebe2d58c..7e95ed75941a6488242631857342072321706c64 100755 (executable)
@@ -35,7 +35,10 @@ fdmap = { }
 # fdmap[nominal] = (actual, Donor, there)
 
 def implement_pending():
 # fdmap[nominal] = (actual, Donor, there)
 
 def implement_pending():
-    actuals = donor.fish([pend[1] for pend in pending])
+    try: actuals = donor.fish([pend[1] for pend in pending])
+    except fishdescriptor.fish.Error as e:
+        print('fishdescriptor error: %s' % e, file=sys.stderr)
+        sys.exit(127)
     assert(len(actuals) == len(pending))
     for (nominal, there), actual in zip(pending, actuals):
         overwriting_info = fdmap.get(nominal)
     assert(len(actuals) == len(pending))
     for (nominal, there), actual in zip(pending, actuals):
         overwriting_info = fdmap.get(nominal)
index a506938964f71671c757b57decdceacb9039151a..56a562db6ce9c94a400e5b60eb1c226c59d36a37 100644 (file)
@@ -13,6 +13,8 @@ def _shuffle_fd3():
     os.dup2(1,3)
     os.dup2(2,1)
 
     os.dup2(1,3)
     os.dup2(2,1)
 
+class Error(Exception): pass
+
 class Donor():
     def __init__(d, pid, debug=None):
         d.pid = pid
 class Donor():
     def __init__(d, pid, debug=None):
         d.pid = pid
@@ -35,6 +37,7 @@ class Donor():
     def _eval_integer(d, expr):
         try:
             l = d._sp.stdout.readline()
     def _eval_integer(d, expr):
         try:
             l = d._sp.stdout.readline()
+            if not len(l): raise Error('gdb process donor python repl quit')
             if l != b'!\n': raise RuntimeError("indonor said %s" % repr(l))
             d._sp.stdin.write(expr.encode('utf-8') + b'\n')
             d._sp.stdin.flush()
             if l != b'!\n': raise RuntimeError("indonor said %s" % repr(l))
             d._sp.stdin.write(expr.encode('utf-8') + b'\n')
             d._sp.stdin.flush()
index c538baa846372d67f47db1b55680c7567bea973e..dcd447a39090c9a6d3321b359af1ccf31fae2de7 100644 (file)
@@ -1,6 +1,8 @@
 
 # class for use inside gdb which is debugging the donor process
 
 
 # class for use inside gdb which is debugging the donor process
 
+from __future__ import print_function
+
 import gdb
 import copy
 import os
 import gdb
 import copy
 import os
@@ -260,6 +262,9 @@ class DonorImplementation():
         return input
 
     def eval_loop(di):
         return input
 
     def eval_loop(di):
+        if not gdb.selected_inferior().was_attached:
+            print('gdb inferior not attached', file=sys.stderr)
+            sys.exit(0)
         while True:
             di._result('!\n')
             cmd = di._protocol_read()
         while True:
             di._result('!\n')
             cmd = di._protocol_read()