Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: tools/grokdump.py

Issue 10697067: Add function to grokdump shell to print ASCII string. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2012 the V8 project authors. All rights reserved. 3 # Copyright 2012 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 def do_list(self, smth): 1584 def do_list(self, smth):
1585 """ 1585 """
1586 List all available memory regions. 1586 List all available memory regions.
1587 """ 1587 """
1588 def print_region(reader, start, size, location): 1588 def print_region(reader, start, size, location):
1589 print " %s - %s (%d bytes)" % (reader.FormatIntPtr(start), 1589 print " %s - %s (%d bytes)" % (reader.FormatIntPtr(start),
1590 reader.FormatIntPtr(start + size), 1590 reader.FormatIntPtr(start + size),
1591 size) 1591 size)
1592 print "Available memory regions:" 1592 print "Available memory regions:"
1593 self.reader.ForEachMemoryRegion(print_region) 1593 self.reader.ForEachMemoryRegion(print_region)
1594
1595 def do_ascii(self, address):
Michael Starzinger 2012/07/03 11:43:16 How about naming this command "dascii" or just "da
Yang 2012/07/03 11:51:11 Done.
1596 """
1597 Print ASCII string starting at specified address.
Michael Starzinger 2012/07/03 11:43:16 Indent that by one space for consistency.
Yang 2012/07/03 11:51:11 Done.
1598 """
1599 address = int(address, 16)
1600 string = ""
1601 while self.reader.IsValidAddress(address):
1602 code = self.reader.ReadU8(address)
1603 if code < 128:
1604 string += chr(code)
1605 else:
1606 break
1607 address += 1
1608
1609 if string == "":
1610 print "Not an ASCII string at %s" % self.reader.FormatIntPtr(address)
1611 else:
1612 print "%s" % string
Michael Starzinger 2012/07/03 11:43:16 Maybe we should put parentheses around the string.
Yang 2012/07/03 11:51:11 Quotes don't work that well since the string may n
1594 1613
1595 1614
1596 EIP_PROXIMITY = 64 1615 EIP_PROXIMITY = 64
1597 1616
1598 CONTEXT_FOR_ARCH = { 1617 CONTEXT_FOR_ARCH = {
1599 MD_CPU_ARCHITECTURE_AMD64: 1618 MD_CPU_ARCHITECTURE_AMD64:
1600 ['rax', 'rbx', 'rcx', 'rdx', 'rdi', 'rsi', 'rbp', 'rsp', 'rip'], 1619 ['rax', 'rbx', 'rcx', 'rdx', 'rdi', 'rsi', 'rbp', 'rsp', 'rip'],
1601 MD_CPU_ARCHITECTURE_X86: 1620 MD_CPU_ARCHITECTURE_X86:
1602 ['eax', 'ebx', 'ecx', 'edx', 'edi', 'esi', 'ebp', 'esp', 'eip'] 1621 ['eax', 'ebx', 'ecx', 'edx', 'edi', 'esi', 'ebp', 'esp', 'eip']
1603 } 1622 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 parser = optparse.OptionParser(USAGE) 1692 parser = optparse.OptionParser(USAGE)
1674 parser.add_option("-s", "--shell", dest="shell", action="store_true", 1693 parser.add_option("-s", "--shell", dest="shell", action="store_true",
1675 help="start an interactive inspector shell") 1694 help="start an interactive inspector shell")
1676 parser.add_option("-f", "--full", dest="full", action="store_true", 1695 parser.add_option("-f", "--full", dest="full", action="store_true",
1677 help="dump all information contained in the minidump") 1696 help="dump all information contained in the minidump")
1678 options, args = parser.parse_args() 1697 options, args = parser.parse_args()
1679 if len(args) != 1: 1698 if len(args) != 1:
1680 parser.print_help() 1699 parser.print_help()
1681 sys.exit(1) 1700 sys.exit(1)
1682 AnalyzeMinidump(options, args[0]) 1701 AnalyzeMinidump(options, args[0])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698