summaryrefslogtreecommitdiff
path: root/data/eo/eo_gdb.py
diff options
context:
space:
mode:
Diffstat (limited to 'data/eo/eo_gdb.py')
-rw-r--r--data/eo/eo_gdb.py52
1 files changed, 30 insertions, 22 deletions
diff --git a/data/eo/eo_gdb.py b/data/eo/eo_gdb.py
index ab84805..2df82b6 100644
--- a/data/eo/eo_gdb.py
+++ b/data/eo/eo_gdb.py
@@ -2,34 +2,42 @@
2 2
3import gdb 3import gdb
4 4
5def symbol_equal_to_string(symbol, string):
6 return (symbol != None) and (symbol.name == string)
7
5class Eo_step(gdb.Command): 8class Eo_step(gdb.Command):
9 STEP_LIMIT = 10
6 def __init__(self): 10 def __init__(self):
7 gdb.Command.__init__(self, "eo_step", gdb.COMMAND_OBSCURE) 11 gdb.Command.__init__(self, "eo_step", gdb.COMMAND_OBSCURE)
12 self.START_FUNC = "_eo_call_resolve"
13 self.SKIP_FUNC = "_eo_do_start"
8 14
9 def invoke (self, arg, from_tty): 15 def invoke (self, arg, from_tty):
10 # While libeo is not reached, we step into 16 # Get to the call resolve function.
11 while gdb.solib_name(gdb.selected_frame().pc()).find("libeo.so") == -1: 17 i = 0
12 # step by one assembly instruction, no print 18 while not symbol_equal_to_string(gdb.selected_frame().function(), self.START_FUNC):
19 if symbol_equal_to_string(gdb.selected_frame().function(), self.SKIP_FUNC):
20 gdb.execute("finish", False, to_string=True)
21
22 if i > Eo_step.STEP_LIMIT:
23 break
24 else:
25 i += 1
26 gdb.execute("step", False, to_string=True)
27
28 # If we found the function, return from it, otherwise, fail.
29 if symbol_equal_to_string(gdb.selected_frame().function(), self.START_FUNC):
30 gdb.execute("finish", False, to_string=True)
31 else:
32 print "Search limit reached, you tried calling eo_step too far from an eo_do."
33 return
34
35 # Step until we move to a different function. FIXME: The hook can confuse us, needs to be solved.
36 cur_func = gdb.selected_frame().function()
37 while gdb.selected_frame().function() == cur_func:
13 gdb.execute("stepi", False, to_string=True) 38 gdb.execute("stepi", False, to_string=True)
14 39
15 # While we are in libeo or in an unknown function, we step into 40 # One last call to skip into the implementation
16 while (gdb.selected_frame().function() == None) or (gdb.solib_name(gdb.selected_frame().pc()).find("libeo.so") != -1): 41 gdb.execute("step", True)
17 # step by one assembly instruction, no print
18 gdb.execute("stepi", False, to_string=True)
19 42
20 print "Stopped at file " + gdb.selected_frame().find_sal().symtab.filename+ " line " + str(gdb.selected_frame().find_sal().line) + " function " + str(gdb.selected_frame().function())
21Eo_step() 43Eo_step()
22
23# Very crude, but works for the meanwhile
24class Eo_backtrace(gdb.Command):
25 def __init__(self):
26 gdb.Command.__init__(self, "eo_backtrace", gdb.COMMAND_OBSCURE)
27
28 def invoke (self, arg, from_tty):
29 btrace = gdb.execute("backtrace", False, to_string=True).split('\n')
30
31 for line in btrace:
32 if line.find("libeo.so") == -1 and line.find("lib/eo/") == -1:
33 print line
34
35Eo_backtrace()