| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 arg1[ARG_SIZE] = 0; | 197 arg1[ARG_SIZE] = 0; |
| 198 arg2[ARG_SIZE] = 0; | 198 arg2[ARG_SIZE] = 0; |
| 199 | 199 |
| 200 // Undo all set breakpoints while running in the debugger shell. This will | 200 // Undo all set breakpoints while running in the debugger shell. This will |
| 201 // make them invisible to all commands. | 201 // make them invisible to all commands. |
| 202 UndoBreakpoints(); | 202 UndoBreakpoints(); |
| 203 | 203 |
| 204 while (!done) { | 204 while (!done) { |
| 205 if (last_pc != sim_->get_pc()) { | 205 if (last_pc != sim_->get_pc()) { |
| 206 disasm::Disassembler dasm; | 206 disasm::Disassembler dasm; |
| 207 char buffer[256]; // use a reasonably large buffer | 207 // use a reasonably large buffer |
| 208 dasm.InstructionDecode(buffer, sizeof(buffer), | 208 v8::internal::EmbeddedVector<char, 256> buffer; |
| 209 dasm.InstructionDecode(buffer, |
| 209 reinterpret_cast<byte*>(sim_->get_pc())); | 210 reinterpret_cast<byte*>(sim_->get_pc())); |
| 210 PrintF(" 0x%x %s\n", sim_->get_pc(), buffer); | 211 PrintF(" 0x%x %s\n", sim_->get_pc(), buffer.start()); |
| 211 last_pc = sim_->get_pc(); | 212 last_pc = sim_->get_pc(); |
| 212 } | 213 } |
| 213 char* line = ReadLine("sim> "); | 214 char* line = ReadLine("sim> "); |
| 214 if (line == NULL) { | 215 if (line == NULL) { |
| 215 break; | 216 break; |
| 216 } else { | 217 } else { |
| 217 // Use sscanf to parse the individual parts of the command line. At the | 218 // Use sscanf to parse the individual parts of the command line. At the |
| 218 // moment no command expects more than two parameters. | 219 // moment no command expects more than two parameters. |
| 219 int args = sscanf(line, // NOLINT | 220 int args = sscanf(line, // NOLINT |
| 220 "%" XSTR(COMMAND_SIZE) "s " | 221 "%" XSTR(COMMAND_SIZE) "s " |
| (...skipping 30 matching lines...) Expand all Loading... |
| 251 obj->PrintLn(); | 252 obj->PrintLn(); |
| 252 #endif // defined(DEBUG) | 253 #endif // defined(DEBUG) |
| 253 } else { | 254 } else { |
| 254 PrintF("%s unrecognized\n", arg1); | 255 PrintF("%s unrecognized\n", arg1); |
| 255 } | 256 } |
| 256 } else { | 257 } else { |
| 257 PrintF("printobject value\n"); | 258 PrintF("printobject value\n"); |
| 258 } | 259 } |
| 259 } else if (strcmp(cmd, "disasm") == 0) { | 260 } else if (strcmp(cmd, "disasm") == 0) { |
| 260 disasm::Disassembler dasm; | 261 disasm::Disassembler dasm; |
| 261 char buffer[256]; // use a reasonably large buffer | 262 // use a reasonably large buffer |
| 263 v8::internal::EmbeddedVector<char, 256> buffer; |
| 262 | 264 |
| 263 byte* cur = NULL; | 265 byte* cur = NULL; |
| 264 byte* end = NULL; | 266 byte* end = NULL; |
| 265 | 267 |
| 266 if (args == 1) { | 268 if (args == 1) { |
| 267 cur = reinterpret_cast<byte*>(sim_->get_pc()); | 269 cur = reinterpret_cast<byte*>(sim_->get_pc()); |
| 268 end = cur + (10 * Instr::kInstrSize); | 270 end = cur + (10 * Instr::kInstrSize); |
| 269 } else if (args == 2) { | 271 } else if (args == 2) { |
| 270 int32_t value; | 272 int32_t value; |
| 271 if (GetValue(arg1, &value)) { | 273 if (GetValue(arg1, &value)) { |
| 272 cur = reinterpret_cast<byte*>(value); | 274 cur = reinterpret_cast<byte*>(value); |
| 273 // no length parameter passed, assume 10 instructions | 275 // no length parameter passed, assume 10 instructions |
| 274 end = cur + (10 * Instr::kInstrSize); | 276 end = cur + (10 * Instr::kInstrSize); |
| 275 } | 277 } |
| 276 } else { | 278 } else { |
| 277 int32_t value1; | 279 int32_t value1; |
| 278 int32_t value2; | 280 int32_t value2; |
| 279 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { | 281 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { |
| 280 cur = reinterpret_cast<byte*>(value1); | 282 cur = reinterpret_cast<byte*>(value1); |
| 281 end = cur + (value2 * Instr::kInstrSize); | 283 end = cur + (value2 * Instr::kInstrSize); |
| 282 } | 284 } |
| 283 } | 285 } |
| 284 | 286 |
| 285 while (cur < end) { | 287 while (cur < end) { |
| 286 dasm.InstructionDecode(buffer, sizeof(buffer), cur); | 288 dasm.InstructionDecode(buffer, cur); |
| 287 PrintF(" 0x%x %s\n", cur, buffer); | 289 PrintF(" 0x%x %s\n", cur, buffer.start()); |
| 288 cur += Instr::kInstrSize; | 290 cur += Instr::kInstrSize; |
| 289 } | 291 } |
| 290 } else if (strcmp(cmd, "gdb") == 0) { | 292 } else if (strcmp(cmd, "gdb") == 0) { |
| 291 PrintF("relinquishing control to gdb\n"); | 293 PrintF("relinquishing control to gdb\n"); |
| 292 v8::internal::OS::DebugBreak(); | 294 v8::internal::OS::DebugBreak(); |
| 293 PrintF("regaining control from gdb\n"); | 295 PrintF("regaining control from gdb\n"); |
| 294 } else if (strcmp(cmd, "break") == 0) { | 296 } else if (strcmp(cmd, "break") == 0) { |
| 295 if (args == 2) { | 297 if (args == 2) { |
| 296 int32_t value; | 298 int32_t value; |
| 297 if (GetValue(arg1, &value)) { | 299 if (GetValue(arg1, &value)) { |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 // Executes the current instruction. | 1336 // Executes the current instruction. |
| 1335 void Simulator::InstructionDecode(Instr* instr) { | 1337 void Simulator::InstructionDecode(Instr* instr) { |
| 1336 pc_modified_ = false; | 1338 pc_modified_ = false; |
| 1337 if (instr->ConditionField() == special_condition) { | 1339 if (instr->ConditionField() == special_condition) { |
| 1338 Debugger dbg(this); | 1340 Debugger dbg(this); |
| 1339 dbg.Stop(instr); | 1341 dbg.Stop(instr); |
| 1340 return; | 1342 return; |
| 1341 } | 1343 } |
| 1342 if (FLAG_trace_sim) { | 1344 if (FLAG_trace_sim) { |
| 1343 disasm::Disassembler dasm; | 1345 disasm::Disassembler dasm; |
| 1344 char buffer[256]; // use a reasonably large buffer | 1346 // use a reasonably large buffer |
| 1347 v8::internal::EmbeddedVector<char, 256> buffer; |
| 1345 dasm.InstructionDecode(buffer, | 1348 dasm.InstructionDecode(buffer, |
| 1346 sizeof(buffer), | |
| 1347 reinterpret_cast<byte*>(instr)); | 1349 reinterpret_cast<byte*>(instr)); |
| 1348 PrintF(" 0x%x %s\n", instr, buffer); | 1350 PrintF(" 0x%x %s\n", instr, buffer.start()); |
| 1349 } | 1351 } |
| 1350 if (ConditionallyExecute(instr)) { | 1352 if (ConditionallyExecute(instr)) { |
| 1351 switch (instr->TypeField()) { | 1353 switch (instr->TypeField()) { |
| 1352 case 0: | 1354 case 0: |
| 1353 case 1: { | 1355 case 1: { |
| 1354 DecodeType01(instr); | 1356 DecodeType01(instr); |
| 1355 break; | 1357 break; |
| 1356 } | 1358 } |
| 1357 case 2: { | 1359 case 2: { |
| 1358 DecodeType2(instr); | 1360 DecodeType2(instr); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 set_register(r10, r10_val); | 1479 set_register(r10, r10_val); |
| 1478 set_register(r11, r11_val); | 1480 set_register(r11, r11_val); |
| 1479 | 1481 |
| 1480 int result = get_register(r0); | 1482 int result = get_register(r0); |
| 1481 return reinterpret_cast<Object*>(result); | 1483 return reinterpret_cast<Object*>(result); |
| 1482 } | 1484 } |
| 1483 | 1485 |
| 1484 } } // namespace assembler::arm | 1486 } } // namespace assembler::arm |
| 1485 | 1487 |
| 1486 #endif // !defined(__arm__) | 1488 #endif // !defined(__arm__) |
| OLD | NEW |