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

Side by Side Diff: tools/grokdump.py

Issue 14660012: Prevent grokdump from crying about invalid input. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 def do_sh(self, none): 2029 def do_sh(self, none):
2030 """ 2030 """
2031 Search for the V8 Heap object in all available memory regions. You 2031 Search for the V8 Heap object in all available memory regions. You
2032 might get lucky and find this rare treasure full of invaluable 2032 might get lucky and find this rare treasure full of invaluable
2033 information. 2033 information.
2034 """ 2034 """
2035 raise NotImplementedError 2035 raise NotImplementedError
2036 2036
2037 def do_u(self, args): 2037 def do_u(self, args):
2038 """ 2038 """
2039 u 0x<address> 0x<size> 2039 Unassemble memory in the region [address, address + size). If the
2040 Unassemble memory in the region [address, address + size) 2040 size is not specified, a default value of 32 bytes is used.
2041 Synopsis: u 0x<address> 0x<size>
2041 """ 2042 """
2042 args = args.split(' ') 2043 args = args.split(' ')
2043 start = int(args[0], 16) 2044 start = int(args[0], 16)
2044 size = int(args[1], 16) 2045 size = int(args[1], 16) if len(args) > 1 else 0x20
2046 if not self.reader.IsValidAddress(start):
2047 print "Address is not contained within the minidump!"
2048 return
2045 lines = self.reader.GetDisasmLines(start, size) 2049 lines = self.reader.GetDisasmLines(start, size)
2046 for line in lines: 2050 for line in lines:
2047 print FormatDisasmLine(start, self.heap, line) 2051 print FormatDisasmLine(start, self.heap, line)
2048 print 2052 print
2049 2053
2054 def do_EOF(self, none):
2055 raise KeyboardInterrupt
2056
2050 EIP_PROXIMITY = 64 2057 EIP_PROXIMITY = 64
2051 2058
2052 CONTEXT_FOR_ARCH = { 2059 CONTEXT_FOR_ARCH = {
2053 MD_CPU_ARCHITECTURE_AMD64: 2060 MD_CPU_ARCHITECTURE_AMD64:
2054 ['rax', 'rbx', 'rcx', 'rdx', 'rdi', 'rsi', 'rbp', 'rsp', 'rip', 2061 ['rax', 'rbx', 'rcx', 'rdx', 'rdi', 'rsi', 'rbp', 'rsp', 'rip',
2055 'r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15'], 2062 'r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15'],
2056 MD_CPU_ARCHITECTURE_ARM: 2063 MD_CPU_ARCHITECTURE_ARM:
2057 ['r0', 'r1', 'r2', 'r3', 'r4', 'r5', 'r6', 'r7', 'r8', 'r9', 2064 ['r0', 'r1', 'r2', 'r3', 'r4', 'r5', 'r6', 'r7', 'r8', 'r9',
2058 'r10', 'r11', 'r12', 'sp', 'lr', 'pc'], 2065 'r10', 'r11', 'r12', 'sp', 'lr', 'pc'],
2059 MD_CPU_ARCHITECTURE_X86: 2066 MD_CPU_ARCHITECTURE_X86:
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 print FormatDisasmLine(disasm_start, heap, line) 2131 print FormatDisasmLine(disasm_start, heap, line)
2125 print 2132 print
2126 2133
2127 if heap is None: 2134 if heap is None:
2128 heap = V8Heap(reader, None) 2135 heap = V8Heap(reader, None)
2129 2136
2130 if options.full: 2137 if options.full:
2131 FullDump(reader, heap) 2138 FullDump(reader, heap)
2132 2139
2133 if options.shell: 2140 if options.shell:
2134 InspectionShell(reader, heap).cmdloop("type help to get help") 2141 try:
2142 InspectionShell(reader, heap).cmdloop("type help to get help")
2143 except KeyboardInterrupt:
2144 print "Kthxbye."
2135 else: 2145 else:
2136 if reader.exception is not None: 2146 if reader.exception is not None:
2137 print "Annotated stack (from exception.esp to bottom):" 2147 print "Annotated stack (from exception.esp to bottom):"
2138 for slot in xrange(stack_top, stack_bottom, reader.PointerSize()): 2148 for slot in xrange(stack_top, stack_bottom, reader.PointerSize()):
2139 maybe_address = reader.ReadUIntPtr(slot) 2149 maybe_address = reader.ReadUIntPtr(slot)
2140 heap_object = heap.FindObject(maybe_address) 2150 heap_object = heap.FindObject(maybe_address)
2141 maybe_symbol = reader.FindSymbol(maybe_address) 2151 maybe_symbol = reader.FindSymbol(maybe_address)
2142 print "%s: %s %s" % (reader.FormatIntPtr(slot), 2152 print "%s: %s %s" % (reader.FormatIntPtr(slot),
2143 reader.FormatIntPtr(maybe_address), 2153 reader.FormatIntPtr(maybe_address),
2144 maybe_symbol or "") 2154 maybe_symbol or "")
(...skipping 18 matching lines...) Expand all
2163 options, args = parser.parse_args() 2173 options, args = parser.parse_args()
2164 if os.path.exists(options.objdump): 2174 if os.path.exists(options.objdump):
2165 disasm.OBJDUMP_BIN = options.objdump 2175 disasm.OBJDUMP_BIN = options.objdump
2166 OBJDUMP_BIN = options.objdump 2176 OBJDUMP_BIN = options.objdump
2167 else: 2177 else:
2168 print "Cannot find %s, falling back to default objdump" % options.objdump 2178 print "Cannot find %s, falling back to default objdump" % options.objdump
2169 if len(args) != 1: 2179 if len(args) != 1:
2170 parser.print_help() 2180 parser.print_help()
2171 sys.exit(1) 2181 sys.exit(1)
2172 AnalyzeMinidump(options, args[0]) 2182 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