Skip to content
Snippets Groups Projects
Commit 4ad66359 authored by Mohammed Bilal Akhtar's avatar Mohammed Bilal Akhtar
Browse files

Restore all threads in inferior, not just selected one

parent 015468d7
No related branches found
No related tags found
1 merge request!6Add new argument to info fibres to enable grouping by line/stack
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
...@@ -15,12 +15,8 @@ class FibreSupport(): ...@@ -15,12 +15,8 @@ class FibreSupport():
return return
FibreSupport.list = [] FibreSupport.list = []
FibreSupport.active = {} FibreSupport.active = {}
FibreSupport.threads = {}
FibreSupport.saved = True 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 # traverse runtime stack list to build internal list of fibres
_globalStackList = gdb.parse_and_eval("_globalStackList") _globalStackList = gdb.parse_and_eval("_globalStackList")
first = _globalStackList['anchor'].address first = _globalStackList['anchor'].address
...@@ -34,21 +30,39 @@ class FibreSupport(): ...@@ -34,21 +30,39 @@ class FibreSupport():
currStack = str(gdb.parse_and_eval("Context::currStack")) currStack = str(gdb.parse_and_eval("Context::currStack"))
# Cache the registers for this thread, in case it represents # Cache the registers for this thread, in case it represents
# a fibre # 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] = { FibreSupport.active[currStack] = {
'rsp': str(gdb.parse_and_eval("$rsp")).split(None, 1)[0], 'rsp': rsp,
'rbp': str(gdb.parse_and_eval("$rbp")).split(None, 1)[0], 'rbp': rbp,
'rip': str(gdb.parse_and_eval("$rip")).split(None, 1)[0] 'rip': rip
} }
orig_thread.switch() orig_thread.switch()
# restore() is hooked to continue events via script hooks to 'fibre reset' # restore() is hooked to continue events via script hooks to 'fibre reset'
def restore(): def restore():
FibreSupport.prep_frame() orig_thread = gdb.selected_thread()
# restore original register context for thread in gdb.selected_inferior().threads():
gdb.execute("set $rsp = " + str(FibreSupport.rsp)) thread.switch()
gdb.execute("set $rbp = " + str(FibreSupport.rbp)) rsp = FibreSupport.threads[thread.num]['rsp']
gdb.execute("set $rip = " + str(FibreSupport.rip)) rbp = FibreSupport.threads[thread.num]['rbp']
gdb.execute("set Context::currStack = " + str(FibreSupport.currStack)) 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 FibreSupport.saved = False
def prep_frame(): def prep_frame():
......
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