chiark / gitweb /
fishdescriptor: Allow "preloaded"
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 6 Oct 2017 18:12:30 +0000 (19:12 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 6 Oct 2017 18:12:30 +0000 (19:12 +0100)
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
fishdescriptor/greenend/fishdescriptor/indonor.py

index f77a4da..b366e23 100644 (file)
@@ -27,12 +27,14 @@ def _string_escape_for_c(s):
             out += chr(c)
     return out
 
-class DonorImplementation():
+class DonorImplementation(preloaded=False):
     def __init__(self):
         # works on the current gdb.Inferior
         # ideally should be reused if the same process is targetd
         self._open = None
         self._sym = None
+        if preloaded:
+            self._sym = 'fishdescriptor_donate'
 
     def _func(self, functype, funcname, realargs):
         expr = '((%s) %s) %s' % (functype, funcname, realargs)
@@ -58,12 +60,12 @@ class DonorImplementation():
 
     def _dlsym(self):
         if self._sym is not None: return
+        self._dlopen()
         self._sym = self._dlfunc('void* (*)(void*, const char*)'
                                  'dlsym',
                                  '(%s, "fishdescriptor_donate")' % self._open)
 
     def donate(self, path, fds):
-        self._dlopen()
         self._dlsym()
         r = self._func('int (*)(const char*, const int*)',
                        self._sym,