Extend grokdump's dd command with a second optional parameter defining number of...
authorishell <ishell@chromium.org>
Fri, 9 Jan 2015 11:52:17 +0000 (03:52 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 9 Jan 2015 11:52:30 +0000 (11:52 +0000)
Review URL: https://codereview.chromium.org/845713002

Cr-Commit-Position: refs/heads/master@{#26007}

tools/grokdump.py

index 2177ec2..5a5cf4b 100755 (executable)
@@ -2807,16 +2807,20 @@ class InspectionShell(cmd.Cmd):
     else:
       print "%s\n" % string
 
-  def do_dd(self, address):
+  def do_dd(self, args):
     """
-     Interpret memory at the given address (if available) as a sequence
-     of words. Automatic alignment is not performed.
+     Interpret memory in the given region [address, address + num * word_size)
+     (if available) as a sequence of words. Automatic alignment is not performed.
+     If the num is not specified, a default value of 16 words is used.
+     Synopsis: dd 0x<address> 0x<num>
     """
-    start = int(address, 16)
+    args = args.split(' ')
+    start = int(args[0], 16)
+    num = int(args[1], 16) if len(args) > 1 else 0x10
     if (start & self.heap.ObjectAlignmentMask()) != 0:
       print "Warning: Dumping un-aligned memory, is this what you had in mind?"
     for slot in xrange(start,
-                       start + self.reader.PointerSize() * 10,
+                       start + self.reader.PointerSize() * num,
                        self.reader.PointerSize()):
       if not self.reader.IsValidAddress(slot):
         print "Address is not contained within the minidump!"