Skip to content
Snippets Groups Projects
Commit 4b02c772 authored by Martin Karsten's avatar Martin Karsten
Browse files

- fix bug in gdb support: script hook masks python hook?

parent 32d6abd6
No related branches found
No related tags found
No related merge requests found
......@@ -6,21 +6,17 @@ import gdb
from contextlib import contextmanager
class FibreSupport():
def __init__(self):
FibreSupport.list = []
FibreSupport.active = {}
FibreSupport.saved = False
def stop_handler(event):
if (gdb.lookup_symbol("_globalStackList")[0] == None):
print("WARNING: no fibre debugging support - did you enable TESTING_ENABLE_DEBUGGING?")
return
FibreSupport.list = []
FibreSupport.active = {}
# save register context for later continuation
FibreSupport.rsp = str(gdb.parse_and_eval("$rsp")).split(None, 1)[0]
FibreSupport.rbp = str(gdb.parse_and_eval("$rbp")).split(None, 1)[0]
FibreSupport.rip = str(gdb.parse_and_eval("$rip")).split(None, 1)[0]
FibreSupport.currStack = str(gdb.parse_and_eval("Context::currStack"))
FibreSupport.saved = True
# traverse runtime stack list to build internal list of fibres
_globalStackList = gdb.parse_and_eval("_globalStackList")
first = _globalStackList['anchor'].address
......@@ -41,21 +37,14 @@ class FibreSupport():
}
orig_thread.switch()
def cont_handler(event):
FibreSupport.list = []
FibreSupport.active = {}
# ideally restore() would be hooked up with cont_handler,
# but gdb currently fails with segmentation fault when trying
# restore() is hooked to continue events via basic script hooks
def restore():
if (FibreSupport.saved):
FibreSupport.prep_frame()
# restore original register context
gdb.execute("set $rsp = " + str(FibreSupport.rsp))
gdb.execute("set $rbp = " + str(FibreSupport.rbp))
gdb.execute("set $rip = " + str(FibreSupport.rip))
gdb.execute("set Context::currStack = " + str(FibreSupport.currStack))
FibreSupport.saved = False
FibreSupport.prep_frame()
# restore original register context
gdb.execute("set $rsp = " + str(FibreSupport.rsp))
gdb.execute("set $rbp = " + str(FibreSupport.rbp))
gdb.execute("set $rip = " + str(FibreSupport.rip))
gdb.execute("set Context::currStack = " + str(FibreSupport.currStack))
def prep_frame():
# walk stack down to innermost frame
......@@ -234,4 +223,3 @@ FibreSetPtr()
FibreSetIdx()
FibreReset()
gdb.events.stop.connect(FibreSupport.stop_handler)
gdb.events.cont.connect(FibreSupport.cont_handler)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment