From 410007558fa8d314e3f2fdfb385d2d8ab07e1e6c Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Tue, 29 Jan 2013 20:22:45 +0100 Subject: Added gdb_plugins/rblog.py for reading out RBLog objects. --- gdb_plugins/rblog.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 gdb_plugins/rblog.py (limited to 'gdb_plugins') diff --git a/gdb_plugins/rblog.py b/gdb_plugins/rblog.py new file mode 100644 index 0000000..c058db9 --- /dev/null +++ b/gdb_plugins/rblog.py @@ -0,0 +1,37 @@ +class RBlog(gdb.Command): + def __init__(self): + gdb.Command.__init__(self, "rblog", gdb.COMMAND_DATA, gdb.COMPLETE_SYMBOL, True) + + def invoke(self, arg, from_tty): + args = gdb.string_to_argv(arg) + if len(args) != 1: + print 'Usage: rblog ' + return + + rblog = gdb.parse_and_eval(args[0]) + num_entries = rblog['num_entries'] + num_arguments = rblog['num_arguments'] + entries = rblog['entries'] + index = rblog['index'] + + if entries[index]['string']: + r = range(index, num_entries) + range(index) + else: + r = range(index) + + for i in r: + entry = entries[i] + timestamp = int(entry['timestamp']) + if not entry['string']: + break + string = entry['string'].string() + arguments = [int(entry['arguments'][i]) for i in range(num_arguments)] + + try: + string = string % tuple(arguments[:string.count('%') - 2 * string.count('%%')]) + except: + pass + + print '%8d %-80s %s' % (timestamp, string, ' '.join('%08x' % a for a in arguments)) + +RBlog() -- cgit v1.2.3