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

Side by Side Diff: tools/grokdump.py

Issue 23465027: Fix string and descriptor array decoding in grokdump. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 p.Print("TransitionsOrBackPointer: %s" % (transitions)) 1022 p.Print("TransitionsOrBackPointer: %s" % (transitions))
1023 1023
1024 def __init__(self, heap, map, address): 1024 def __init__(self, heap, map, address):
1025 HeapObject.__init__(self, heap, map, address) 1025 HeapObject.__init__(self, heap, map, address)
1026 self.instance_type = \ 1026 self.instance_type = \
1027 heap.reader.ReadU8(self.address + self.InstanceTypeOffset()) 1027 heap.reader.ReadU8(self.address + self.InstanceTypeOffset())
1028 1028
1029 1029
1030 class String(HeapObject): 1030 class String(HeapObject):
1031 def LengthOffset(self): 1031 def LengthOffset(self):
1032 return self.heap.PointerSize() 1032 # First word after the map is the hash, the second is the length.
1033 return self.heap.PointerSize() * 2
1033 1034
1034 def __init__(self, heap, map, address): 1035 def __init__(self, heap, map, address):
1035 HeapObject.__init__(self, heap, map, address) 1036 HeapObject.__init__(self, heap, map, address)
1036 self.length = self.SmiField(self.LengthOffset()) 1037 self.length = self.SmiField(self.LengthOffset())
1037 1038
1038 def GetChars(self): 1039 def GetChars(self):
1039 return "?string?" 1040 return "?string?"
1040 1041
1041 def Print(self, p): 1042 def Print(self, p):
1042 p.Print(str(self)) 1043 p.Print(str(self))
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 attributes = self.Decode(3, 3, value) 1209 attributes = self.Decode(3, 3, value)
1209 result = [] 1210 result = []
1210 if (attributes & 0): result += ["ReadOnly"] 1211 if (attributes & 0): result += ["ReadOnly"]
1211 if (attributes & 1): result += ["DontEnum"] 1212 if (attributes & 1): result += ["DontEnum"]
1212 if (attributes & 2): result += ["DontDelete"] 1213 if (attributes & 2): result += ["DontDelete"]
1213 return "[" + (",".join(result)) + "]" 1214 return "[" + (",".join(result)) + "]"
1214 1215
1215 def Deleted(self, value): 1216 def Deleted(self, value):
1216 return self.Decode(6, 1, value) == 1 1217 return self.Decode(6, 1, value) == 1
1217 1218
1218 def Storage(self, value): 1219 def FieldIndex(self, value):
1219 return self.Decode(7, 11, value) 1220 return self.Decode(20, 11, value)
1220 1221
1221 def Pointer(self, value): 1222 def Pointer(self, value):
1222 return self.Decode(18, 11, value) 1223 return self.Decode(6, 11, value)
1223 1224
1224 def Details(self, di, value): 1225 def Details(self, di, value):
1225 return ( 1226 return (
1226 di, 1227 di,
1227 self.Type(value), 1228 self.Type(value),
1228 self.Attributes(value), 1229 self.Attributes(value),
1229 self.Storage(value), 1230 self.FieldIndex(value),
1230 self.Pointer(value) 1231 self.Pointer(value)
1231 ) 1232 )
1232 1233
1233 1234
1234 def Print(self, p): 1235 def Print(self, p):
1235 length = self.Length() 1236 length = self.Length()
1236 array = self.array 1237 array = self.array
1237 1238
1238 p.Print("Descriptors(%08x, length=%d)" % (array.address, length)) 1239 p.Print("Descriptors(%08x, length=%d)" % (array.address, length))
1239 p.Print("[et] %s" % (array.Get(1))) 1240 p.Print("[et] %s" % (array.Get(1)))
1240 1241
1241 for di in xrange(length): 1242 for di in xrange(length):
1242 i = 2 + di * 3 1243 i = 2 + di * 3
1243 p.Print("0x%x" % (array.address + array.MemberOffset(i))) 1244 p.Print("0x%x" % (array.address + array.MemberOffset(i)))
1244 p.Print("[%i] name: %s" % (di, array.Get(i + 0))) 1245 p.Print("[%i] name: %s" % (di, array.Get(i + 0)))
1245 p.Print("[%i] details: %s %s enum %i pointer %i" % \ 1246 p.Print("[%i] details: %s %s field-index %i pointer %i" % \
1246 self.Details(di, array.Get(i + 1))) 1247 self.Details(di, array.Get(i + 1)))
1247 p.Print("[%i] value: %s" % (di, array.Get(i + 2))) 1248 p.Print("[%i] value: %s" % (di, array.Get(i + 2)))
1248 1249
1249 end = self.array.length // 3 1250 end = self.array.length // 3
1250 if length != end: 1251 if length != end:
1251 p.Print("[%i-%i] slack descriptors" % (length, end)) 1252 p.Print("[%i-%i] slack descriptors" % (length, end))
1252 1253
1253 1254
1254 class TransitionArray(object): 1255 class TransitionArray(object):
1255 def __init__(self, array): 1256 def __init__(self, array):
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 options, args = parser.parse_args() 1995 options, args = parser.parse_args()
1995 if os.path.exists(options.objdump): 1996 if os.path.exists(options.objdump):
1996 disasm.OBJDUMP_BIN = options.objdump 1997 disasm.OBJDUMP_BIN = options.objdump
1997 OBJDUMP_BIN = options.objdump 1998 OBJDUMP_BIN = options.objdump
1998 else: 1999 else:
1999 print "Cannot find %s, falling back to default objdump" % options.objdump 2000 print "Cannot find %s, falling back to default objdump" % options.objdump
2000 if len(args) != 1: 2001 if len(args) != 1:
2001 parser.print_help() 2002 parser.print_help()
2002 sys.exit(1) 2003 sys.exit(1)
2003 AnalyzeMinidump(options, args[0]) 2004 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