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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 arg2[ARG_SIZE] = 0; | 307 arg2[ARG_SIZE] = 0; |
308 | 308 |
309 // Undo all set breakpoints while running in the debugger shell. This will | 309 // Undo all set breakpoints while running in the debugger shell. This will |
310 // make them invisible to all commands. | 310 // make them invisible to all commands. |
311 UndoBreakpoints(); | 311 UndoBreakpoints(); |
312 | 312 |
313 while (!done) { | 313 while (!done) { |
314 if (last_pc != sim_->get_pc()) { | 314 if (last_pc != sim_->get_pc()) { |
315 last_pc = sim_->get_pc(); | 315 last_pc = sim_->get_pc(); |
316 if (Simulator::IsIllegalAddress(last_pc)) { | 316 if (Simulator::IsIllegalAddress(last_pc)) { |
317 OS::Print("pc is out of bounds: 0x%"Px"\n", last_pc); | 317 OS::Print("pc is out of bounds: 0x%" Px "\n", last_pc); |
318 } else { | 318 } else { |
319 Disassembler::Disassemble(last_pc, last_pc + Instr::kInstrSize); | 319 Disassembler::Disassemble(last_pc, last_pc + Instr::kInstrSize); |
320 } | 320 } |
321 } | 321 } |
322 char* line = ReadLine("sim> "); | 322 char* line = ReadLine("sim> "); |
323 if (line == NULL) { | 323 if (line == NULL) { |
324 FATAL("ReadLine failed"); | 324 FATAL("ReadLine failed"); |
325 } else { | 325 } else { |
326 // 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 |
327 // moment no command expects more than two parameters. | 327 // moment no command expects more than two parameters. |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 FATAL("Cannot continue execution after unimplemented instruction."); | 811 FATAL("Cannot continue execution after unimplemented instruction."); |
812 } | 812 } |
813 | 813 |
814 | 814 |
815 void Simulator::HandleIllegalAccess(uword addr, Instr* instr) { | 815 void Simulator::HandleIllegalAccess(uword addr, Instr* instr) { |
816 uword fault_pc = get_pc(); | 816 uword fault_pc = get_pc(); |
817 // The debugger will not be able to single step past this instruction, but | 817 // The debugger will not be able to single step past this instruction, but |
818 // it will be possible to disassemble the code and inspect registers. | 818 // it will be possible to disassemble the code and inspect registers. |
819 char buffer[128]; | 819 char buffer[128]; |
820 snprintf(buffer, sizeof(buffer), | 820 snprintf(buffer, sizeof(buffer), |
821 "illegal memory access at 0x%"Px", pc=0x%"Px"\n", | 821 "illegal memory access at 0x%" Px ", pc=0x%" Px "\n", |
822 addr, fault_pc); | 822 addr, fault_pc); |
823 SimulatorDebugger dbg(this); | 823 SimulatorDebugger dbg(this); |
824 dbg.Stop(instr, buffer); | 824 dbg.Stop(instr, buffer); |
825 // The debugger will return control in non-interactive mode. | 825 // The debugger will return control in non-interactive mode. |
826 FATAL("Cannot continue execution after illegal memory access."); | 826 FATAL("Cannot continue execution after illegal memory access."); |
827 } | 827 } |
828 | 828 |
829 | 829 |
830 void Simulator::UnalignedAccess(const char* msg, uword addr, Instr* instr) { | 830 void Simulator::UnalignedAccess(const char* msg, uword addr, Instr* instr) { |
831 // The debugger will not be able to single step past this instruction, but | 831 // The debugger will not be able to single step past this instruction, but |
832 // it will be possible to disassemble the code and inspect registers. | 832 // it will be possible to disassemble the code and inspect registers. |
833 char buffer[128]; | 833 char buffer[128]; |
834 snprintf(buffer, sizeof(buffer), | 834 snprintf(buffer, sizeof(buffer), |
835 "pc=%p, unaligned %s at 0x%"Px"\n", instr, msg, addr); | 835 "pc=%p, unaligned %s at 0x%" Px "\n", instr, msg, addr); |
836 SimulatorDebugger dbg(this); | 836 SimulatorDebugger dbg(this); |
837 dbg.Stop(instr, buffer); | 837 dbg.Stop(instr, buffer); |
838 // The debugger will return control in non-interactive mode. | 838 // The debugger will return control in non-interactive mode. |
839 FATAL("Cannot continue execution after unaligned access."); | 839 FATAL("Cannot continue execution after unaligned access."); |
840 } | 840 } |
841 | 841 |
842 | 842 |
843 // Returns the top of the stack area to enable checking for stack pointer | 843 // Returns the top of the stack area to enable checking for stack pointer |
844 // validity. | 844 // validity. |
845 uword Simulator::StackTop() const { | 845 uword Simulator::StackTop() const { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 UnimplementedInstruction(instr); | 998 UnimplementedInstruction(instr); |
999 } | 999 } |
1000 } else if (instr->BreakCodeField() == Instr::kRedirectCode) { | 1000 } else if (instr->BreakCodeField() == Instr::kRedirectCode) { |
1001 SimulatorSetjmpBuffer buffer(this); | 1001 SimulatorSetjmpBuffer buffer(this); |
1002 | 1002 |
1003 if (!setjmp(buffer.buffer_)) { | 1003 if (!setjmp(buffer.buffer_)) { |
1004 int32_t saved_ra = get_register(RA); | 1004 int32_t saved_ra = get_register(RA); |
1005 Redirection* redirection = Redirection::FromBreakInstruction(instr); | 1005 Redirection* redirection = Redirection::FromBreakInstruction(instr); |
1006 uword external = redirection->external_function(); | 1006 uword external = redirection->external_function(); |
1007 if (FLAG_trace_sim) { | 1007 if (FLAG_trace_sim) { |
1008 OS::Print("Call to host function at 0x%"Pd"\n", external); | 1008 OS::Print("Call to host function at 0x%" Pd "\n", external); |
1009 } | 1009 } |
1010 | 1010 |
1011 if ((redirection->call_kind() == kRuntimeCall) || | 1011 if ((redirection->call_kind() == kRuntimeCall) || |
1012 (redirection->call_kind() == kBootstrapNativeCall) || | 1012 (redirection->call_kind() == kBootstrapNativeCall) || |
1013 (redirection->call_kind() == kNativeCall)) { | 1013 (redirection->call_kind() == kNativeCall)) { |
1014 // Set the top_exit_frame_info of this simulator to the native stack. | 1014 // Set the top_exit_frame_info of this simulator to the native stack. |
1015 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); | 1015 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); |
1016 } | 1016 } |
1017 if (redirection->call_kind() == kRuntimeCall) { | 1017 if (redirection->call_kind() == kRuntimeCall) { |
1018 NativeArguments arguments; | 1018 NativeArguments arguments; |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2245 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 2245 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
2246 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 2246 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
2247 buf->Longjmp(); | 2247 buf->Longjmp(); |
2248 } | 2248 } |
2249 | 2249 |
2250 } // namespace dart | 2250 } // namespace dart |
2251 | 2251 |
2252 #endif // !defined(HOST_ARCH_MIPS) | 2252 #endif // !defined(HOST_ARCH_MIPS) |
2253 | 2253 |
2254 #endif // defined TARGET_ARCH_MIPS | 2254 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |