| 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_MIPS) | 10 #if defined(TARGET_ARCH_MIPS) |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 arg1[ARG_SIZE] = 0; | 282 arg1[ARG_SIZE] = 0; |
| 283 arg2[ARG_SIZE] = 0; | 283 arg2[ARG_SIZE] = 0; |
| 284 | 284 |
| 285 // Undo all set breakpoints while running in the debugger shell. This will | 285 // Undo all set breakpoints while running in the debugger shell. This will |
| 286 // make them invisible to all commands. | 286 // make them invisible to all commands. |
| 287 UndoBreakpoints(); | 287 UndoBreakpoints(); |
| 288 | 288 |
| 289 while (!done) { | 289 while (!done) { |
| 290 if (last_pc != sim_->get_pc()) { | 290 if (last_pc != sim_->get_pc()) { |
| 291 last_pc = sim_->get_pc(); | 291 last_pc = sim_->get_pc(); |
| 292 Disassembler::Disassemble(last_pc, last_pc + Instr::kInstrSize); | 292 if (Simulator::IsIllegalAddress(last_pc)) { |
| 293 OS::Print("pc is out of bounds: 0x%"Px"\n", last_pc); |
| 294 } else { |
| 295 Disassembler::Disassemble(last_pc, last_pc + Instr::kInstrSize); |
| 296 } |
| 293 } | 297 } |
| 294 char* line = ReadLine("sim> "); | 298 char* line = ReadLine("sim> "); |
| 295 if (line == NULL) { | 299 if (line == NULL) { |
| 296 FATAL("ReadLine failed"); | 300 FATAL("ReadLine failed"); |
| 297 } else { | 301 } else { |
| 298 // Use sscanf to parse the individual parts of the command line. At the | 302 // Use sscanf to parse the individual parts of the command line. At the |
| 299 // moment no command expects more than two parameters. | 303 // moment no command expects more than two parameters. |
| 300 int args = SScanF(line, | 304 int args = SScanF(line, |
| 301 "%" XSTR(COMMAND_SIZE) "s " | 305 "%" XSTR(COMMAND_SIZE) "s " |
| 302 "%" XSTR(ARG_SIZE) "s " | 306 "%" XSTR(ARG_SIZE) "s " |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 set_register(A3, icount_); | 901 set_register(A3, icount_); |
| 898 set_register(TMP, icount_); | 902 set_register(TMP, icount_); |
| 899 set_register(RA, icount_); | 903 set_register(RA, icount_); |
| 900 | 904 |
| 901 // Zap floating point registers. | 905 // Zap floating point registers. |
| 902 double zap_dvalue = static_cast<double>(icount_); | 906 double zap_dvalue = static_cast<double>(icount_); |
| 903 for (int i = F0; i <= F31; i++) { | 907 for (int i = F0; i <= F31; i++) { |
| 904 set_fregister(static_cast<FRegister>(i), zap_dvalue); | 908 set_fregister(static_cast<FRegister>(i), zap_dvalue); |
| 905 } | 909 } |
| 906 | 910 |
| 907 // Return. | 911 // Return. Subtract to account for pc_ increment after return. |
| 908 set_pc(saved_ra); | 912 set_pc(saved_ra - Instr::kInstrSize); |
| 909 } | 913 } |
| 910 } else { | 914 } else { |
| 911 SimulatorDebugger dbg(this); | 915 SimulatorDebugger dbg(this); |
| 912 dbg.Stop(instr, "breakpoint"); | 916 dbg.Stop(instr, "breakpoint"); |
| 913 } | 917 } |
| 914 } | 918 } |
| 915 | 919 |
| 916 | 920 |
| 917 void Simulator::DecodeSpecial(Instr* instr) { | 921 void Simulator::DecodeSpecial(Instr* instr) { |
| 918 ASSERT(instr->OpcodeField() == SPECIAL); | 922 ASSERT(instr->OpcodeField() == SPECIAL); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 | 981 |
| 978 set_lo_register(rs_val / rt_val); | 982 set_lo_register(rs_val / rt_val); |
| 979 set_hi_register(rs_val % rt_val); | 983 set_hi_register(rs_val % rt_val); |
| 980 break; | 984 break; |
| 981 } | 985 } |
| 982 case JALR: { | 986 case JALR: { |
| 983 ASSERT(instr->RtField() == R0); | 987 ASSERT(instr->RtField() == R0); |
| 984 ASSERT(instr->RsField() != instr->RdField()); | 988 ASSERT(instr->RsField() != instr->RdField()); |
| 985 ASSERT(!delay_slot_); | 989 ASSERT(!delay_slot_); |
| 986 // Format(instr, "jalr'hint 'rd, rs"); | 990 // Format(instr, "jalr'hint 'rd, rs"); |
| 991 set_register(instr->RdField(), pc_ + 2*Instr::kInstrSize); |
| 987 uword next_pc = get_register(instr->RsField()); | 992 uword next_pc = get_register(instr->RsField()); |
| 988 ExecuteDelaySlot(); | 993 ExecuteDelaySlot(); |
| 989 // Set return address to be the instruction after the delay slot. | 994 // Set return address to be the instruction after the delay slot. |
| 990 set_register(instr->RdField(), pc_ + Instr::kInstrSize); | |
| 991 pc_ = next_pc - Instr::kInstrSize; // Account for regular PC increment. | 995 pc_ = next_pc - Instr::kInstrSize; // Account for regular PC increment. |
| 992 break; | 996 break; |
| 993 } | 997 } |
| 994 case JR: { | 998 case JR: { |
| 995 ASSERT(instr->RtField() == R0); | 999 ASSERT(instr->RtField() == R0); |
| 996 ASSERT(instr->RdField() == R0); | 1000 ASSERT(instr->RdField() == R0); |
| 997 ASSERT(!delay_slot_); | 1001 ASSERT(!delay_slot_); |
| 998 // Format(instr, "jr'hint 'rs"); | 1002 // Format(instr, "jr'hint 'rs"); |
| 999 uword next_pc = get_register(instr->RsField()); | 1003 uword next_pc = get_register(instr->RsField()); |
| 1000 ExecuteDelaySlot(); | 1004 ExecuteDelaySlot(); |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 // Restore the SP register and return R1:R0. | 1626 // Restore the SP register and return R1:R0. |
| 1623 set_register(SP, sp_before_call); | 1627 set_register(SP, sp_before_call); |
| 1624 return Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); | 1628 return Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); |
| 1625 } | 1629 } |
| 1626 | 1630 |
| 1627 } // namespace dart | 1631 } // namespace dart |
| 1628 | 1632 |
| 1629 #endif // !defined(HOST_ARCH_MIPS) | 1633 #endif // !defined(HOST_ARCH_MIPS) |
| 1630 | 1634 |
| 1631 #endif // defined TARGET_ARCH_MIPS | 1635 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |