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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 char* buffer_; // Decode instructions into this buffer. | 330 char* buffer_; // Decode instructions into this buffer. |
331 intptr_t buffer_size_; // The size of the buffer_. | 331 intptr_t buffer_size_; // The size of the buffer_. |
332 intptr_t buffer_pos_; // Current character position in the buffer_. | 332 intptr_t buffer_pos_; // Current character position in the buffer_. |
333 | 333 |
334 DISALLOW_COPY_AND_ASSIGN(X86Decoder); | 334 DISALLOW_COPY_AND_ASSIGN(X86Decoder); |
335 }; | 335 }; |
336 | 336 |
337 | 337 |
338 void X86Decoder::PrintInt(int value) { | 338 void X86Decoder::PrintInt(int value) { |
339 char int_buffer[16]; | 339 char int_buffer[16]; |
340 OS::SNPrint(int_buffer, sizeof(int_buffer), "0x%x", value); | 340 OS::SNPrint(int_buffer, sizeof(int_buffer), "%#x", value); |
341 Print(int_buffer); | 341 Print(int_buffer); |
342 } | 342 } |
343 | 343 |
344 | 344 |
345 // Append the int value (printed in hex) to the output buffer. | 345 // Append the int value (printed in hex) to the output buffer. |
346 void X86Decoder::PrintHex(int value) { | 346 void X86Decoder::PrintHex(int value) { |
347 char hex_buffer[16]; | 347 char hex_buffer[16]; |
348 OS::SNPrint(hex_buffer, sizeof(hex_buffer), "0x%x", value); | 348 OS::SNPrint(hex_buffer, sizeof(hex_buffer), "%#x", value); |
349 Print(hex_buffer); | 349 Print(hex_buffer); |
350 } | 350 } |
351 | 351 |
352 | 352 |
353 // Append the str to the output buffer. | 353 // Append the str to the output buffer. |
354 void X86Decoder::Print(const char* str) { | 354 void X86Decoder::Print(const char* str) { |
355 char cur = *str++; | 355 char cur = *str++; |
356 while (cur != '\0' && (buffer_pos_ < (buffer_size_ - 1))) { | 356 while (cur != '\0' && (buffer_pos_ < (buffer_size_ - 1))) { |
357 buffer_[buffer_pos_++] = cur; | 357 buffer_[buffer_pos_++] = cur; |
358 cur = *str++; | 358 cur = *str++; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1; | 411 intptr_t len = OS::SNPrint(NULL, 0, format, full_class_name) + 1; |
412 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 412 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
413 OS::SNPrint(chars, len, format, full_class_name); | 413 OS::SNPrint(chars, len, format, full_class_name); |
414 return chars; | 414 return chars; |
415 } | 415 } |
416 | 416 |
417 | 417 |
418 void X86Decoder::PrintAddress(uword addr) { | 418 void X86Decoder::PrintAddress(uword addr) { |
419 NoGCScope no_gc; | 419 NoGCScope no_gc; |
420 char addr_buffer[32]; | 420 char addr_buffer[32]; |
421 OS::SNPrint(addr_buffer, sizeof(addr_buffer), "%p", addr); | 421 OS::SNPrint(addr_buffer, sizeof(addr_buffer), "%#"Px"", addr); |
422 Print(addr_buffer); | 422 Print(addr_buffer); |
423 // Try to print as heap object or stub name | 423 // Try to print as heap object or stub name |
424 if (!Isolate::Current()->heap()->CodeContains(addr) && | 424 if (!Isolate::Current()->heap()->CodeContains(addr) && |
425 Isolate::Current()->heap()->Contains(addr - kHeapObjectTag)) { | 425 Isolate::Current()->heap()->Contains(addr - kHeapObjectTag)) { |
426 Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); | 426 Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr)); |
427 if (obj.IsArray()) { | 427 if (obj.IsArray()) { |
428 const Array& arr = Array::CheckedHandle(obj.raw()); | 428 const Array& arr = Array::CheckedHandle(obj.raw()); |
429 intptr_t len = arr.Length(); | 429 intptr_t len = arr.Length(); |
430 if (len > 5) len = 5; // Print a max of 5 elements. | 430 if (len > 5) len = 5; // Print a max of 5 elements. |
431 Print(" Array["); | 431 Print(" Array["); |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 } | 1573 } |
1574 case 0xF7: | 1574 case 0xF7: |
1575 data += F7Instruction(data); | 1575 data += F7Instruction(data); |
1576 break; | 1576 break; |
1577 | 1577 |
1578 case 0xC8: | 1578 case 0xC8: |
1579 data += DecodeEnter(data); | 1579 data += DecodeEnter(data); |
1580 break; | 1580 break; |
1581 | 1581 |
1582 default: | 1582 default: |
1583 OS::Print("Unknown case 0x%x\n", *data); | 1583 OS::Print("Unknown case %#x\n", *data); |
1584 UNIMPLEMENTED(); | 1584 UNIMPLEMENTED(); |
1585 } | 1585 } |
1586 } | 1586 } |
1587 | 1587 |
1588 int instr_len = data - reinterpret_cast<uint8_t*>(pc); | 1588 int instr_len = data - reinterpret_cast<uint8_t*>(pc); |
1589 ASSERT(instr_len > 0); // Ensure progress. | 1589 ASSERT(instr_len > 0); // Ensure progress. |
1590 | 1590 |
1591 return instr_len; | 1591 return instr_len; |
1592 } | 1592 } |
1593 | 1593 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 human_buffer, | 1639 human_buffer, |
1640 sizeof(human_buffer), | 1640 sizeof(human_buffer), |
1641 pc); | 1641 pc); |
1642 pc += instruction_length; | 1642 pc += instruction_length; |
1643 } | 1643 } |
1644 } | 1644 } |
1645 | 1645 |
1646 } // namespace dart | 1646 } // namespace dart |
1647 | 1647 |
1648 #endif // defined TARGET_ARCH_IA32 | 1648 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |