| 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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 ADDRESS_RE = re.compile(r"0x[0-9a-fA-F]+") | 874 ADDRESS_RE = re.compile(r"0x[0-9a-fA-F]+") |
| 875 | 875 |
| 876 | 876 |
| 877 def FormatDisasmLine(start, heap, line): | 877 def FormatDisasmLine(start, heap, line): |
| 878 line_address = start + line[0] | 878 line_address = start + line[0] |
| 879 stack_slot = heap.stack_map.get(line_address) | 879 stack_slot = heap.stack_map.get(line_address) |
| 880 marker = " " | 880 marker = " " |
| 881 if stack_slot: | 881 if stack_slot: |
| 882 marker = "=>" | 882 marker = "=>" |
| 883 code = AnnotateAddresses(heap, line[1]) | 883 code = AnnotateAddresses(heap, line[1]) |
| 884 |
| 885 # Compute the actual call target which the disassembler is too stupid |
| 886 # to figure out (it adds the call offset to the disassembly offset rather |
| 887 # than the absolute instruction address). |
| 888 if heap.reader.arch == MD_CPU_ARCHITECTURE_X86: |
| 889 if code.startswith("e8"): |
| 890 words = code.split() |
| 891 if len(words) > 6 and words[5] == "call": |
| 892 offset = int(words[4] + words[3] + words[2] + words[1], 16) |
| 893 target = (line_address + offset + 5) & 0xFFFFFFFF |
| 894 code = code.replace(words[6], "0x%08x" % target) |
| 895 # TODO(jkummerow): port this hack to ARM and x64. |
| 896 |
| 884 return "%s%08x %08x: %s" % (marker, line_address, line[0], code) | 897 return "%s%08x %08x: %s" % (marker, line_address, line[0], code) |
| 885 | 898 |
| 886 | 899 |
| 887 def AnnotateAddresses(heap, line): | 900 def AnnotateAddresses(heap, line): |
| 888 extra = [] | 901 extra = [] |
| 889 for m in ADDRESS_RE.finditer(line): | 902 for m in ADDRESS_RE.finditer(line): |
| 890 maybe_address = int(m.group(0), 16) | 903 maybe_address = int(m.group(0), 16) |
| 891 object = heap.FindObject(maybe_address) | 904 object = heap.FindObject(maybe_address) |
| 892 if not object: continue | 905 if not object: continue |
| 893 extra.append(str(object)) | 906 extra.append(str(object)) |
| (...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 options, args = parser.parse_args() | 2008 options, args = parser.parse_args() |
| 1996 if os.path.exists(options.objdump): | 2009 if os.path.exists(options.objdump): |
| 1997 disasm.OBJDUMP_BIN = options.objdump | 2010 disasm.OBJDUMP_BIN = options.objdump |
| 1998 OBJDUMP_BIN = options.objdump | 2011 OBJDUMP_BIN = options.objdump |
| 1999 else: | 2012 else: |
| 2000 print "Cannot find %s, falling back to default objdump" % options.objdump | 2013 print "Cannot find %s, falling back to default objdump" % options.objdump |
| 2001 if len(args) != 1: | 2014 if len(args) != 1: |
| 2002 parser.print_help() | 2015 parser.print_help() |
| 2003 sys.exit(1) | 2016 sys.exit(1) |
| 2004 AnalyzeMinidump(options, args[0]) | 2017 AnalyzeMinidump(options, args[0]) |
| OLD | NEW |