Skip to content
Snippets Groups Projects

Add new argument to info fibres to enable grouping by line/stack

Merged Mohammed Bilal Akhtar requested to merge mbakhtar/KOS:fibre-grouping-initial into master
@@ -15,12 +15,8 @@ class FibreSupport():
return
FibreSupport.list = []
FibreSupport.active = {}
FibreSupport.threads = {}
FibreSupport.saved = True
# 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"))
# traverse runtime stack list to build internal list of fibres
_globalStackList = gdb.parse_and_eval("_globalStackList")
first = _globalStackList['anchor'].address
@@ -34,21 +30,39 @@ class FibreSupport():
currStack = str(gdb.parse_and_eval("Context::currStack"))
# Cache the registers for this thread, in case it represents
# a fibre
rsp = str(gdb.parse_and_eval("$rsp")).split(None, 1)[0]
rbp = str(gdb.parse_and_eval("$rbp")).split(None, 1)[0]
rip = str(gdb.parse_and_eval("$rip")).split(None, 1)[0]
FibreSupport.threads[thread.num] = {
'rsp': rsp,
'rbp': rbp,
'rip': rip,
'currStack': currStack
}
FibreSupport.active[currStack] = {
'rsp': str(gdb.parse_and_eval("$rsp")).split(None, 1)[0],
'rbp': str(gdb.parse_and_eval("$rbp")).split(None, 1)[0],
'rip': str(gdb.parse_and_eval("$rip")).split(None, 1)[0]
'rsp': rsp,
'rbp': rbp,
'rip': rip
}
orig_thread.switch()
# restore() is hooked to continue events via script hooks to 'fibre reset'
def restore():
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))
orig_thread = gdb.selected_thread()
for thread in gdb.selected_inferior().threads():
thread.switch()
rsp = FibreSupport.threads[thread.num]['rsp']
rbp = FibreSupport.threads[thread.num]['rbp']
rip = FibreSupport.threads[thread.num]['rip']
currStack = FibreSupport.threads[thread.num]['currStack']
FibreSupport.prep_frame()
# restore original register context
gdb.execute("set $rsp = " + str(rsp))
gdb.execute("set $rbp = " + str(rbp))
gdb.execute("set $rip = " + str(rip))
gdb.execute("set Context::currStack = " + str(currStack))
orig_thread.switch()
FibreSupport.saved = False
def prep_frame():
Loading