Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 32 import cgi | 32 import cgi |
| 33 import cmd | 33 import cmd |
| 34 import codecs | 34 import codecs |
| 35 import ctypes | 35 import ctypes |
| 36 import datetime | 36 import datetime |
| 37 import disasm | 37 import disasm |
| 38 import mmap | 38 import mmap |
| 39 import optparse | 39 import optparse |
| 40 import os | 40 import os |
| 41 import re | 41 import re |
| 42 import StringIO | |
| 42 import sys | 43 import sys |
| 43 import types | 44 import types |
| 44 import urllib | 45 import urllib |
| 45 import urlparse | 46 import urlparse |
| 46 import v8heapconst | 47 import v8heapconst |
| 47 import webbrowser | 48 import webbrowser |
| 48 | 49 |
| 49 PORT_NUMBER = 8081 | 50 PORT_NUMBER = 8081 |
| 50 | 51 |
| 51 | 52 |
| (...skipping 2042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2094 self.send_header('Content-type','text/html') | 2095 self.send_header('Content-type','text/html') |
| 2095 self.end_headers() | 2096 self.end_headers() |
| 2096 return | 2097 return |
| 2097 | 2098 |
| 2098 def do_GET(self): | 2099 def do_GET(self): |
| 2099 try: | 2100 try: |
| 2100 parsedurl = urlparse.urlparse(self.path) | 2101 parsedurl = urlparse.urlparse(self.path) |
| 2101 query_components = urlparse.parse_qs(parsedurl.query) | 2102 query_components = urlparse.parse_qs(parsedurl.query) |
| 2102 if parsedurl.path == "/dumps.html": | 2103 if parsedurl.path == "/dumps.html": |
| 2103 self.send_success_html_headers() | 2104 self.send_success_html_headers() |
| 2104 self.server.output_dumps(self.wfile) | 2105 out_buffer = StringIO.StringIO() |
| 2106 self.server.output_dumps(out_buffer) | |
| 2107 self.wfile.write(out_buffer.getvalue()) | |
|
Camillo Bruni
2016/10/04 07:38:20
nit: maybe pull the buffer creation and flushing o
| |
| 2105 elif parsedurl.path == "/summary.html": | 2108 elif parsedurl.path == "/summary.html": |
| 2106 self.send_success_html_headers() | 2109 self.send_success_html_headers() |
| 2107 self.formatter(query_components).output_summary(self.wfile) | 2110 out_buffer = StringIO.StringIO() |
| 2111 self.formatter(query_components).output_summary(out_buffer) | |
| 2112 self.wfile.write(out_buffer.getvalue()) | |
| 2108 elif parsedurl.path == "/info.html": | 2113 elif parsedurl.path == "/info.html": |
| 2109 self.send_success_html_headers() | 2114 self.send_success_html_headers() |
| 2110 self.formatter(query_components).output_info(self.wfile) | 2115 out_buffer = StringIO.StringIO() |
| 2116 self.formatter(query_components).output_info(out_buffer) | |
| 2117 self.wfile.write(out_buffer.getvalue()) | |
| 2111 elif parsedurl.path == "/modules.html": | 2118 elif parsedurl.path == "/modules.html": |
| 2112 self.send_success_html_headers() | 2119 self.send_success_html_headers() |
| 2113 self.formatter(query_components).output_modules(self.wfile) | 2120 out_buffer = StringIO.StringIO() |
| 2121 self.formatter(query_components).output_modules(out_buffer) | |
| 2122 self.wfile.write(out_buffer.getvalue()) | |
| 2114 elif parsedurl.path == "/search.html" or parsedurl.path == "/s": | 2123 elif parsedurl.path == "/search.html" or parsedurl.path == "/s": |
| 2115 address = query_components.get("val", []) | 2124 address = query_components.get("val", []) |
| 2116 if len(address) != 1: | 2125 if len(address) != 1: |
| 2117 self.send_error(404, "Invalid params") | 2126 self.send_error(404, "Invalid params") |
| 2118 return | 2127 return |
| 2119 self.send_success_html_headers() | 2128 self.send_success_html_headers() |
| 2129 out_buffer = StringIO.StringIO() | |
| 2120 self.formatter(query_components).output_search_res( | 2130 self.formatter(query_components).output_search_res( |
| 2121 self.wfile, address[0]) | 2131 out_buffer, address[0]) |
| 2132 self.wfile.write(out_buffer.getvalue()) | |
| 2122 elif parsedurl.path == "/disasm.html": | 2133 elif parsedurl.path == "/disasm.html": |
| 2123 address = query_components.get("val", []) | 2134 address = query_components.get("val", []) |
| 2124 exact = query_components.get("exact", ["on"]) | 2135 exact = query_components.get("exact", ["on"]) |
| 2125 if len(address) != 1: | 2136 if len(address) != 1: |
| 2126 self.send_error(404, "Invalid params") | 2137 self.send_error(404, "Invalid params") |
| 2127 return | 2138 return |
| 2128 self.send_success_html_headers() | 2139 self.send_success_html_headers() |
| 2140 out_buffer = StringIO.StringIO() | |
| 2129 self.formatter(query_components).output_disasm( | 2141 self.formatter(query_components).output_disasm( |
| 2130 self.wfile, address[0], exact[0]) | 2142 out_buffer, address[0], exact[0]) |
| 2143 self.wfile.write(out_buffer.getvalue()) | |
| 2131 elif parsedurl.path == "/data.html": | 2144 elif parsedurl.path == "/data.html": |
| 2132 address = query_components.get("val", []) | 2145 address = query_components.get("val", []) |
| 2133 datakind = query_components.get("type", ["address"]) | 2146 datakind = query_components.get("type", ["address"]) |
| 2134 if len(address) == 1 and len(datakind) == 1: | 2147 if len(address) == 1 and len(datakind) == 1: |
| 2135 self.send_success_html_headers() | 2148 self.send_success_html_headers() |
| 2149 out_buffer = StringIO.StringIO() | |
| 2136 self.formatter(query_components).output_data( | 2150 self.formatter(query_components).output_data( |
| 2137 self.wfile, address[0], datakind[0]) | 2151 out_buffer, address[0], datakind[0]) |
| 2152 self.wfile.write(out_buffer.getvalue()) | |
| 2138 else: | 2153 else: |
| 2139 self.send_error(404,'Invalid params') | 2154 self.send_error(404,'Invalid params') |
| 2140 elif parsedurl.path == "/setdumpdesc": | 2155 elif parsedurl.path == "/setdumpdesc": |
| 2141 name = query_components.get("dump", [""]) | 2156 name = query_components.get("dump", [""]) |
| 2142 description = query_components.get("description", [""]) | 2157 description = query_components.get("description", [""]) |
| 2143 if len(name) == 1 and len(description) == 1: | 2158 if len(name) == 1 and len(description) == 1: |
| 2144 name = name[0] | 2159 name = name[0] |
| 2145 description = description[0] | 2160 description = description[0] |
| 2146 if self.server.set_dump_desc(name, description): | 2161 if self.server.set_dump_desc(name, description): |
| 2147 self.send_success_html_headers() | 2162 self.send_success_html_headers() |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2246 (style_class, self.encfilename, straddress, straddress)) | 2261 (style_class, self.encfilename, straddress, straddress)) |
| 2247 | 2262 |
| 2248 def output_header(self, f): | 2263 def output_header(self, f): |
| 2249 f.write(WEB_HEADER % | 2264 f.write(WEB_HEADER % |
| 2250 { "query_dump" : self.encfilename, | 2265 { "query_dump" : self.encfilename, |
| 2251 "dump_name" : cgi.escape(self.dumpfilename) }) | 2266 "dump_name" : cgi.escape(self.dumpfilename) }) |
| 2252 | 2267 |
| 2253 def output_footer(self, f): | 2268 def output_footer(self, f): |
| 2254 f.write(WEB_FOOTER) | 2269 f.write(WEB_FOOTER) |
| 2255 | 2270 |
| 2256 MAX_CONTEXT_STACK = 4096 | 2271 MAX_CONTEXT_STACK = 2048 |
| 2257 | 2272 |
| 2258 def output_summary(self, f): | 2273 def output_summary(self, f): |
| 2259 self.output_header(f) | 2274 self.output_header(f) |
| 2260 f.write('<div class="code">') | 2275 f.write('<div class="code">') |
| 2261 self.output_context(f, InspectionWebFormatter.CONTEXT_SHORT) | 2276 self.output_context(f, InspectionWebFormatter.CONTEXT_SHORT) |
| 2262 self.output_disasm_pc(f) | 2277 self.output_disasm_pc(f) |
| 2263 | 2278 |
| 2264 # Output stack | 2279 # Output stack |
| 2265 exception_thread = self.reader.thread_map[self.reader.exception.thread_id] | 2280 exception_thread = self.reader.thread_map[self.reader.exception.thread_id] |
| 2266 stack_bottom = exception_thread.stack.start + \ | |
| 2267 min(exception_thread.stack.memory.data_size, self.MAX_CONTEXT_STACK) | |
| 2268 stack_top = self.reader.ExceptionSP() | 2281 stack_top = self.reader.ExceptionSP() |
| 2282 stack_bottom = min(exception_thread.stack.start + \ | |
| 2283 exception_thread.stack.memory.data_size, | |
| 2284 stack_top + self.MAX_CONTEXT_STACK) | |
| 2269 self.output_words(f, stack_top - 16, stack_bottom, stack_top, "Stack") | 2285 self.output_words(f, stack_top - 16, stack_bottom, stack_top, "Stack") |
| 2270 | 2286 |
| 2271 f.write('</div>') | 2287 f.write('</div>') |
| 2272 self.output_footer(f) | 2288 self.output_footer(f) |
| 2273 return | 2289 return |
| 2274 | 2290 |
| 2275 def output_info(self, f): | 2291 def output_info(self, f): |
| 2276 self.output_header(f) | 2292 self.output_header(f) |
| 2277 f.write("<h3>Dump info</h3>") | 2293 f.write("<h3>Dump info</h3>") |
| 2278 f.write("Description: ") | 2294 f.write("Description: ") |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3284 try: | 3300 try: |
| 3285 server = InspectionWebServer(PORT_NUMBER, options, args[0]) | 3301 server = InspectionWebServer(PORT_NUMBER, options, args[0]) |
| 3286 print 'Started httpserver on port ' , PORT_NUMBER | 3302 print 'Started httpserver on port ' , PORT_NUMBER |
| 3287 webbrowser.open('http://localhost:%i/summary.html' % PORT_NUMBER) | 3303 webbrowser.open('http://localhost:%i/summary.html' % PORT_NUMBER) |
| 3288 server.serve_forever() | 3304 server.serve_forever() |
| 3289 except KeyboardInterrupt: | 3305 except KeyboardInterrupt: |
| 3290 print '^C received, shutting down the web server' | 3306 print '^C received, shutting down the web server' |
| 3291 server.socket.close() | 3307 server.socket.close() |
| 3292 else: | 3308 else: |
| 3293 AnalyzeMinidump(options, args[0]) | 3309 AnalyzeMinidump(options, args[0]) |
| OLD | NEW |