| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2006-2008 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 |
| 29 |
| 30 #include "v8.h" |
| 31 |
| 32 #include "codegen-inl.h" |
| 33 #include "debug.h" |
| 34 |
| 35 namespace v8 { |
| 36 namespace internal { |
| 37 |
| 38 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 39 bool BreakLocationIterator::IsDebugBreakAtReturn() { |
| 40 return Debug::IsDebugBreakAtReturn(rinfo()); |
| 41 } |
| 42 |
| 43 |
| 44 void BreakLocationIterator::SetDebugBreakAtReturn() { |
| 45 UNIMPLEMENTED(); |
| 46 // Patch the code changing the return from JS function sequence from |
| 47 // mov sp, fp |
| 48 // ldmia sp!, {fp, lr} |
| 49 // add sp, sp, #4 |
| 50 // bx lr |
| 51 // to a call to the debug break return code. |
| 52 // mov lr, pc |
| 53 // ldr pc, [pc, #-4] |
| 54 // <debug break return code entry point address> |
| 55 // bktp 0 |
| 56 // CodePatcher patcher(rinfo()->pc(), 4); |
| 57 // patcher.masm()->mov(v8::internal::lr, v8::internal::pc); |
| 58 // patcher.masm()->ldr(v8::internal::pc, MemOperand(v8::internal::pc, -4)); |
| 59 // patcher.Emit(Debug::debug_break_return()->entry()); |
| 60 // patcher.masm()->bkpt(0); |
| 61 } |
| 62 |
| 63 |
| 64 // Restore the JS frame exit code. |
| 65 void BreakLocationIterator::ClearDebugBreakAtReturn() { |
| 66 UNIMPLEMENTED(); |
| 67 // rinfo()->PatchCode(original_rinfo()->pc(), |
| 68 // CodeGenerator::kJSReturnSequenceLength); |
| 69 } |
| 70 |
| 71 |
| 72 // A debug break in the exit code is identified by a call. |
| 73 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { |
| 74 ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); |
| 75 return rinfo->IsPatchedReturnSequence(); |
| 76 } |
| 77 |
| 78 |
| 79 #define __ ACCESS_MASM(masm) |
| 80 |
| 81 |
| 82 //static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
| 83 // RegList pointer_regs) { |
| 84 // UNIMPLEMENTED_(); |
| 85 // // Save the content of all general purpose registers in memory. This copy in |
| 86 // // memory is later pushed onto the JS expression stack for the fake JS frame |
| 87 // // generated and also to the C frame generated on top of that. In the JS |
| 88 // // frame ONLY the registers containing pointers will be pushed on the |
| 89 // // expression stack. This causes the GC to update these pointers so that |
| 90 // // they will have the correct value when returning from the debugger. |
| 91 // __ SaveRegistersToMemory(kJSCallerSaved); |
| 92 // |
| 93 // __ EnterInternalFrame(); |
| 94 // |
| 95 // // Store the registers containing object pointers on the expression stack to |
| 96 // // make sure that these are correctly updated during GC. |
| 97 // // Use sp as base to push. |
| 98 // __ CopyRegistersFromMemoryToStack(sp, pointer_regs); |
| 99 // |
| 100 //#ifdef DEBUG |
| 101 // __ RecordComment("// Calling from debug break to runtime - come in - over"); |
| 102 //#endif |
| 103 //// __ mov(r0, Operand(0)); // no arguments |
| 104 //// __ mov(r1, Operand(ExternalReference::debug_break())); |
| 105 // __ li(a0, Operand(0)); |
| 106 // __ li(a1, Operand(ExternalReference::debug_break())); |
| 107 // |
| 108 // CEntryDebugBreakStub ceb; |
| 109 // __ CallStub(&ceb); |
| 110 // |
| 111 // // Restore the register values containing object pointers from the expressio
n |
| 112 // // stack in the reverse order as they where pushed. |
| 113 // // Use sp as base to pop. |
| 114 // __ CopyRegistersFromStackToMemory(sp, a3, pointer_regs); |
| 115 // |
| 116 // __ LeaveInternalFrame(); |
| 117 // |
| 118 // // Finally restore all registers. |
| 119 // __ RestoreRegistersFromMemory(kJSCallerSaved); |
| 120 // |
| 121 // // Now that the break point has been handled, resume normal execution by |
| 122 // // jumping to the target address intended by the caller and that was |
| 123 // // overwritten by the address of DebugBreakXXX. |
| 124 //// __ mov(ip, Operand(ExternalReference(Debug_Address::AfterBreakTarget()))); |
| 125 //// __ ldr(ip, MemOperand(ip)); |
| 126 //// __ Jump(ip); |
| 127 // __ li(ip, Operand(ExternalReference(Debug_Address::AfterBreakTarget()))); |
| 128 // __ lw(ip, MemOperand(ip)); |
| 129 // __ Jump(ip); |
| 130 // __ nop(); // NOP_ADDED |
| 131 //} |
| 132 |
| 133 |
| 134 void Debug::GenerateLoadICDebugBreak(MacroAssembler* masm) { |
| 135 UNIMPLEMENTED_(); |
| 136 // Calling convention for IC load (from ic-arm.cc). |
| 137 // ----------- S t a t e ------------- |
| 138 // -- r0 : receiver |
| 139 // -- r2 : name |
| 140 // -- lr : return address |
| 141 // -- [sp] : receiver |
| 142 // ----------------------------------- |
| 143 // Registers r0 and r2 contain objects that needs to be pushed on the |
| 144 // expression stack of the fake JS frame. |
| 145 // Generate_DebugBreakCallHelper(masm, a0.bit() | a2.bit()); |
| 146 } |
| 147 |
| 148 |
| 149 void Debug::GenerateStoreICDebugBreak(MacroAssembler* masm) { |
| 150 UNIMPLEMENTED_(); |
| 151 // Calling convention for IC store (from ic-arm.cc). |
| 152 // ----------- S t a t e ------------- |
| 153 // -- r0 : receiver |
| 154 // -- r2 : name |
| 155 // -- lr : return address |
| 156 // -- [sp] : receiver |
| 157 // ----------------------------------- |
| 158 // Registers r0 and r2 contain objects that needs to be pushed on the |
| 159 // expression stack of the fake JS frame. |
| 160 // Generate_DebugBreakCallHelper(masm, a0.bit() | a2.bit()); |
| 161 } |
| 162 |
| 163 |
| 164 void Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) { |
| 165 UNIMPLEMENTED_(); |
| 166 // ---------- S t a t e -------------- |
| 167 // -- lr : return address |
| 168 // -- sp[0] : key |
| 169 // -- sp[4] : receiver |
| 170 // Generate_DebugBreakCallHelper(masm, 0); |
| 171 } |
| 172 |
| 173 |
| 174 void Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) { |
| 175 UNIMPLEMENTED_(); |
| 176 // ---------- S t a t e -------------- |
| 177 // -- lr : return address |
| 178 // -- sp[0] : key |
| 179 // -- sp[4] : receiver |
| 180 // Generate_DebugBreakCallHelper(masm, 0); |
| 181 } |
| 182 |
| 183 |
| 184 void Debug::GenerateCallICDebugBreak(MacroAssembler* masm) { |
| 185 UNIMPLEMENTED_(); |
| 186 // Calling convention for IC call (from ic-arm.cc) |
| 187 // ----------- S t a t e ------------- |
| 188 // -- r0: number of arguments |
| 189 // -- r1: receiver |
| 190 // -- lr: return address |
| 191 // ----------------------------------- |
| 192 // Register r1 contains an object that needs to be pushed on the expression |
| 193 // stack of the fake JS frame. r0 is the actual number of arguments not |
| 194 // encoded as a smi, therefore it cannot be on the expression stack of the |
| 195 // fake JS frame as it can easily be an invalid pointer (e.g. 1). r0 will be |
| 196 // pushed on the stack of the C frame and restored from there. |
| 197 // Generate_DebugBreakCallHelper(masm, a1.bit()); |
| 198 } |
| 199 |
| 200 |
| 201 void Debug::GenerateConstructCallDebugBreak(MacroAssembler* masm) { |
| 202 UNIMPLEMENTED_(); |
| 203 // In places other than IC call sites it is expected that r0 is TOS which |
| 204 // is an object - this is not generally the case so this should be used with |
| 205 // care. |
| 206 // Generate_DebugBreakCallHelper(masm, a0.bit()); |
| 207 } |
| 208 |
| 209 |
| 210 void Debug::GenerateReturnDebugBreak(MacroAssembler* masm) { |
| 211 UNIMPLEMENTED_(); |
| 212 // In places other than IC call sites it is expected that r0 is TOS which |
| 213 // is an object - this is not generally the case so this should be used with |
| 214 // care. |
| 215 // Generate_DebugBreakCallHelper(masm, a0.bit()); |
| 216 } |
| 217 |
| 218 |
| 219 void Debug::GenerateStubNoRegistersDebugBreak(MacroAssembler* masm) { |
| 220 UNIMPLEMENTED_(); |
| 221 // ----------- S t a t e ------------- |
| 222 // No registers used on entry. |
| 223 // ----------------------------------- |
| 224 // Generate_DebugBreakCallHelper(masm, 0); |
| 225 } |
| 226 |
| 227 |
| 228 #undef __ |
| 229 |
| 230 #endif // ENABLE_DEBUGGER_SUPPORT |
| 231 |
| 232 } } // namespace v8::internal |
| OLD | NEW |