| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 383 } |
| 384 | 384 |
| 385 | 385 |
| 386 void X86Decoder::PrintXmmRegister(int reg) { | 386 void X86Decoder::PrintXmmRegister(int reg) { |
| 387 ASSERT(0 <= reg); | 387 ASSERT(0 <= reg); |
| 388 ASSERT(reg < kMaxXmmRegisters); | 388 ASSERT(reg < kMaxXmmRegisters); |
| 389 Print(xmm_regs[reg]); | 389 Print(xmm_regs[reg]); |
| 390 } | 390 } |
| 391 | 391 |
| 392 | 392 |
| 393 static const char* ObjectToCStringNoGC(const Object& obj) { |
| 394 if (obj.IsSmi() || |
| 395 obj.IsMint() || |
| 396 obj.IsDouble() || |
| 397 obj.IsString() || |
| 398 obj.IsNull() || |
| 399 obj.IsBool() || |
| 400 obj.IsClass() || |
| 401 obj.IsFunction() || |
| 402 obj.IsICData() || |
| 403 obj.IsField()) { |
| 404 return obj.ToCString(); |
| 405 } |
| 406 |
| 407 const Class& clazz = Class::CheckedHandle(obj.clazz()); |
| 408 const char* full_class_name = clazz.ToCString(); |
| 409 const char* format = "instance of %s"; |
| 410 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1; |
| 411 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 412 OS::SNPrint(chars, len, format, full_class_name); |
| 413 return chars; |
| 414 } |
| 415 |
| 416 |
| 393 void X86Decoder::PrintAddress(uword addr) { | 417 void X86Decoder::PrintAddress(uword addr) { |
| 394 NoGCScope no_gc; | 418 NoGCScope no_gc; |
| 395 char addr_buffer[32]; | 419 char addr_buffer[32]; |
| 396 OS::SNPrint(addr_buffer, sizeof(addr_buffer), "%p", addr); | 420 OS::SNPrint(addr_buffer, sizeof(addr_buffer), "%p", addr); |
| 397 Print(addr_buffer); | 421 Print(addr_buffer); |
| 398 // Try to print as heap object or stub name | 422 // Try to print as heap object or stub name |
| 399 if (!Isolate::Current()->heap()->CodeContains(addr) && | 423 if (!Isolate::Current()->heap()->CodeContains(addr) && |
| 400 Isolate::Current()->heap()->Contains(addr - kHeapObjectTag)) { | 424 Isolate::Current()->heap()->Contains(addr - kHeapObjectTag)) { |
| 401 Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); | 425 Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); |
| 402 if (obj.IsArray()) { | 426 if (obj.IsArray()) { |
| 403 const Array& arr = Array::CheckedHandle(obj.raw()); | 427 const Array& arr = Array::CheckedHandle(obj.raw()); |
| 404 intptr_t len = arr.Length(); | 428 intptr_t len = arr.Length(); |
| 405 if (len > 5) len = 5; // Print a max of 5 elements. | 429 if (len > 5) len = 5; // Print a max of 5 elements. |
| 406 Print(" Array["); | 430 Print(" Array["); |
| 407 int i = 0; | 431 int i = 0; |
| 408 while (i < len) { | 432 while (i < len) { |
| 409 obj = arr.At(i); | 433 obj = arr.At(i); |
| 410 if (i > 0) Print(", "); | 434 if (i > 0) Print(", "); |
| 411 Print(obj.ToCString()); | 435 Print(ObjectToCStringNoGC(obj)); |
| 412 i++; | 436 i++; |
| 413 } | 437 } |
| 414 if (i < arr.Length()) Print(", ..."); | 438 if (i < arr.Length()) Print(", ..."); |
| 415 Print("]"); | 439 Print("]"); |
| 416 return; | 440 return; |
| 417 } | 441 } |
| 418 Print(" '"); | 442 Print(" '"); |
| 419 Print(obj.ToCString()); | 443 Print(ObjectToCStringNoGC(obj)); |
| 420 Print("'"); | 444 Print("'"); |
| 421 } else { | 445 } else { |
| 422 // 'addr' is not an object, but probably a code address. | 446 // 'addr' is not an object, but probably a code address. |
| 423 const char* name_of_stub = StubCode::NameOfStub(addr); | 447 const char* name_of_stub = StubCode::NameOfStub(addr); |
| 424 if (name_of_stub != NULL) { | 448 if (name_of_stub != NULL) { |
| 425 Print(" [stub: "); | 449 Print(" [stub: "); |
| 426 Print(name_of_stub); | 450 Print(name_of_stub); |
| 427 Print("]"); | 451 Print("]"); |
| 428 } else { | 452 } else { |
| 429 // Print only if jumping to entry point. | 453 // Print only if jumping to entry point. |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 human_buffer, | 1629 human_buffer, |
| 1606 sizeof(human_buffer), | 1630 sizeof(human_buffer), |
| 1607 pc); | 1631 pc); |
| 1608 pc += instruction_length; | 1632 pc += instruction_length; |
| 1609 } | 1633 } |
| 1610 } | 1634 } |
| 1611 | 1635 |
| 1612 } // namespace dart | 1636 } // namespace dart |
| 1613 | 1637 |
| 1614 #endif // defined TARGET_ARCH_IA32 | 1638 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |