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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 bool is_optimized, | 287 bool is_optimized, |
288 bool is_inlined) { | 288 bool is_inlined) { |
289 const Script& script = Script::Handle(function.script()); | 289 const Script& script = Script::Handle(function.script()); |
290 const String& func_name = String::Handle(function.QualifiedUserVisibleName()); | 290 const String& func_name = String::Handle(function.QualifiedUserVisibleName()); |
291 const String& url = String::Handle(script.url()); | 291 const String& url = String::Handle(script.url()); |
292 intptr_t line = -1; | 292 intptr_t line = -1; |
293 intptr_t column = -1; | 293 intptr_t column = -1; |
294 if (token_pos >= 0) { | 294 if (token_pos >= 0) { |
295 script.GetTokenLocation(token_pos, &line, &column); | 295 script.GetTokenLocation(token_pos, &line, &column); |
296 } | 296 } |
297 OS::Print("pc=0x%"Px" fp=0x%"Px" sp=0x%"Px" %s%s (%s:%"Pd":%"Pd")\n", | 297 OS::Print("pc=0x%" Px " fp=0x%" Px " sp=0x%" Px " %s%s (%s:%" Pd ":%" Pd ")\n" , |
siva
2013/08/20 19:54:51
OS::Print("pc=0x%" Px " fp=0x%" Px " sp=0x%" Px "
Jacob
2013/08/20 20:32:15
Done.
| |
298 pc, fp, sp, | 298 pc, fp, sp, |
299 is_optimized ? (is_inlined ? "inlined " : "optimized ") : "", | 299 is_optimized ? (is_inlined ? "inlined " : "optimized ") : "", |
300 func_name.ToCString(), | 300 func_name.ToCString(), |
301 url.ToCString(), | 301 url.ToCString(), |
302 line, column); | 302 line, column); |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 void SimulatorDebugger::PrintBacktrace() { | 306 void SimulatorDebugger::PrintBacktrace() { |
307 StackFrameIterator frames(sim_->get_register(FP), | 307 StackFrameIterator frames(sim_->get_register(FP), |
(...skipping 29 matching lines...) Expand all Loading... | |
337 true, true); | 337 true, true); |
338 } | 338 } |
339 } | 339 } |
340 // Print the optimized inlining frame below. | 340 // Print the optimized inlining frame below. |
341 } | 341 } |
342 PrintDartFrame(frame->pc(), frame->fp(), frame->sp(), | 342 PrintDartFrame(frame->pc(), frame->fp(), frame->sp(), |
343 function, | 343 function, |
344 GetApproximateTokenIndex(code, frame->pc()), | 344 GetApproximateTokenIndex(code, frame->pc()), |
345 code.is_optimized(), false); | 345 code.is_optimized(), false); |
346 } else { | 346 } else { |
347 OS::Print("pc=0x%"Px" fp=0x%"Px" sp=0x%"Px" %s frame\n", | 347 OS::Print("pc=0x%" Px " fp=0x%" Px " sp=0x%" Px " %s frame\n", |
348 frame->pc(), frame->fp(), frame->sp(), | 348 frame->pc(), frame->fp(), frame->sp(), |
349 frame->IsEntryFrame() ? "entry" : | 349 frame->IsEntryFrame() ? "entry" : |
350 frame->IsExitFrame() ? "exit" : | 350 frame->IsExitFrame() ? "exit" : |
351 frame->IsStubFrame() ? "stub" : "invalid"); | 351 frame->IsStubFrame() ? "stub" : "invalid"); |
352 } | 352 } |
353 frame = frames.NextFrame(); | 353 frame = frames.NextFrame(); |
354 } | 354 } |
355 } | 355 } |
356 | 356 |
357 | 357 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 arg2[ARG_SIZE] = 0; | 415 arg2[ARG_SIZE] = 0; |
416 | 416 |
417 // Undo all set breakpoints while running in the debugger shell. This will | 417 // Undo all set breakpoints while running in the debugger shell. This will |
418 // make them invisible to all commands. | 418 // make them invisible to all commands. |
419 UndoBreakpoints(); | 419 UndoBreakpoints(); |
420 | 420 |
421 while (!done) { | 421 while (!done) { |
422 if (last_pc != sim_->get_pc()) { | 422 if (last_pc != sim_->get_pc()) { |
423 last_pc = sim_->get_pc(); | 423 last_pc = sim_->get_pc(); |
424 if (Simulator::IsIllegalAddress(last_pc)) { | 424 if (Simulator::IsIllegalAddress(last_pc)) { |
425 OS::Print("pc is out of bounds: 0x%"Px"\n", last_pc); | 425 OS::Print("pc is out of bounds: 0x%" Px "\n", last_pc); |
426 } else { | 426 } else { |
427 Disassembler::Disassemble(last_pc, last_pc + Instr::kInstrSize); | 427 Disassembler::Disassemble(last_pc, last_pc + Instr::kInstrSize); |
428 } | 428 } |
429 } | 429 } |
430 char* line = ReadLine("sim> "); | 430 char* line = ReadLine("sim> "); |
431 if (line == NULL) { | 431 if (line == NULL) { |
432 FATAL("ReadLine failed"); | 432 FATAL("ReadLine failed"); |
433 } else { | 433 } else { |
434 // Use sscanf to parse the individual parts of the command line. At the | 434 // Use sscanf to parse the individual parts of the command line. At the |
435 // moment no command expects more than two parameters. | 435 // moment no command expects more than two parameters. |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
969 return dregisters_[reg]; | 969 return dregisters_[reg]; |
970 } | 970 } |
971 | 971 |
972 | 972 |
973 void Simulator::HandleIllegalAccess(uword addr, Instr* instr) { | 973 void Simulator::HandleIllegalAccess(uword addr, Instr* instr) { |
974 uword fault_pc = get_pc(); | 974 uword fault_pc = get_pc(); |
975 // The debugger will not be able to single step past this instruction, but | 975 // The debugger will not be able to single step past this instruction, but |
976 // it will be possible to disassemble the code and inspect registers. | 976 // it will be possible to disassemble the code and inspect registers. |
977 char buffer[128]; | 977 char buffer[128]; |
978 snprintf(buffer, sizeof(buffer), | 978 snprintf(buffer, sizeof(buffer), |
979 "illegal memory access at 0x%"Px", pc=0x%"Px"\n", | 979 "illegal memory access at 0x%" Px ", pc=0x%" Px "\n", |
980 addr, fault_pc); | 980 addr, fault_pc); |
981 SimulatorDebugger dbg(this); | 981 SimulatorDebugger dbg(this); |
982 dbg.Stop(instr, buffer); | 982 dbg.Stop(instr, buffer); |
983 // The debugger will return control in non-interactive mode. | 983 // The debugger will return control in non-interactive mode. |
984 FATAL("Cannot continue execution after illegal memory access."); | 984 FATAL("Cannot continue execution after illegal memory access."); |
985 } | 985 } |
986 | 986 |
987 | 987 |
988 // Processor versions prior to ARMv7 could not do unaligned reads and writes. | 988 // Processor versions prior to ARMv7 could not do unaligned reads and writes. |
989 // On some ARM platforms an interrupt is caused. On others it does a funky | 989 // On some ARM platforms an interrupt is caused. On others it does a funky |
990 // rotation thing. However, from version v7, unaligned access is supported. | 990 // rotation thing. However, from version v7, unaligned access is supported. |
991 // Note that simulator runs have the runtime system running directly on the host | 991 // Note that simulator runs have the runtime system running directly on the host |
992 // system and only generated code is executed in the simulator. Since the host | 992 // system and only generated code is executed in the simulator. Since the host |
993 // is typically IA32 we will get the correct ARMv7-like behaviour on unaligned | 993 // is typically IA32 we will get the correct ARMv7-like behaviour on unaligned |
994 // accesses, but we should actually not generate code accessing unaligned data, | 994 // accesses, but we should actually not generate code accessing unaligned data, |
995 // so we still want to know and abort if we encounter such code. | 995 // so we still want to know and abort if we encounter such code. |
996 void Simulator::UnalignedAccess(const char* msg, uword addr, Instr* instr) { | 996 void Simulator::UnalignedAccess(const char* msg, uword addr, Instr* instr) { |
997 // The debugger will not be able to single step past this instruction, but | 997 // The debugger will not be able to single step past this instruction, but |
998 // it will be possible to disassemble the code and inspect registers. | 998 // it will be possible to disassemble the code and inspect registers. |
999 char buffer[64]; | 999 char buffer[64]; |
1000 snprintf(buffer, sizeof(buffer), | 1000 snprintf(buffer, sizeof(buffer), |
1001 "unaligned %s at 0x%"Px", pc=%p\n", msg, addr, instr); | 1001 "unaligned %s at 0x%" Px ", pc=%p\n", msg, addr, instr); |
1002 SimulatorDebugger dbg(this); | 1002 SimulatorDebugger dbg(this); |
1003 dbg.Stop(instr, buffer); | 1003 dbg.Stop(instr, buffer); |
1004 // The debugger will return control in non-interactive mode. | 1004 // The debugger will return control in non-interactive mode. |
1005 FATAL("Cannot continue execution after unaligned access."); | 1005 FATAL("Cannot continue execution after unaligned access."); |
1006 } | 1006 } |
1007 | 1007 |
1008 | 1008 |
1009 void Simulator::UnimplementedInstruction(Instr* instr) { | 1009 void Simulator::UnimplementedInstruction(Instr* instr) { |
1010 char buffer[64]; | 1010 char buffer[64]; |
1011 snprintf(buffer, sizeof(buffer), "Unimplemented instruction: pc=%p\n", instr); | 1011 snprintf(buffer, sizeof(buffer), "Unimplemented instruction: pc=%p\n", instr); |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1499 int svc = instr->SvcField(); | 1499 int svc = instr->SvcField(); |
1500 switch (svc) { | 1500 switch (svc) { |
1501 case kRedirectionSvcCode: { | 1501 case kRedirectionSvcCode: { |
1502 SimulatorSetjmpBuffer buffer(this); | 1502 SimulatorSetjmpBuffer buffer(this); |
1503 | 1503 |
1504 if (!setjmp(buffer.buffer_)) { | 1504 if (!setjmp(buffer.buffer_)) { |
1505 int32_t saved_lr = get_register(LR); | 1505 int32_t saved_lr = get_register(LR); |
1506 Redirection* redirection = Redirection::FromSvcInstruction(instr); | 1506 Redirection* redirection = Redirection::FromSvcInstruction(instr); |
1507 uword external = redirection->external_function(); | 1507 uword external = redirection->external_function(); |
1508 if (FLAG_trace_sim) { | 1508 if (FLAG_trace_sim) { |
1509 OS::Print("Call to host function at 0x%"Pd"\n", external); | 1509 OS::Print("Call to host function at 0x%" Pd "\n", external); |
1510 } | 1510 } |
1511 | 1511 |
1512 if ((redirection->call_kind() == kRuntimeCall) || | 1512 if ((redirection->call_kind() == kRuntimeCall) || |
1513 (redirection->call_kind() == kBootstrapNativeCall) || | 1513 (redirection->call_kind() == kBootstrapNativeCall) || |
1514 (redirection->call_kind() == kNativeCall)) { | 1514 (redirection->call_kind() == kNativeCall)) { |
1515 // Set the top_exit_frame_info of this simulator to the native stack. | 1515 // Set the top_exit_frame_info of this simulator to the native stack. |
1516 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); | 1516 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); |
1517 } | 1517 } |
1518 if (redirection->call_kind() == kRuntimeCall) { | 1518 if (redirection->call_kind() == kRuntimeCall) { |
1519 NativeArguments arguments; | 1519 NativeArguments arguments; |
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3667 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 3667 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
3668 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 3668 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
3669 buf->Longjmp(); | 3669 buf->Longjmp(); |
3670 } | 3670 } |
3671 | 3671 |
3672 } // namespace dart | 3672 } // namespace dart |
3673 | 3673 |
3674 #endif // !defined(HOST_ARCH_ARM) | 3674 #endif // !defined(HOST_ARCH_ARM) |
3675 | 3675 |
3676 #endif // defined TARGET_ARCH_ARM | 3676 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |