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