diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/examples/python/globals.py | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/examples/python/globals.py')
-rwxr-xr-x | lldb/examples/python/globals.py | 74 |
1 files changed, 54 insertions, 20 deletions
diff --git a/lldb/examples/python/globals.py b/lldb/examples/python/globals.py index fb2739c8b69..43bd915b393 100755 --- a/lldb/examples/python/globals.py +++ b/lldb/examples/python/globals.py @@ -15,58 +15,92 @@ import os import shlex import sys + def get_globals(raw_path, options): error = lldb.SBError() # Resolve the path if needed path = os.path.expanduser(raw_path) # Create a target using path + options - target = lldb.debugger.CreateTarget(path, options.arch, options.platform, False, error) + target = lldb.debugger.CreateTarget( + path, options.arch, options.platform, False, error) if target: # Get the executable module module = target.module[target.executable.basename] if module: # Keep track of which variables we have already looked up global_names = list() - # Iterate through all symbols in the symbol table and watch for any DATA symbols + # Iterate through all symbols in the symbol table and watch for any + # DATA symbols for symbol in module.symbols: if symbol.type == lldb.eSymbolTypeData: - # The symbol is a DATA symbol, lets try and find all global variables + # The symbol is a DATA symbol, lets try and find all global variables # that match this name and print them global_name = symbol.name # Make sure we don't lookup the same variable twice if global_name not in global_names: global_names.append(global_name) # Find all global variables by name - global_variable_list = module.FindGlobalVariables (target, global_name, lldb.UINT32_MAX) + global_variable_list = module.FindGlobalVariables( + target, global_name, lldb.UINT32_MAX) if global_variable_list: # Print results for anything that matched for global_variable in global_variable_list: - print 'name = %s' % global_variable.name # returns the global variable name as a string - print 'value = %s' % global_variable.value # Returns the variable value as a string + # returns the global variable name as a string + print 'name = %s' % global_variable.name + # Returns the variable value as a string + print 'value = %s' % global_variable.value print 'type = %s' % global_variable.type # Returns an lldb.SBType object - print 'addr = %s' % global_variable.addr # Returns an lldb.SBAddress (section offset address) for this global - print 'file_addr = 0x%x' % global_variable.addr.file_addr # Returns the file virtual address for this global - print 'location = %s' % global_variable.location # returns the global variable value as a string - print 'size = %s' % global_variable.size # Returns the size in bytes of this global variable + # Returns an lldb.SBAddress (section offset + # address) for this global + print 'addr = %s' % global_variable.addr + # Returns the file virtual address for this + # global + print 'file_addr = 0x%x' % global_variable.addr.file_addr + # returns the global variable value as a string + print 'location = %s' % global_variable.location + # Returns the size in bytes of this global + # variable + print 'size = %s' % global_variable.size print + def globals(command_args): '''Extract all globals from any arguments which must be paths to object files.''' usage = "usage: %prog [options] <PATH> [PATH ...]" - description='''This command will find all globals in the specified object file and return an list() of lldb.SBValue objects (which might be empty).''' - parser = optparse.OptionParser(description=description, prog='globals',usage=usage) - parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False) - parser.add_option('-a', '--arch', type='string', metavar='arch', dest='arch', help='Specify an architecture (or triple) to use when extracting from a file.') - parser.add_option('-p', '--platform', type='string', metavar='platform', dest='platform', help='Specify the platform to use when creating the debug target. Valid values include "localhost", "darwin-kernel", "ios-simulator", "remote-freebsd", "remote-macosx", "remote-ios", "remote-linux".') + description = '''This command will find all globals in the specified object file and return an list() of lldb.SBValue objects (which might be empty).''' + parser = optparse.OptionParser( + description=description, + prog='globals', + usage=usage) + parser.add_option( + '-v', + '--verbose', + action='store_true', + dest='verbose', + help='display verbose debug info', + default=False) + parser.add_option( + '-a', + '--arch', + type='string', + metavar='arch', + dest='arch', + help='Specify an architecture (or triple) to use when extracting from a file.') + parser.add_option( + '-p', + '--platform', + type='string', + metavar='platform', + dest='platform', + help='Specify the platform to use when creating the debug target. Valid values include "localhost", "darwin-kernel", "ios-simulator", "remote-freebsd", "remote-macosx", "remote-ios", "remote-linux".') try: (options, args) = parser.parse_args(command_args) except: return - + for path in args: - get_globals (path, options) - + get_globals(path, options) + if __name__ == '__main__': lldb.debugger = lldb.SBDebugger.Create() - globals (sys.argv[1:]) - + globals(sys.argv[1:]) |