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

Side by Side Diff: tools/grokdump.py

Issue 1023443004: Version 4.3.48.1 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.3.48
Patch Set: Created 5 years, 9 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
« no previous file with comments | « test/cctest/test-weaksets.cc ('k') | tools/oom_dump/oom_dump.cc » ('j') | 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 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 HeapObject.__init__(self, heap, None, None) 1614 HeapObject.__init__(self, heap, None, None)
1615 self.instance_type = instance_type 1615 self.instance_type = instance_type
1616 self.known_name = known_name 1616 self.known_name = known_name
1617 1617
1618 def __str__(self): 1618 def __str__(self):
1619 return "<%s>" % self.known_name 1619 return "<%s>" % self.known_name
1620 1620
1621 1621
1622 COMMENT_RE = re.compile(r"^C (0x[0-9a-fA-F]+) (.*)$") 1622 COMMENT_RE = re.compile(r"^C (0x[0-9a-fA-F]+) (.*)$")
1623 PAGEADDRESS_RE = re.compile( 1623 PAGEADDRESS_RE = re.compile(
1624 r"^P (mappage|oldpage) (0x[0-9a-fA-F]+)$") 1624 r"^P (mappage|pointerpage|datapage) (0x[0-9a-fA-F]+)$")
1625 1625
1626 1626
1627 class InspectionInfo(object): 1627 class InspectionInfo(object):
1628 def __init__(self, minidump_name, reader): 1628 def __init__(self, minidump_name, reader):
1629 self.comment_file = minidump_name + ".comments" 1629 self.comment_file = minidump_name + ".comments"
1630 self.address_comments = {} 1630 self.address_comments = {}
1631 self.page_address = {} 1631 self.page_address = {}
1632 if os.path.exists(self.comment_file): 1632 if os.path.exists(self.comment_file):
1633 with open(self.comment_file, "r") as f: 1633 with open(self.comment_file, "r") as f:
1634 lines = f.readlines() 1634 lines = f.readlines()
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 def get_comment(self, address): 1691 def get_comment(self, address):
1692 return self.address_comments.get(address, "") 1692 return self.address_comments.get(address, "")
1693 1693
1694 1694
1695 class InspectionPadawan(object): 1695 class InspectionPadawan(object):
1696 """The padawan can improve annotations by sensing well-known objects.""" 1696 """The padawan can improve annotations by sensing well-known objects."""
1697 def __init__(self, reader, heap): 1697 def __init__(self, reader, heap):
1698 self.reader = reader 1698 self.reader = reader
1699 self.heap = heap 1699 self.heap = heap
1700 self.known_first_map_page = 0 1700 self.known_first_map_page = 0
1701 self.known_first_old_page = 0 1701 self.known_first_data_page = 0
1702 self.known_first_pointer_page = 0
1702 1703
1703 def __getattr__(self, name): 1704 def __getattr__(self, name):
1704 """An InspectionPadawan can be used instead of V8Heap, even though 1705 """An InspectionPadawan can be used instead of V8Heap, even though
1705 it does not inherit from V8Heap (aka. mixin).""" 1706 it does not inherit from V8Heap (aka. mixin)."""
1706 return getattr(self.heap, name) 1707 return getattr(self.heap, name)
1707 1708
1708 def GetPageOffset(self, tagged_address): 1709 def GetPageOffset(self, tagged_address):
1709 return tagged_address & self.heap.PageAlignmentMask() 1710 return tagged_address & self.heap.PageAlignmentMask()
1710 1711
1711 def IsInKnownMapSpace(self, tagged_address): 1712 def IsInKnownMapSpace(self, tagged_address):
1712 page_address = tagged_address & ~self.heap.PageAlignmentMask() 1713 page_address = tagged_address & ~self.heap.PageAlignmentMask()
1713 return page_address == self.known_first_map_page 1714 return page_address == self.known_first_map_page
1714 1715
1715 def IsInKnownOldSpace(self, tagged_address): 1716 def IsInKnownOldSpace(self, tagged_address):
1716 page_address = tagged_address & ~self.heap.PageAlignmentMask() 1717 page_address = tagged_address & ~self.heap.PageAlignmentMask()
1717 return page_address == self.known_first_old_page 1718 return page_address in [self.known_first_data_page,
1719 self.known_first_pointer_page]
1718 1720
1719 def ContainingKnownOldSpaceName(self, tagged_address): 1721 def ContainingKnownOldSpaceName(self, tagged_address):
1720 page_address = tagged_address & ~self.heap.PageAlignmentMask() 1722 page_address = tagged_address & ~self.heap.PageAlignmentMask()
1721 if page_address == self.known_first_old_page: return "OLD_SPACE" 1723 if page_address == self.known_first_data_page: return "OLD_DATA_SPACE"
1724 if page_address == self.known_first_pointer_page: return "OLD_POINTER_SPACE"
1722 return None 1725 return None
1723 1726
1724 def SenseObject(self, tagged_address): 1727 def SenseObject(self, tagged_address):
1725 if self.IsInKnownOldSpace(tagged_address): 1728 if self.IsInKnownOldSpace(tagged_address):
1726 offset = self.GetPageOffset(tagged_address) 1729 offset = self.GetPageOffset(tagged_address)
1727 lookup_key = (self.ContainingKnownOldSpaceName(tagged_address), offset) 1730 lookup_key = (self.ContainingKnownOldSpaceName(tagged_address), offset)
1728 known_obj_name = KNOWN_OBJECTS.get(lookup_key) 1731 known_obj_name = KNOWN_OBJECTS.get(lookup_key)
1729 if known_obj_name: 1732 if known_obj_name:
1730 return KnownObject(self, known_obj_name) 1733 return KnownObject(self, known_obj_name)
1731 if self.IsInKnownMapSpace(tagged_address): 1734 if self.IsInKnownMapSpace(tagged_address):
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 def FindObject(self, tagged_address): 1771 def FindObject(self, tagged_address):
1769 """When used as a mixin in place of V8Heap.""" 1772 """When used as a mixin in place of V8Heap."""
1770 raise NotImplementedError 1773 raise NotImplementedError
1771 1774
1772 def FindMap(self, tagged_address): 1775 def FindMap(self, tagged_address):
1773 """When used as a mixin in place of V8Heap.""" 1776 """When used as a mixin in place of V8Heap."""
1774 raise NotImplementedError 1777 raise NotImplementedError
1775 1778
1776 def PrintKnowledge(self): 1779 def PrintKnowledge(self):
1777 print " known_first_map_page = %s\n"\ 1780 print " known_first_map_page = %s\n"\
1778 " known_first_old_page = %s" % ( 1781 " known_first_data_page = %s\n"\
1782 " known_first_pointer_page = %s" % (
1779 self.reader.FormatIntPtr(self.known_first_map_page), 1783 self.reader.FormatIntPtr(self.known_first_map_page),
1780 self.reader.FormatIntPtr(self.known_first_old_page)) 1784 self.reader.FormatIntPtr(self.known_first_data_page),
1785 self.reader.FormatIntPtr(self.known_first_pointer_page))
1781 1786
1782 WEB_HEADER = """ 1787 WEB_HEADER = """
1783 <!DOCTYPE html> 1788 <!DOCTYPE html>
1784 <html> 1789 <html>
1785 <head> 1790 <head>
1786 <meta content="text/html; charset=utf-8" http-equiv="content-type"> 1791 <meta content="text/html; charset=utf-8" http-equiv="content-type">
1787 <style media="screen" type="text/css"> 1792 <style media="screen" type="text/css">
1788 1793
1789 .code { 1794 .code {
1790 font-family: monospace; 1795 font-family: monospace;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 exception_thread.stack.memory.data_size 2117 exception_thread.stack.memory.data_size
2113 stack_map = {self.reader.ExceptionIP(): -1} 2118 stack_map = {self.reader.ExceptionIP(): -1}
2114 for slot in xrange(stack_top, stack_bottom, self.reader.PointerSize()): 2119 for slot in xrange(stack_top, stack_bottom, self.reader.PointerSize()):
2115 maybe_address = self.reader.ReadUIntPtr(slot) 2120 maybe_address = self.reader.ReadUIntPtr(slot)
2116 if not maybe_address in stack_map: 2121 if not maybe_address in stack_map:
2117 stack_map[maybe_address] = slot 2122 stack_map[maybe_address] = slot
2118 self.heap = V8Heap(self.reader, stack_map) 2123 self.heap = V8Heap(self.reader, stack_map)
2119 2124
2120 self.padawan = InspectionPadawan(self.reader, self.heap) 2125 self.padawan = InspectionPadawan(self.reader, self.heap)
2121 self.comments = InspectionInfo(minidump_name, self.reader) 2126 self.comments = InspectionInfo(minidump_name, self.reader)
2122 self.padawan.known_first_old_page = ( 2127 self.padawan.known_first_data_page = (
2123 self.comments.get_page_address("oldpage")) 2128 self.comments.get_page_address("datapage"))
2124 self.padawan.known_first_map_page = ( 2129 self.padawan.known_first_map_page = (
2125 self.comments.get_page_address("mappage")) 2130 self.comments.get_page_address("mappage"))
2131 self.padawan.known_first_pointer_page = (
2132 self.comments.get_page_address("pointerpage"))
2126 2133
2127 def set_comment(self, straddress, comment): 2134 def set_comment(self, straddress, comment):
2128 try: 2135 try:
2129 address = int(straddress, 0) 2136 address = int(straddress, 0)
2130 self.comments.set_comment(address, comment) 2137 self.comments.set_comment(address, comment)
2131 except ValueError: 2138 except ValueError:
2132 print "Invalid address" 2139 print "Invalid address"
2133 2140
2134 def set_page_address(self, kind, straddress): 2141 def set_page_address(self, kind, straddress):
2135 try: 2142 try:
2136 address = int(straddress, 0) 2143 address = int(straddress, 0)
2137 if kind == "oldpage": 2144 if kind == "datapage":
2138 self.padawan.known_first_old_page = address 2145 self.padawan.known_first_data_page = address
2139 elif kind == "mappage": 2146 elif kind == "mappage":
2140 self.padawan.known_first_map_page = address 2147 self.padawan.known_first_map_page = address
2148 elif kind == "pointerpage":
2149 self.padawan.known_first_pointer_page = address
2141 self.comments.save_page_address(kind, address) 2150 self.comments.save_page_address(kind, address)
2142 except ValueError: 2151 except ValueError:
2143 print "Invalid address" 2152 print "Invalid address"
2144 2153
2145 def td_from_address(self, f, address): 2154 def td_from_address(self, f, address):
2146 f.write("<td %s>" % self.comments.get_style_class_string(address)) 2155 f.write("<td %s>" % self.comments.get_style_class_string(address))
2147 2156
2148 def format_address(self, maybeaddress, straddress = None): 2157 def format_address(self, maybeaddress, straddress = None):
2149 if maybeaddress is None: 2158 if maybeaddress is None:
2150 return "not in dump" 2159 return "not in dump"
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 2610
2602 address = int(straddress, 0) 2611 address = int(straddress, 0)
2603 2612
2604 f.write("Comment: ") 2613 f.write("Comment: ")
2605 self.output_comment_box(f, "search-", address) 2614 self.output_comment_box(f, "search-", address)
2606 f.write("<br>\n") 2615 f.write("<br>\n")
2607 2616
2608 page_address = address & ~self.heap.PageAlignmentMask() 2617 page_address = address & ~self.heap.PageAlignmentMask()
2609 2618
2610 f.write("Page info: \n") 2619 f.write("Page info: \n")
2611 self.output_page_info(f, "old", self.padawan.known_first_old_page, \ 2620 self.output_page_info(f, "data", self.padawan.known_first_data_page, \
2612 page_address) 2621 page_address)
2613 self.output_page_info(f, "map", self.padawan.known_first_map_page, \ 2622 self.output_page_info(f, "map", self.padawan.known_first_map_page, \
2614 page_address) 2623 page_address)
2624 self.output_page_info(f, "pointer", \
2625 self.padawan.known_first_pointer_page, \
2626 page_address)
2615 2627
2616 if not self.reader.IsValidAddress(address): 2628 if not self.reader.IsValidAddress(address):
2617 f.write("<h3>The contents at address %s not found in the dump.</h3>" % \ 2629 f.write("<h3>The contents at address %s not found in the dump.</h3>" % \
2618 straddress) 2630 straddress)
2619 else: 2631 else:
2620 # Print as words 2632 # Print as words
2621 self.output_words(f, address - 8, address + 32, address, "Dump") 2633 self.output_words(f, address - 8, address + 32, address, "Dump")
2622 2634
2623 # Print as ASCII 2635 # Print as ASCII
2624 f.write("<hr>\n") 2636 f.write("<hr>\n")
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 2918
2907 def do_k(self, arguments): 2919 def do_k(self, arguments):
2908 """ 2920 """
2909 Teach V8 heap layout information to the inspector. This increases 2921 Teach V8 heap layout information to the inspector. This increases
2910 the amount of annotations the inspector can produce while dumping 2922 the amount of annotations the inspector can produce while dumping
2911 data. The first page of each heap space is of particular interest 2923 data. The first page of each heap space is of particular interest
2912 because it contains known objects that do not move. 2924 because it contains known objects that do not move.
2913 """ 2925 """
2914 self.padawan.PrintKnowledge() 2926 self.padawan.PrintKnowledge()
2915 2927
2916 def do_ko(self, address): 2928 def do_kd(self, address):
2917 """ 2929 """
2918 Teach V8 heap layout information to the inspector. Set the first 2930 Teach V8 heap layout information to the inspector. Set the first
2919 old space page by passing any pointer into that page. 2931 data-space page by passing any pointer into that page.
2920 """ 2932 """
2921 address = int(address, 16) 2933 address = int(address, 16)
2922 page_address = address & ~self.heap.PageAlignmentMask() 2934 page_address = address & ~self.heap.PageAlignmentMask()
2923 self.padawan.known_first_old_page = page_address 2935 self.padawan.known_first_data_page = page_address
2924 2936
2925 def do_km(self, address): 2937 def do_km(self, address):
2926 """ 2938 """
2927 Teach V8 heap layout information to the inspector. Set the first 2939 Teach V8 heap layout information to the inspector. Set the first
2928 map-space page by passing any pointer into that page. 2940 map-space page by passing any pointer into that page.
2929 """ 2941 """
2930 address = int(address, 16) 2942 address = int(address, 16)
2931 page_address = address & ~self.heap.PageAlignmentMask() 2943 page_address = address & ~self.heap.PageAlignmentMask()
2932 self.padawan.known_first_map_page = page_address 2944 self.padawan.known_first_map_page = page_address
2933 2945
2946 def do_kp(self, address):
2947 """
2948 Teach V8 heap layout information to the inspector. Set the first
2949 pointer-space page by passing any pointer into that page.
2950 """
2951 address = int(address, 16)
2952 page_address = address & ~self.heap.PageAlignmentMask()
2953 self.padawan.known_first_pointer_page = page_address
2954
2934 def do_list(self, smth): 2955 def do_list(self, smth):
2935 """ 2956 """
2936 List all available memory regions. 2957 List all available memory regions.
2937 """ 2958 """
2938 def print_region(reader, start, size, location): 2959 def print_region(reader, start, size, location):
2939 print " %s - %s (%d bytes)" % (reader.FormatIntPtr(start), 2960 print " %s - %s (%d bytes)" % (reader.FormatIntPtr(start),
2940 reader.FormatIntPtr(start + size), 2961 reader.FormatIntPtr(start + size),
2941 size) 2962 size)
2942 print "Available memory regions:" 2963 print "Available memory regions:"
2943 self.reader.ForEachMemoryRegion(print_region) 2964 self.reader.ForEachMemoryRegion(print_region)
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 try: 3185 try:
3165 server = InspectionWebServer(PORT_NUMBER, options, args[0]) 3186 server = InspectionWebServer(PORT_NUMBER, options, args[0])
3166 print 'Started httpserver on port ' , PORT_NUMBER 3187 print 'Started httpserver on port ' , PORT_NUMBER
3167 webbrowser.open('http://localhost:%i/summary.html' % PORT_NUMBER) 3188 webbrowser.open('http://localhost:%i/summary.html' % PORT_NUMBER)
3168 server.serve_forever() 3189 server.serve_forever()
3169 except KeyboardInterrupt: 3190 except KeyboardInterrupt:
3170 print '^C received, shutting down the web server' 3191 print '^C received, shutting down the web server'
3171 server.socket.close() 3192 server.socket.close()
3172 else: 3193 else:
3173 AnalyzeMinidump(options, args[0]) 3194 AnalyzeMinidump(options, args[0])
OLDNEW
« no previous file with comments | « test/cctest/test-weaksets.cc ('k') | tools/oom_dump/oom_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698