| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/disassembler.h" | 5 #include "vm/disassembler.h" |
| 6 | 6 |
| 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 8 #if defined(TARGET_ARCH_X64) | 8 #if defined(TARGET_ARCH_X64) |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 const char* full_class_name = clazz.ToCString(); | 795 const char* full_class_name = clazz.ToCString(); |
| 796 const char* format = "instance of %s"; | 796 const char* format = "instance of %s"; |
| 797 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1; | 797 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1; |
| 798 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 798 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 799 OS::SNPrint(chars, len, format, full_class_name); | 799 OS::SNPrint(chars, len, format, full_class_name); |
| 800 return chars; | 800 return chars; |
| 801 } | 801 } |
| 802 | 802 |
| 803 | 803 |
| 804 void DisassemblerX64::AppendAddressToBuffer(uint8_t* addr_byte_ptr) { | 804 void DisassemblerX64::AppendAddressToBuffer(uint8_t* addr_byte_ptr) { |
| 805 NoGCScope no_gc; | |
| 806 uword addr = reinterpret_cast<uword>(addr_byte_ptr); | 805 uword addr = reinterpret_cast<uword>(addr_byte_ptr); |
| 807 AppendToBuffer("%#" Px "", addr); | 806 AppendToBuffer("%#" Px "", addr); |
| 808 // Try to print as heap object or stub name | 807 // Try to print as heap object or stub name |
| 809 if (((addr & kSmiTagMask) == kHeapObjectTag) && | 808 if (((addr & kSmiTagMask) == kHeapObjectTag) && |
| 810 reinterpret_cast<RawObject*>(addr)->IsOldObject() && | 809 reinterpret_cast<RawObject*>(addr)->IsOldObject() && |
| 811 !Isolate::Current()->heap()->CodeContains(addr) && | 810 !Isolate::Current()->heap()->CodeContains(addr) && |
| 812 Disassembler::CanFindOldObject(addr)) { | 811 Disassembler::CanFindOldObject(addr)) { |
| 812 NoGCScope no_gc; |
| 813 const Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); | 813 const Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); |
| 814 if (obj.IsArray()) { | 814 if (obj.IsArray()) { |
| 815 const Array& arr = Array::Cast(obj); | 815 const Array& arr = Array::Cast(obj); |
| 816 intptr_t len = arr.Length(); | 816 intptr_t len = arr.Length(); |
| 817 if (len > 5) len = 5; // Print a max of 5 elements. | 817 if (len > 5) len = 5; // Print a max of 5 elements. |
| 818 AppendToBuffer(" Array["); | 818 AppendToBuffer(" Array["); |
| 819 int i = 0; | 819 int i = 0; |
| 820 Object& element = Object::Handle(); | 820 Object& element = Object::Handle(); |
| 821 while (i < len) { | 821 while (i < len) { |
| 822 element = arr.At(i); | 822 element = arr.At(i); |
| 823 if (i > 0) AppendToBuffer(", "); | 823 if (i > 0) AppendToBuffer(", "); |
| 824 AppendToBuffer("%s", ObjectToCStringNoGC(element)); | 824 AppendToBuffer("%s", ObjectToCStringNoGC(element)); |
| 825 i++; | 825 i++; |
| 826 } | 826 } |
| 827 if (i < arr.Length()) AppendToBuffer(", ..."); | 827 if (i < arr.Length()) AppendToBuffer(", ..."); |
| 828 AppendToBuffer("]"); | 828 AppendToBuffer("]"); |
| 829 return; | 829 return; |
| 830 } | 830 } |
| 831 AppendToBuffer(" '%s'", ObjectToCStringNoGC(obj)); | 831 AppendToBuffer(" '%s'", ObjectToCStringNoGC(obj)); |
| 832 } else { | 832 } else { |
| 833 // 'addr' is not an object, but probably a code address. | 833 // 'addr' is not an object, but probably a code address. |
| 834 const char* name_of_stub = StubCode::NameOfStub(addr); | 834 const char* name_of_stub = StubCode::NameOfStub(addr); |
| 835 if (name_of_stub != NULL) { | 835 if (name_of_stub != NULL) { |
| 836 AppendToBuffer(" [stub: %s]", name_of_stub); | 836 AppendToBuffer(" [stub: %s]", name_of_stub); |
| 837 } else { | 837 } else { |
| 838 // Print only if jumping to entry point. | 838 // Print only if jumping to entry point. |
| 839 const Code& code = Code::Handle(Code::LookupCode(addr)); | 839 const Code& code = Code::Handle(Code::LookupCode(addr)); |
| 840 if (!code.IsNull() && (code.EntryPoint() == addr)) { | 840 if (!code.IsNull() && (code.EntryPoint() == addr)) { |
| 841 const Function& function = Function::Handle(code.function()); | 841 const String& name = String::Handle(code.UserName()); |
| 842 if (function.IsNull()) { | 842 const char* name_c = name.ToCString(); |
| 843 AppendToBuffer(" [ stub ]"); | 843 AppendToBuffer(" [%s]", name_c); |
| 844 } else { | |
| 845 const char* name_of_function = function.ToFullyQualifiedCString(); | |
| 846 AppendToBuffer(" [%s]", name_of_function); | |
| 847 } | |
| 848 } | 844 } |
| 849 } | 845 } |
| 850 } | 846 } |
| 851 } | 847 } |
| 852 | 848 |
| 853 | 849 |
| 854 // Returns number of bytes used, including *data. | 850 // Returns number of bytes used, including *data. |
| 855 int DisassemblerX64::JumpShort(uint8_t* data) { | 851 int DisassemblerX64::JumpShort(uint8_t* data) { |
| 856 ASSERT(0xEB == *data); | 852 ASSERT(0xEB == *data); |
| 857 uint8_t b = *(data + 1); | 853 uint8_t b = *(data + 1); |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 pc); | 1960 pc); |
| 1965 pc += instruction_length; | 1961 pc += instruction_length; |
| 1966 } | 1962 } |
| 1967 | 1963 |
| 1968 return; | 1964 return; |
| 1969 } | 1965 } |
| 1970 | 1966 |
| 1971 } // namespace dart | 1967 } // namespace dart |
| 1972 | 1968 |
| 1973 #endif // defined TARGET_ARCH_X64 | 1969 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |