| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 void DisassembleToStdout::ConsumeInstruction(char* hex_buffer, | 13 void DisassembleToStdout::ConsumeInstruction(char* hex_buffer, |
| 14 intptr_t hex_size, | 14 intptr_t hex_size, |
| 15 char* human_buffer, | 15 char* human_buffer, |
| 16 intptr_t human_size, | 16 intptr_t human_size, |
| 17 uword pc) { | 17 uword pc) { |
| 18 static const int kHexColumnWidth = 18; | 18 static const int kHexColumnWidth = 23; |
| 19 uint8_t* pc_ptr = reinterpret_cast<uint8_t*>(pc); | 19 uint8_t* pc_ptr = reinterpret_cast<uint8_t*>(pc); |
| 20 OS::Print("%p %s", pc_ptr, hex_buffer); | 20 OS::Print("%p %s", pc_ptr, hex_buffer); |
| 21 int hex_length = strlen(hex_buffer); | 21 int hex_length = strlen(hex_buffer); |
| 22 if (hex_length < kHexColumnWidth) { | 22 if (hex_length < kHexColumnWidth) { |
| 23 for (int i = kHexColumnWidth - hex_length; i > 0; i--) { | 23 for (int i = kHexColumnWidth - hex_length; i > 0; i--) { |
| 24 OS::Print(" "); | 24 OS::Print(" "); |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 OS::Print("%s", human_buffer); | 27 OS::Print("%s", human_buffer); |
| 28 OS::Print("\n"); | 28 OS::Print("\n"); |
| 29 } | 29 } |
| 30 | 30 |
| 31 | 31 |
| 32 void DisassembleToStdout::Print(const char* format, ...) { | 32 void DisassembleToStdout::Print(const char* format, ...) { |
| 33 va_list args; | 33 va_list args; |
| 34 va_start(args, format); | 34 va_start(args, format); |
| 35 OS::VFPrint(stdout, format, args); | 35 OS::VFPrint(stdout, format, args); |
| 36 va_end(args); | 36 va_end(args); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace dart | 39 } // namespace dart |
| OLD | NEW |