| 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 <setjmp.h> | 5 #include <setjmp.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #if defined(TARGET_ARCH_MIPS) | 9 #if defined(TARGET_ARCH_MIPS) |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void Debug(); | 87 void Debug(); |
| 88 char* ReadLine(const char* prompt); | 88 char* ReadLine(const char* prompt); |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 Simulator* sim_; | 91 Simulator* sim_; |
| 92 | 92 |
| 93 bool GetValue(char* desc, uint32_t* value); | 93 bool GetValue(char* desc, uint32_t* value); |
| 94 bool GetFValue(char* desc, double* value); | 94 bool GetFValue(char* desc, double* value); |
| 95 bool GetDValue(char* desc, double* value); | 95 bool GetDValue(char* desc, double* value); |
| 96 | 96 |
| 97 static const int32_t kSimulatorBreakpointInstruction = |
| 98 Instr::kBreakPointInstruction | |
| 99 (Instr::kSimulatorBreakCode << kBreakCodeShift); |
| 100 |
| 97 // Set or delete a breakpoint. Returns true if successful. | 101 // Set or delete a breakpoint. Returns true if successful. |
| 98 bool SetBreakpoint(Instr* breakpc); | 102 bool SetBreakpoint(Instr* breakpc); |
| 99 bool DeleteBreakpoint(Instr* breakpc); | 103 bool DeleteBreakpoint(Instr* breakpc); |
| 100 | 104 |
| 101 // Undo and redo all breakpoints. This is needed to bracket disassembly and | 105 // Undo and redo all breakpoints. This is needed to bracket disassembly and |
| 102 // execution to skip past breakpoints when run from the debugger. | 106 // execution to skip past breakpoints when run from the debugger. |
| 103 void UndoBreakpoints(); | 107 void UndoBreakpoints(); |
| 104 void RedoBreakpoints(); | 108 void RedoBreakpoints(); |
| 105 }; | 109 }; |
| 106 | 110 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 279 |
| 276 void SimulatorDebugger::UndoBreakpoints() { | 280 void SimulatorDebugger::UndoBreakpoints() { |
| 277 if (sim_->break_pc_ != NULL) { | 281 if (sim_->break_pc_ != NULL) { |
| 278 sim_->break_pc_->SetInstructionBits(sim_->break_instr_); | 282 sim_->break_pc_->SetInstructionBits(sim_->break_instr_); |
| 279 } | 283 } |
| 280 } | 284 } |
| 281 | 285 |
| 282 | 286 |
| 283 void SimulatorDebugger::RedoBreakpoints() { | 287 void SimulatorDebugger::RedoBreakpoints() { |
| 284 if (sim_->break_pc_ != NULL) { | 288 if (sim_->break_pc_ != NULL) { |
| 285 sim_->break_pc_->SetInstructionBits(Instr::kBreakPointInstruction); | 289 sim_->break_pc_->SetInstructionBits(kSimulatorBreakpointInstruction); |
| 286 } | 290 } |
| 287 } | 291 } |
| 288 | 292 |
| 289 | 293 |
| 290 void SimulatorDebugger::Debug() { | 294 void SimulatorDebugger::Debug() { |
| 291 intptr_t last_pc = -1; | 295 intptr_t last_pc = -1; |
| 292 bool done = false; | 296 bool done = false; |
| 293 | 297 |
| 294 #define COMMAND_SIZE 63 | 298 #define COMMAND_SIZE 63 |
| 295 #define ARG_SIZE 255 | 299 #define ARG_SIZE 255 |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 } | 1199 } |
| 1196 | 1200 |
| 1197 // Return. Subtract to account for pc_ increment after return. | 1201 // Return. Subtract to account for pc_ increment after return. |
| 1198 set_pc(saved_ra - Instr::kInstrSize); | 1202 set_pc(saved_ra - Instr::kInstrSize); |
| 1199 } else { | 1203 } else { |
| 1200 // Coming via long jump from a throw. Continue to exception handler. | 1204 // Coming via long jump from a throw. Continue to exception handler. |
| 1201 set_top_exit_frame_info(0); | 1205 set_top_exit_frame_info(0); |
| 1202 // Adjust for extra pc increment. | 1206 // Adjust for extra pc increment. |
| 1203 set_pc(get_pc() - Instr::kInstrSize); | 1207 set_pc(get_pc() - Instr::kInstrSize); |
| 1204 } | 1208 } |
| 1209 } else if (instr->BreakCodeField() == Instr::kSimulatorBreakCode) { |
| 1210 SimulatorDebugger dbg(this); |
| 1211 dbg.Stop(instr, "breakpoint"); |
| 1212 // Adjust for extra pc increment. |
| 1213 set_pc(get_pc() - Instr::kInstrSize); |
| 1205 } else { | 1214 } else { |
| 1206 SimulatorDebugger dbg(this); | 1215 SimulatorDebugger dbg(this); |
| 1207 dbg.Stop(instr, "breakpoint"); | 1216 set_pc(get_pc() + Instr::kInstrSize); |
| 1217 char buffer[32]; |
| 1218 snprintf(buffer, sizeof(buffer), "break #0x%x", instr->BreakCodeField()); |
| 1219 dbg.Stop(instr, buffer); |
| 1208 // Adjust for extra pc increment. | 1220 // Adjust for extra pc increment. |
| 1209 set_pc(get_pc() - Instr::kInstrSize); | 1221 set_pc(get_pc() - Instr::kInstrSize); |
| 1210 } | 1222 } |
| 1211 } | 1223 } |
| 1212 | 1224 |
| 1213 | 1225 |
| 1214 void Simulator::DecodeSpecial(Instr* instr) { | 1226 void Simulator::DecodeSpecial(Instr* instr) { |
| 1215 ASSERT(instr->OpcodeField() == SPECIAL); | 1227 ASSERT(instr->OpcodeField() == SPECIAL); |
| 1216 switch (instr->FunctionField()) { | 1228 switch (instr->FunctionField()) { |
| 1217 case ADDU: { | 1229 case ADDU: { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 ASSERT(instr->RdField() == 0); | 1370 ASSERT(instr->RdField() == 0); |
| 1359 ASSERT(instr->SaField() == 0); | 1371 ASSERT(instr->SaField() == 0); |
| 1360 // Format(instr, "mflo 'rd"); | 1372 // Format(instr, "mflo 'rd"); |
| 1361 set_lo_register(get_register(instr->RsField())); | 1373 set_lo_register(get_register(instr->RsField())); |
| 1362 break; | 1374 break; |
| 1363 } | 1375 } |
| 1364 case MULT: { | 1376 case MULT: { |
| 1365 ASSERT(instr->RdField() == 0); | 1377 ASSERT(instr->RdField() == 0); |
| 1366 ASSERT(instr->SaField() == 0); | 1378 ASSERT(instr->SaField() == 0); |
| 1367 // Format(instr, "mult 'rs, 'rt"); | 1379 // Format(instr, "mult 'rs, 'rt"); |
| 1368 int64_t rs = static_cast<int64_t>(get_register(instr->RsField())); | 1380 int64_t rs = get_register(instr->RsField()); |
| 1369 int64_t rt = static_cast<int64_t>(get_register(instr->RtField())); | 1381 int64_t rt = get_register(instr->RtField()); |
| 1370 int64_t res = rs * rt; | 1382 int64_t res = rs * rt; |
| 1371 set_hi_register(Utils::High32Bits(res)); | 1383 set_hi_register(Utils::High32Bits(res)); |
| 1372 set_lo_register(Utils::Low32Bits(res)); | 1384 set_lo_register(Utils::Low32Bits(res)); |
| 1373 break; | 1385 break; |
| 1374 } | 1386 } |
| 1375 case MULTU: { | 1387 case MULTU: { |
| 1376 ASSERT(instr->RdField() == 0); | 1388 ASSERT(instr->RdField() == 0); |
| 1377 ASSERT(instr->SaField() == 0); | 1389 ASSERT(instr->SaField() == 0); |
| 1378 // Format(instr, "multu 'rs, 'rt"); | 1390 // Format(instr, "multu 'rs, 'rt"); |
| 1379 uint64_t rs = static_cast<uint64_t>(get_register(instr->RsField())); | 1391 uint64_t rs = static_cast<uint32_t>(get_register(instr->RsField())); |
| 1380 uint64_t rt = static_cast<uint64_t>(get_register(instr->RtField())); | 1392 uint64_t rt = static_cast<uint32_t>(get_register(instr->RtField())); |
| 1381 uint64_t res = rs * rt; | 1393 uint64_t res = rs * rt; |
| 1382 set_hi_register(Utils::High32Bits(res)); | 1394 set_hi_register(Utils::High32Bits(res)); |
| 1383 set_lo_register(Utils::Low32Bits(res)); | 1395 set_lo_register(Utils::Low32Bits(res)); |
| 1384 break; | 1396 break; |
| 1385 } | 1397 } |
| 1386 case NOR: { | 1398 case NOR: { |
| 1387 ASSERT(instr->SaField() == 0); | 1399 ASSERT(instr->SaField() == 0); |
| 1388 // Format(instr, "nor 'rd, 'rs, 'rt"); | 1400 // Format(instr, "nor 'rd, 'rs, 'rt"); |
| 1389 int32_t rs_val = get_register(instr->RsField()); | 1401 int32_t rs_val = get_register(instr->RsField()); |
| 1390 int32_t rt_val = get_register(instr->RtField()); | 1402 int32_t rt_val = get_register(instr->RtField()); |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2349 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 2361 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
| 2350 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 2362 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
| 2351 buf->Longjmp(); | 2363 buf->Longjmp(); |
| 2352 } | 2364 } |
| 2353 | 2365 |
| 2354 } // namespace dart | 2366 } // namespace dart |
| 2355 | 2367 |
| 2356 #endif // !defined(HOST_ARCH_MIPS) | 2368 #endif // !defined(HOST_ARCH_MIPS) |
| 2357 | 2369 |
| 2358 #endif // defined TARGET_ARCH_MIPS | 2370 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |