| OLD | NEW |
| 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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 self.map = map | 963 self.map = map |
| 964 self.address = address | 964 self.address = address |
| 965 | 965 |
| 966 def Is(self, cls): | 966 def Is(self, cls): |
| 967 return isinstance(self, cls) | 967 return isinstance(self, cls) |
| 968 | 968 |
| 969 def Print(self, p): | 969 def Print(self, p): |
| 970 p.Print(str(self)) | 970 p.Print(str(self)) |
| 971 | 971 |
| 972 def __str__(self): | 972 def __str__(self): |
| 973 instance_type = "???" |
| 974 if self.map is not None: |
| 975 instance_type = INSTANCE_TYPES[self.map.instance_type] |
| 973 return "HeapObject(%s, %s)" % (self.heap.reader.FormatIntPtr(self.address), | 976 return "HeapObject(%s, %s)" % (self.heap.reader.FormatIntPtr(self.address), |
| 974 INSTANCE_TYPES[self.map.instance_type]) | 977 instance_type) |
| 975 | 978 |
| 976 def ObjectField(self, offset): | 979 def ObjectField(self, offset): |
| 977 field_value = self.heap.reader.ReadUIntPtr(self.address + offset) | 980 field_value = self.heap.reader.ReadUIntPtr(self.address + offset) |
| 978 return self.heap.FindObjectOrSmi(field_value) | 981 return self.heap.FindObjectOrSmi(field_value) |
| 979 | 982 |
| 980 def SmiField(self, offset): | 983 def SmiField(self, offset): |
| 981 field_value = self.heap.reader.ReadUIntPtr(self.address + offset) | 984 field_value = self.heap.reader.ReadUIntPtr(self.address + offset) |
| 982 if (field_value & 1) == 0: | 985 if (field_value & 1) == 0: |
| 983 return field_value / 2 | 986 return field_value / 2 |
| 984 return None | 987 return None |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 p.Print("code:") | 1382 p.Print("code:") |
| 1380 self.code.Print(p) | 1383 self.code.Print(p) |
| 1381 if self.code != self.shared.code: | 1384 if self.code != self.shared.code: |
| 1382 p.Print("unoptimized code:") | 1385 p.Print("unoptimized code:") |
| 1383 self.shared.code.Print(p) | 1386 self.shared.code.Print(p) |
| 1384 p.Dedent() | 1387 p.Dedent() |
| 1385 p.Print("}") | 1388 p.Print("}") |
| 1386 | 1389 |
| 1387 def __str__(self): | 1390 def __str__(self): |
| 1388 inferred_name = "" | 1391 inferred_name = "" |
| 1389 if self.shared.Is(SharedFunctionInfo): | 1392 if self.shared is not None and self.shared.Is(SharedFunctionInfo): |
| 1390 inferred_name = self.shared.inferred_name | 1393 inferred_name = self.shared.inferred_name |
| 1391 return "JSFunction(%s, %s)" % \ | 1394 return "JSFunction(%s, %s) " % \ |
| 1392 (self.heap.reader.FormatIntPtr(self.address), inferred_name) | 1395 (self.heap.reader.FormatIntPtr(self.address), inferred_name) |
| 1393 | 1396 |
| 1394 def _GetSource(self): | 1397 def _GetSource(self): |
| 1395 source = "?source?" | 1398 source = "?source?" |
| 1396 start = self.shared.start_position | 1399 start = self.shared.start_position |
| 1397 end = self.shared.end_position | 1400 end = self.shared.end_position |
| 1398 if not self.shared.script.Is(Script): return source | 1401 if not self.shared.script.Is(Script): return source |
| 1399 script_source = self.shared.script.source | 1402 script_source = self.shared.script.source |
| 1400 if not script_source.Is(String): return source | 1403 if not script_source.Is(String): return source |
| 1401 if start and end: | 1404 if start and end: |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2087 else: | 2090 else: |
| 2088 self.send_error(404,'File Not Found: %s' % self.path) | 2091 self.send_error(404,'File Not Found: %s' % self.path) |
| 2089 | 2092 |
| 2090 except IOError: | 2093 except IOError: |
| 2091 self.send_error(404,'File Not Found: %s' % self.path) | 2094 self.send_error(404,'File Not Found: %s' % self.path) |
| 2092 | 2095 |
| 2093 except WebParameterError as e: | 2096 except WebParameterError as e: |
| 2094 self.send_error(404, 'Web parameter error: %s' % e.message) | 2097 self.send_error(404, 'Web parameter error: %s' % e.message) |
| 2095 | 2098 |
| 2096 | 2099 |
| 2097 HTML_REG_FORMAT = "<span class=\"register\"><b>%s</b>: %s</span>\n" | 2100 HTML_REG_FORMAT = "<span class=\"register\"><b>%s</b>: %s</span><br/>\n" |
| 2098 | 2101 |
| 2099 | 2102 |
| 2100 class InspectionWebFormatter(object): | 2103 class InspectionWebFormatter(object): |
| 2101 CONTEXT_FULL = 0 | 2104 CONTEXT_FULL = 0 |
| 2102 CONTEXT_SHORT = 1 | 2105 CONTEXT_SHORT = 1 |
| 2103 | 2106 |
| 2104 def __init__(self, switches, minidump_name, http_server): | 2107 def __init__(self, switches, minidump_name, http_server): |
| 2105 self.dumpfilename = os.path.split(minidump_name)[1] | 2108 self.dumpfilename = os.path.split(minidump_name)[1] |
| 2106 self.encfilename = urllib.urlencode({ 'dump' : self.dumpfilename }) | 2109 self.encfilename = urllib.urlencode({ 'dump' : self.dumpfilename }) |
| 2107 self.reader = MinidumpReader(switches, minidump_name) | 2110 self.reader = MinidumpReader(switches, minidump_name) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 self.output_module_details(f, module) | 2259 self.output_module_details(f, module) |
| 2257 f.write("</div>") | 2260 f.write("</div>") |
| 2258 self.output_footer(f) | 2261 self.output_footer(f) |
| 2259 return | 2262 return |
| 2260 | 2263 |
| 2261 def output_context(self, f, details): | 2264 def output_context(self, f, details): |
| 2262 exception_thread = self.reader.thread_map[self.reader.exception.thread_id] | 2265 exception_thread = self.reader.thread_map[self.reader.exception.thread_id] |
| 2263 f.write("<h3>Exception context</h3>") | 2266 f.write("<h3>Exception context</h3>") |
| 2264 f.write('<div class="code">\n') | 2267 f.write('<div class="code">\n') |
| 2265 f.write("Thread id: %d" % exception_thread.id) | 2268 f.write("Thread id: %d" % exception_thread.id) |
| 2266 f.write(" Exception code: %08X\n" % | 2269 f.write(" Exception code: %08X<br/>\n" % |
| 2267 self.reader.exception.exception.code) | 2270 self.reader.exception.exception.code) |
| 2268 if details == InspectionWebFormatter.CONTEXT_FULL: | 2271 if details == InspectionWebFormatter.CONTEXT_FULL: |
| 2269 if self.reader.exception.exception.parameter_count > 0: | 2272 if self.reader.exception.exception.parameter_count > 0: |
| 2270 f.write(" Exception parameters: \n") | 2273 f.write(" Exception parameters: \n") |
| 2271 for i in xrange(0, self.reader.exception.exception.parameter_count): | 2274 for i in xrange(0, self.reader.exception.exception.parameter_count): |
| 2272 f.write("%08x" % self.reader.exception.exception.information[i]) | 2275 f.write("%08x" % self.reader.exception.exception.information[i]) |
| 2273 f.write("<br><br>\n") | 2276 f.write("<br><br>\n") |
| 2274 | 2277 |
| 2275 for r in CONTEXT_FOR_ARCH[self.reader.arch]: | 2278 for r in CONTEXT_FOR_ARCH[self.reader.arch]: |
| 2276 f.write(HTML_REG_FORMAT % | 2279 f.write(HTML_REG_FORMAT % |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3182 try: | 3185 try: |
| 3183 server = InspectionWebServer(PORT_NUMBER, options, args[0]) | 3186 server = InspectionWebServer(PORT_NUMBER, options, args[0]) |
| 3184 print 'Started httpserver on port ' , PORT_NUMBER | 3187 print 'Started httpserver on port ' , PORT_NUMBER |
| 3185 webbrowser.open('http://localhost:%i/summary.html' % PORT_NUMBER) | 3188 webbrowser.open('http://localhost:%i/summary.html' % PORT_NUMBER) |
| 3186 server.serve_forever() | 3189 server.serve_forever() |
| 3187 except KeyboardInterrupt: | 3190 except KeyboardInterrupt: |
| 3188 print '^C received, shutting down the web server' | 3191 print '^C received, shutting down the web server' |
| 3189 server.socket.close() | 3192 server.socket.close() |
| 3190 else: | 3193 else: |
| 3191 AnalyzeMinidump(options, args[0]) | 3194 AnalyzeMinidump(options, args[0]) |
| OLD | NEW |