| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 <math.h> // for isnan. | 5 #include <math.h> // for isnan. |
| 6 #include <setjmp.h> | 6 #include <setjmp.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #if defined(TARGET_ARCH_ARM) | 10 #if defined(TARGET_ARCH_ARM) |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 void SimulatorDebugger::RedoBreakpoints() { | 286 void SimulatorDebugger::RedoBreakpoints() { |
| 287 if (sim_->break_pc_ != NULL) { | 287 if (sim_->break_pc_ != NULL) { |
| 288 sim_->break_pc_->SetInstructionBits(kSimulatorBreakpointInstr); | 288 sim_->break_pc_->SetInstructionBits(kSimulatorBreakpointInstr); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 | 292 |
| 293 void SimulatorDebugger::Debug() { | 293 void SimulatorDebugger::Debug() { |
| 294 intptr_t last_pc = -1; | 294 intptr_t last_pc = -1; |
| 295 bool done = false; | 295 bool done = false; |
| 296 bool decoded = true; |
| 296 | 297 |
| 297 #define COMMAND_SIZE 63 | 298 #define COMMAND_SIZE 63 |
| 298 #define ARG_SIZE 255 | 299 #define ARG_SIZE 255 |
| 299 | 300 |
| 300 #define STR(a) #a | 301 #define STR(a) #a |
| 301 #define XSTR(a) STR(a) | 302 #define XSTR(a) STR(a) |
| 302 | 303 |
| 303 char cmd[COMMAND_SIZE + 1]; | 304 char cmd[COMMAND_SIZE + 1]; |
| 304 char arg1[ARG_SIZE + 1]; | 305 char arg1[ARG_SIZE + 1]; |
| 305 char arg2[ARG_SIZE + 1]; | 306 char arg2[ARG_SIZE + 1]; |
| 306 | 307 |
| 307 // make sure to have a proper terminating character if reaching the limit | 308 // make sure to have a proper terminating character if reaching the limit |
| 308 cmd[COMMAND_SIZE] = 0; | 309 cmd[COMMAND_SIZE] = 0; |
| 309 arg1[ARG_SIZE] = 0; | 310 arg1[ARG_SIZE] = 0; |
| 310 arg2[ARG_SIZE] = 0; | 311 arg2[ARG_SIZE] = 0; |
| 311 | 312 |
| 312 // Undo all set breakpoints while running in the debugger shell. This will | 313 // Undo all set breakpoints while running in the debugger shell. This will |
| 313 // make them invisible to all commands. | 314 // make them invisible to all commands. |
| 314 UndoBreakpoints(); | 315 UndoBreakpoints(); |
| 315 | 316 |
| 316 while (!done) { | 317 while (!done) { |
| 317 if (last_pc != sim_->get_pc()) { | 318 if (last_pc != sim_->get_pc()) { |
| 318 last_pc = sim_->get_pc(); | 319 last_pc = sim_->get_pc(); |
| 319 Disassembler::Disassemble(last_pc, last_pc + Instr::kInstrSize); | 320 decoded = Disassembler::Disassemble(last_pc, last_pc + Instr::kInstrSize); |
| 320 } | 321 } |
| 321 char* line = ReadLine("sim> "); | 322 char* line = ReadLine("sim> "); |
| 322 if (line == NULL) { | 323 if (line == NULL) { |
| 323 break; | 324 break; |
| 324 } else { | 325 } else { |
| 325 // Use sscanf to parse the individual parts of the command line. At the | 326 // Use sscanf to parse the individual parts of the command line. At the |
| 326 // moment no command expects more than two parameters. | 327 // moment no command expects more than two parameters. |
| 327 int args = SScanF(line, | 328 int args = SScanF(line, |
| 328 "%" XSTR(COMMAND_SIZE) "s " | 329 "%" XSTR(COMMAND_SIZE) "s " |
| 329 "%" XSTR(ARG_SIZE) "s " | 330 "%" XSTR(ARG_SIZE) "s " |
| 330 "%" XSTR(ARG_SIZE) "s", | 331 "%" XSTR(ARG_SIZE) "s", |
| 331 cmd, arg1, arg2); | 332 cmd, arg1, arg2); |
| 332 if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { | 333 if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { |
| 333 OS::Print("c/cont -- continue execution\n" | 334 OS::Print("c/cont -- continue execution\n" |
| 334 "disasm -- disassemble instrs at current pc location\n" | 335 "disasm -- disassemble instrs at current pc location\n" |
| 335 " other variants are:\n" | 336 " other variants are:\n" |
| 336 " disasm <address>\n" | 337 " disasm <address>\n" |
| 337 " disasm <address> <number_of_instructions>\n" | 338 " disasm <address> <number_of_instructions>\n" |
| 338 " by default 10 instrs are disassembled\n" | 339 " by default 10 instrs are disassembled\n" |
| 339 "del -- delete breakpoints\n" | 340 "del -- delete breakpoints\n" |
| 340 "flags -- print flag values\n" | 341 "flags -- print flag values\n" |
| 341 "gdb -- transfer control to gdb\n" | 342 "gdb -- transfer control to gdb\n" |
| 342 "h/help -- print this help string\n" | 343 "h/help -- print this help string\n" |
| 343 "break <address> -- set break point at specified address\n" | 344 "break <address> -- set break point at specified address\n" |
| 344 "p/print <reg or value or *addr> -- print integer value\n" | 345 "p/print <reg or value or *addr> -- print integer value\n" |
| 345 "pf/printfloat <sreg or *addr> -- print float value\n" | 346 "pf/printfloat <sreg or *addr> -- print float value\n" |
| 346 "pd/printdouble <dreg or *addr> -- print double value\n" | 347 "pd/printdouble <dreg or *addr> -- print double value\n" |
| 347 "po/printobject <*reg or *addr> -- print object\n" | 348 "po/printobject <*reg or *addr> -- print object\n" |
| 348 "si/stepi -- single step an instruction\n" | 349 "si/stepi -- single step an instruction\n" |
| 349 "unstop -- if current pc is a stop instr make it a nop\n"); | 350 "unstop -- if current pc is a stop instr make it a nop\n" |
| 351 "q/quit -- Quit the debugger and exit the program\n"); |
| 352 } else if ((strcmp(cmd, "quit") == 0) || (strcmp(cmd, "q") == 0)) { |
| 353 OS::Print("Quitting\n"); |
| 354 OS::Exit(0); |
| 350 } else if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) { | 355 } else if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) { |
| 351 sim_->InstructionDecode(reinterpret_cast<Instr*>(sim_->get_pc())); | 356 if (decoded) { |
| 357 sim_->InstructionDecode(reinterpret_cast<Instr*>(sim_->get_pc())); |
| 358 } else { |
| 359 OS::Print("Instruction could not be decoded. Stepping disabled.\n"); |
| 360 } |
| 352 } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { | 361 } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { |
| 353 // Execute the one instruction we broke at with breakpoints disabled. | 362 if (decoded) { |
| 354 sim_->InstructionDecode(reinterpret_cast<Instr*>(sim_->get_pc())); | 363 // Execute the one instruction we broke at with breakpoints disabled. |
| 355 // Leave the debugger shell. | 364 sim_->InstructionDecode(reinterpret_cast<Instr*>(sim_->get_pc())); |
| 356 done = true; | 365 // Leave the debugger shell. |
| 366 done = true; |
| 367 } else { |
| 368 OS::Print("Instruction could not be decoded. Cannot continue.\n"); |
| 369 } |
| 357 } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { | 370 } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { |
| 358 if (args == 2) { | 371 if (args == 2) { |
| 359 uint32_t value; | 372 uint32_t value; |
| 360 if (GetValue(arg1, &value)) { | 373 if (GetValue(arg1, &value)) { |
| 361 OS::Print("%s: %u 0x%x\n", arg1, value, value); | 374 OS::Print("%s: %u 0x%x\n", arg1, value, value); |
| 362 } else { | 375 } else { |
| 363 OS::Print("%s unrecognized\n", arg1); | 376 OS::Print("%s unrecognized\n", arg1); |
| 364 } | 377 } |
| 365 } else { | 378 } else { |
| 366 OS::Print("print <reg or value or *addr>\n"); | 379 OS::Print("print <reg or value or *addr>\n"); |
| (...skipping 2490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2857 // isolate->ChangeStateToGeneratedCode(); | 2870 // isolate->ChangeStateToGeneratedCode(); |
| 2858 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw())); | 2871 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw())); |
| 2859 buf->Longjmp(); | 2872 buf->Longjmp(); |
| 2860 } | 2873 } |
| 2861 | 2874 |
| 2862 } // namespace dart | 2875 } // namespace dart |
| 2863 | 2876 |
| 2864 #endif // !defined(HOST_ARCH_ARM) | 2877 #endif // !defined(HOST_ARCH_ARM) |
| 2865 | 2878 |
| 2866 #endif // defined TARGET_ARCH_ARM | 2879 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |