Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame^] | 1 | /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 vi:set tabstop=4 expandtab: -*/ |
| 2 | //===-- RemoteDebuggerDummyUnwinder.hpp -------------------------*- C++ -*-===// |
| 3 | // |
| 4 | // The LLVM Compiler Infrastructure |
| 5 | // |
| 6 | // This file is distributed under the University of Illinois Open Source |
| 7 | // License. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | // Code to unwind past a debugger's dummy frame inserted when it does an |
| 12 | // inferior function call. |
| 13 | // In this case we'll need to get the saved register context from the debugger - |
| 14 | // it may be in the debugger's local memory or it may be saved in a nonstandard |
| 15 | // location in the inferior process' memory. |
| 16 | |
| 17 | #ifndef __REMOTE_DEBUGGER_DUMMY_UNWINDER_HPP__ |
| 18 | #define __REMOTE_DEBUGGER_DUMMY_UNWINDER_HPP__ |
| 19 | |
| 20 | #if defined (SUPPORT_REMOTE_UNWINDING) |
| 21 | |
| 22 | #include "libunwind.h" |
| 23 | #include "Registers.hpp" |
| 24 | #include "AddressSpace.hpp" |
| 25 | #include "RemoteRegisterMap.hpp" |
| 26 | #include "RemoteProcInfo.hpp" |
| 27 | |
| 28 | namespace lldb_private |
| 29 | { |
| 30 | |
| 31 | template <typename A> |
| 32 | int stepOutOfDebuggerDummyFrame (A& addressSpace, Registers_x86_64& registers, |
| 33 | RemoteProcInfo *procinfo, uint64_t ip, |
| 34 | uint64_t sp, void* arg) |
| 35 | { |
| 36 | Registers_x86_64 newRegisters(registers); |
| 37 | RemoteRegisterMap *rmap = addressSpace.getRemoteProcInfo()->getRegisterMap(); |
| 38 | unw_word_t regv; |
| 39 | for (int i = UNW_X86_64_RAX; i <= UNW_X86_64_R15; i++) { |
| 40 | int driver_regnum; |
| 41 | if (!rmap->unwind_regno_to_caller_regno (i, driver_regnum)) |
| 42 | continue; |
| 43 | if (addressSpace.accessors()->access_reg_inf_func_call (procinfo->wrap(), ip, sp, driver_regnum, ®v, 0, arg)) |
| 44 | newRegisters.setRegister(i, regv); |
| 45 | } |
| 46 | if (!addressSpace.accessors()->access_reg_inf_func_call (procinfo->wrap(), ip, sp, rmap->caller_regno_for_ip(), ®v, 0, arg)) |
| 47 | return UNW_EUNSPEC; |
| 48 | newRegisters.setIP (regv); |
| 49 | registers = newRegisters; |
| 50 | return UNW_STEP_SUCCESS; |
| 51 | } |
| 52 | |
| 53 | template <typename A> |
| 54 | int stepOutOfDebuggerDummyFrame (A& addressSpace, Registers_x86& registers, |
| 55 | RemoteProcInfo *procinfo, uint64_t ip, |
| 56 | uint64_t sp, void* arg) |
| 57 | { |
| 58 | Registers_x86 newRegisters(registers); |
| 59 | RemoteRegisterMap *rmap = addressSpace.getRemoteProcInfo()->getRegisterMap(); |
| 60 | unw_word_t regv; |
| 61 | for (int i = UNW_X86_EAX; i <= UNW_X86_EDI; i++) { |
| 62 | int driver_regnum; |
| 63 | if (!rmap->unwind_regno_to_caller_regno (i, driver_regnum)) |
| 64 | continue; |
| 65 | if (addressSpace.accessors()->access_reg_inf_func_call (procinfo->wrap(), ip, sp, driver_regnum, ®v, 0, arg)) |
| 66 | newRegisters.setRegister(i, regv); |
| 67 | } |
| 68 | if (!addressSpace.accessors()->access_reg_inf_func_call (procinfo->wrap(), ip, sp, rmap->caller_regno_for_ip(), ®v, 0, arg)) |
| 69 | return UNW_EUNSPEC; |
| 70 | newRegisters.setIP (regv); |
| 71 | registers = newRegisters; |
| 72 | return UNW_STEP_SUCCESS; |
| 73 | } |
| 74 | |
| 75 | template <typename A> |
| 76 | int stepOutOfDebuggerDummyFrame (A& addressSpace, Registers_ppc& registers, |
| 77 | uint64_t ip, uint64_t sp) |
| 78 | { |
| 79 | ABORT ("stepping out of a debugger dummy frame not supported on ppc"); |
| 80 | return UNW_EUNSPEC; |
| 81 | } |
| 82 | |
| 83 | }; // namespace lldb_private |
| 84 | |
| 85 | #endif // SUPPORT_REMOTE_UNWINDING |
| 86 | |
| 87 | #endif // __REMOTE_DEBUGGER_DUMMY_UNWINDER_HPP__ |
| 88 | |