OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #if V8_TARGET_ARCH_A64 |
| 29 |
| 30 #if defined(USE_SIMULATOR) |
| 31 |
| 32 #include "a64/debugger-a64.h" |
| 33 |
| 34 namespace v8 { |
| 35 namespace internal { |
| 36 |
| 37 |
| 38 void Debugger::VisitException(Instruction* instr) { |
| 39 switch (instr->Mask(ExceptionMask)) { |
| 40 case HLT: { |
| 41 if (instr->ImmException() == kImmExceptionIsDebug) { |
| 42 // Read the arguments encoded inline in the instruction stream. |
| 43 uint32_t code; |
| 44 uint32_t parameters; |
| 45 char const * message; |
| 46 |
| 47 ASSERT(sizeof(*pc_) == 1); |
| 48 memcpy(&code, pc_ + kDebugCodeOffset, sizeof(code)); |
| 49 memcpy(¶meters, pc_ + kDebugParamsOffset, sizeof(parameters)); |
| 50 message = reinterpret_cast<char const *>(pc_ + kDebugMessageOffset); |
| 51 |
| 52 if (message[0] == '\0') { |
| 53 fprintf(stream_, "Debugger hit %" PRIu32 ".\n", code); |
| 54 } else { |
| 55 fprintf(stream_, "Debugger hit %" PRIu32 ": %s\n", code, message); |
| 56 } |
| 57 |
| 58 // Other options. |
| 59 switch (parameters & kDebuggerTracingDirectivesMask) { |
| 60 case TRACE_ENABLE: |
| 61 set_log_parameters(log_parameters() | parameters); |
| 62 break; |
| 63 case TRACE_DISABLE: |
| 64 set_log_parameters(log_parameters() & ~parameters); |
| 65 break; |
| 66 case TRACE_OVERRIDE: |
| 67 set_log_parameters(parameters); |
| 68 break; |
| 69 default: |
| 70 // We don't support a one-shot LOG_DISASM. |
| 71 ASSERT((parameters & LOG_DISASM) == 0); |
| 72 // Don't print information that is already being traced. |
| 73 parameters &= ~log_parameters(); |
| 74 // Print the requested information. |
| 75 if (parameters & LOG_SYS_REGS) PrintSystemRegisters(true); |
| 76 if (parameters & LOG_REGS) PrintRegisters(true); |
| 77 if (parameters & LOG_FP_REGS) PrintFPRegisters(true); |
| 78 } |
| 79 |
| 80 // Check if the debugger should break. |
| 81 if (parameters & BREAK) OS::DebugBreak(); |
| 82 |
| 83 // The stop parameters are inlined in the code. Skip them: |
| 84 // - Skip to the end of the message string. |
| 85 pc_ += kDebugMessageOffset + strlen(message) + 1; |
| 86 // - Advance to the next aligned location. |
| 87 pc_ = AlignUp(pc_, kInstructionSize); |
| 88 // - Verify that the unreachable marker is present. |
| 89 ASSERT(reinterpret_cast<Instruction*>(pc_)->Mask(ExceptionMask) == HLT); |
| 90 ASSERT(reinterpret_cast<Instruction*>(pc_)->ImmException() == |
| 91 kImmExceptionIsUnreachable); |
| 92 // - Skip past the unreachable marker. |
| 93 pc_ += kInstructionSize; |
| 94 pc_modified_ = true; |
| 95 } else { |
| 96 Simulator::VisitException(instr); |
| 97 } |
| 98 break; |
| 99 } |
| 100 |
| 101 default: |
| 102 UNIMPLEMENTED(); |
| 103 } |
| 104 } |
| 105 |
| 106 |
| 107 } } // namespace v8::internal |
| 108 |
| 109 #endif // USE_SIMULATOR |
| 110 |
| 111 #endif // V8_TARGET_ARCH_A64 |
OLD | NEW |