| 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_IA32) | 8 #if defined(TARGET_ARCH_IA32) |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 const char* full_class_name = clazz.ToCString(); | 478 const char* full_class_name = clazz.ToCString(); |
| 479 const char* format = "instance of %s"; | 479 const char* format = "instance of %s"; |
| 480 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1; | 480 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1; |
| 481 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 481 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 482 OS::SNPrint(chars, len, format, full_class_name); | 482 OS::SNPrint(chars, len, format, full_class_name); |
| 483 return chars; | 483 return chars; |
| 484 } | 484 } |
| 485 | 485 |
| 486 | 486 |
| 487 void X86Decoder::PrintAddress(uword addr) { | 487 void X86Decoder::PrintAddress(uword addr) { |
| 488 NoGCScope no_gc; | |
| 489 char addr_buffer[32]; | 488 char addr_buffer[32]; |
| 490 OS::SNPrint(addr_buffer, sizeof(addr_buffer), "%#" Px "", addr); | 489 OS::SNPrint(addr_buffer, sizeof(addr_buffer), "%#" Px "", addr); |
| 491 Print(addr_buffer); | 490 Print(addr_buffer); |
| 492 // Try to print as heap object or stub name | 491 // Try to print as heap object or stub name |
| 493 if (((addr & kSmiTagMask) == kHeapObjectTag) && | 492 if (((addr & kSmiTagMask) == kHeapObjectTag) && |
| 494 reinterpret_cast<RawObject*>(addr)->IsOldObject() && | 493 reinterpret_cast<RawObject*>(addr)->IsOldObject() && |
| 495 !Isolate::Current()->heap()->CodeContains(addr) && | 494 !Isolate::Current()->heap()->CodeContains(addr) && |
| 496 Disassembler::CanFindOldObject(addr)) { | 495 Disassembler::CanFindOldObject(addr)) { |
| 496 NoGCScope no_gc; |
| 497 const Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); | 497 const Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); |
| 498 if (obj.IsArray()) { | 498 if (obj.IsArray()) { |
| 499 const Array& arr = Array::Cast(obj); | 499 const Array& arr = Array::Cast(obj); |
| 500 intptr_t len = arr.Length(); | 500 intptr_t len = arr.Length(); |
| 501 if (len > 5) len = 5; // Print a max of 5 elements. | 501 if (len > 5) len = 5; // Print a max of 5 elements. |
| 502 Print(" Array["); | 502 Print(" Array["); |
| 503 int i = 0; | 503 int i = 0; |
| 504 Object& element = Object::Handle(); | 504 Object& element = Object::Handle(); |
| 505 while (i < len) { | 505 while (i < len) { |
| 506 element = arr.At(i); | 506 element = arr.At(i); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 519 // 'addr' is not an object, but probably a code address. | 519 // 'addr' is not an object, but probably a code address. |
| 520 const char* name_of_stub = StubCode::NameOfStub(addr); | 520 const char* name_of_stub = StubCode::NameOfStub(addr); |
| 521 if (name_of_stub != NULL) { | 521 if (name_of_stub != NULL) { |
| 522 Print(" [stub: "); | 522 Print(" [stub: "); |
| 523 Print(name_of_stub); | 523 Print(name_of_stub); |
| 524 Print("]"); | 524 Print("]"); |
| 525 } else { | 525 } else { |
| 526 // Print only if jumping to entry point. | 526 // Print only if jumping to entry point. |
| 527 const Code& code = Code::Handle(Code::LookupCode(addr)); | 527 const Code& code = Code::Handle(Code::LookupCode(addr)); |
| 528 if (!code.IsNull() && (code.EntryPoint() == addr)) { | 528 if (!code.IsNull() && (code.EntryPoint() == addr)) { |
| 529 const Function& function = Function::Handle(code.function()); | 529 const String& name = String::Handle(code.UserName()); |
| 530 if (function.IsNull()) { | 530 const char* name_c = name.ToCString(); |
| 531 Print(" [ stub ]"); | 531 Print(" ["); |
| 532 } else { | 532 Print(name_c); |
| 533 const char* name_of_function = function.ToFullyQualifiedCString(); | 533 Print("]"); |
| 534 Print(" ["); | |
| 535 Print(name_of_function); | |
| 536 Print("]"); | |
| 537 } | |
| 538 } | 534 } |
| 539 } | 535 } |
| 540 } | 536 } |
| 541 } | 537 } |
| 542 | 538 |
| 543 | 539 |
| 544 int X86Decoder::PrintRightOperandHelper(uint8_t* modrmp, | 540 int X86Decoder::PrintRightOperandHelper(uint8_t* modrmp, |
| 545 RegisterNamePrinter register_printer) { | 541 RegisterNamePrinter register_printer) { |
| 546 int mod, regop, rm; | 542 int mod, regop, rm; |
| 547 GetModRm(*modrmp, &mod, ®op, &rm); | 543 GetModRm(*modrmp, &mod, ®op, &rm); |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 pc); | 1857 pc); |
| 1862 pc += instruction_length; | 1858 pc += instruction_length; |
| 1863 } | 1859 } |
| 1864 | 1860 |
| 1865 return; | 1861 return; |
| 1866 } | 1862 } |
| 1867 | 1863 |
| 1868 } // namespace dart | 1864 } // namespace dart |
| 1869 | 1865 |
| 1870 #endif // defined TARGET_ARCH_IA32 | 1866 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |