summaryrefslogtreecommitdiffstats
path: root/lldb/examples
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-03-07 02:57:54 +0000
committerGreg Clayton <gclayton@apple.com>2013-03-07 02:57:54 +0000
commit923bedf52f96d47906e4972321bccb66242ce31e (patch)
tree3116337fc72a36aef1d736e1a020a227b63a1f3b /lldb/examples
parent2199c126f57843e18ff4d0cdd517b0f173cff10e (diff)
downloadbcm5719-llvm-923bedf52f96d47906e4972321bccb66242ce31e.tar.gz
bcm5719-llvm-923bedf52f96d47906e4972321bccb66242ce31e.zip
Added a new module that can dump all line tables for all compile units in any modules that are specified as arguments to the "dump_module_line_tables" command.
I used this to verify that the debug map line tables were the same as previous LLDB releases prior to my change in the DWARF in .o file linking. llvm-svn: 176610
Diffstat (limited to 'lldb/examples')
-rw-r--r--lldb/examples/python/lldb_module_utils.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/lldb/examples/python/lldb_module_utils.py b/lldb/examples/python/lldb_module_utils.py
new file mode 100644
index 00000000000..37f33ba416a
--- /dev/null
+++ b/lldb/examples/python/lldb_module_utils.py
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+
+import lldb
+import optparse
+import shlex
+import string
+import sys
+
+def create_dump_module_line_tables_options ():
+ usage = "usage: dump_module_line_tables [options] MODULE1 [MODULE2 ...]"
+ description='''Dumps all line tables from all compile units for any modules specified as arguments. Specifying the --verbose flag will output address ranges for each line entry.'''
+ parser = optparse.OptionParser(description=description, prog='start_gdb_log',usage=usage)
+ parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='Display verbose output.', default=False)
+ return parser
+
+def dump_module_line_tables(debugger, command, result, dict):
+ '''Dumps all line tables from all compile units for any modules specified as arguments.'''
+ command_args = shlex.split(command)
+
+ parser = create_dump_module_line_tables_options ()
+ try:
+ (options, args) = parser.parse_args(command_args)
+ except:
+ return
+ if command_args:
+ target = debugger.GetSelectedTarget()
+ lldb.target = target
+ for module_name in command_args:
+ result.PutCString('Searching for module "%s"' % (module_name,))
+ module_fspec = lldb.SBFileSpec (module_name, False)
+ module = target.FindModule (module_fspec);
+ if module:
+ for cu_idx in range (module.GetNumCompileUnits()):
+ cu = module.GetCompileUnitAtIndex(cu_idx)
+ result.PutCString("\n%s:" % (cu.file))
+ for line_idx in range(cu.GetNumLineEntries()):
+ line_entry = cu.GetLineEntryAtIndex(line_idx)
+ start_file_addr = line_entry.addr.file_addr
+ end_file_addr = line_entry.end_addr.file_addr
+ # If the two addresses are equal, this line table entry is a termination entry
+ if options.verbose:
+ if start_file_addr != end_file_addr:
+ result.PutCString('[%#x - %#x): %s' % (start_file_addr, end_file_addr, line_entry))
+ else:
+ if start_file_addr == end_file_addr:
+ result.PutCString('%#x: END' % (start_file_addr))
+ else:
+ result.PutCString('%#x: %s' % (start_file_addr, line_entry))
+ if start_file_addr == end_file_addr:
+ result.Printf("\n")
+ else:
+ result.PutCString ("no module for '%s'" % module)
+ else:
+ result.PutCString ("error: invalid target")
+
+parser = create_dump_module_line_tables_options ()
+dump_module_line_tables.__doc__ = parser.format_help()
+lldb.debugger.HandleCommand('command script add -f %s.dump_module_line_tables dump_module_line_tables' % __name__)
+print 'Installed "dump_module_line_tables" command' \ No newline at end of file
OpenPOWER on IntegriCloud