[Lldb-commits] [lldb] r137988 - /lldb/trunk/utils/test/lldb-disasm.py

Johnny Chen johnny.chen at apple.com
Thu Aug 18 15:04:27 PDT 2011


Author: johnny
Date: Thu Aug 18 17:04:27 2011
New Revision: 137988

URL: http://llvm.org/viewvc/llvm-project?rev=137988&view=rev
Log:
Add an option '-q' to have quiet disassembly by not printing out the disassembled result.
This could be useful by reducing the strain on standard output.

Example:

utils/test/lldb-disasm.py -C "platform select remote-ios" -o "-b -n" -e '~/CoreFoundation' -n 50 -q

Modified:
    lldb/trunk/utils/test/lldb-disasm.py

Modified: lldb/trunk/utils/test/lldb-disasm.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=137988&r1=137987&r2=137988&view=diff
==============================================================================
--- lldb/trunk/utils/test/lldb-disasm.py (original)
+++ lldb/trunk/utils/test/lldb-disasm.py Thu Aug 18 17:04:27 2011
@@ -76,7 +76,7 @@
             print "run command failed!"
             print "run_command error:", res.GetError()
 
-def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, symbols_to_disassemble):
+def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, symbols_to_disassemble, quiet_disassembly):
     import lldb, atexit, re
 
     # Create the debugger instance now.
@@ -115,7 +115,7 @@
         return symbol.GetType() == lldb.eSymbolTypeCode
 
     # Define a generator for the symbols to disassemble.
-    def symbol_iter(num, symbols, target):
+    def symbol_iter(num, symbols, target, verbose):
         # If we specify the symbols to disassemble, ignore symbol table dump.
         if symbols:
             for i in range(len(symbols)):
@@ -135,18 +135,20 @@
                     if IsCodeType(s):
                         if limited:
                             count = count + 1
-                            print "returning symbol:", s.GetName()
+                            if verbose:
+                                print "returning symbol:", s.GetName()
                         yield s.GetName()
-                    print "start address:", s.GetStartAddress()
-                    print "end address:", s.GetEndAddress()
-                    s.GetDescription(stream)
-                    print "symbol description:", stream.GetData()
-                    stream.Clear()
+                    if verbose:
+                        print "start address:", s.GetStartAddress()
+                        print "end address:", s.GetEndAddress()
+                        s.GetDescription(stream)
+                        print "symbol description:", stream.GetData()
+                        stream.Clear()
 
     # Disassembly time.
-    for symbol in symbol_iter(num_symbols, symbols_to_disassemble, target):
+    for symbol in symbol_iter(num_symbols, symbols_to_disassemble, target, not quiet_disassembly):
         cmd = "disassemble %s '%s'" % (disassemble_options, symbol)
-        run_command(ci, cmd, res)
+        run_command(ci, cmd, res, True, not quiet_disassembly)
 
 
 def main():
@@ -176,6 +178,10 @@
                       type='int', action='store', default=-1,
                       dest='num_symbols',
                       help="""The number of symbols to disassemble, if specified.""")
+    parser.add_option('-q', '--quiet-disassembly',
+                      action='store_true', default=False,
+                      dest='quiet_disassembly',
+                      help="""The symbol(s) to invoke lldb's 'disassemble' command on, if specified.""")
     parser.add_option('-s', '--symbol',
                       type='string', action='append', metavar='SYMBOL', default=[],
                       dest='symbols_to_disassemble',
@@ -192,6 +198,7 @@
     executable = opts.executable
     disassemble_options = opts.disassemble_options
     num_symbols = opts.num_symbols
+    quiet_disassembly = opts.quiet_disassembly
     symbols_to_disassemble = opts.symbols_to_disassemble
 
     # We have parsed the options.
@@ -199,10 +206,14 @@
     print "executable:", executable
     print "disassemble options:", disassemble_options
     print "num of symbols to disassemble:", num_symbols
+    print "quiet disassembly output:", quiet_disassembly
     print "symbols to disassemble:", symbols_to_disassemble
 
     setupSysPath()
-    do_lldb_disassembly(lldb_commands, executable, disassemble_options, num_symbols, symbols_to_disassemble)
+    do_lldb_disassembly(lldb_commands, executable, disassemble_options,
+                        num_symbols,
+                        symbols_to_disassemble,
+                        quiet_disassembly)
 
 if __name__ == '__main__':
     main()





More information about the lldb-commits mailing list