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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
//===-- ThreadPlanStepThrough.cpp -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/ThreadPlanStepThrough.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private-log.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
using namespace lldb;
using namespace lldb_private;
//----------------------------------------------------------------------
// ThreadPlanStepThrough: If the current instruction is a trampoline, step through it
// If it is the beginning of the prologue of a function, step through that as well.
// FIXME: At present only handles DYLD trampolines.
//----------------------------------------------------------------------
ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, bool stop_others) :
ThreadPlan (ThreadPlan::eKindStepThrough, "Step through trampolines and prologues", thread, eVoteNoOpinion, eVoteNoOpinion),
m_start_address (0),
m_stop_others (stop_others)
{
m_start_address = GetThread().GetRegisterContext()->GetPC(0);
}
ThreadPlanStepThrough::~ThreadPlanStepThrough ()
{
}
void
ThreadPlanStepThrough::GetDescription (Stream *s, lldb::DescriptionLevel level)
{
if (level == lldb::eDescriptionLevelBrief)
s->Printf ("Step through");
else
{
s->Printf ("Stepping through trampoline code from: ");
s->Address(m_start_address, sizeof (addr_t));
}
}
bool
ThreadPlanStepThrough::ValidatePlan (Stream *error)
{
if (HappyToStopHere())
return false;
else
return true;
}
bool
ThreadPlanStepThrough::PlanExplainsStop ()
{
return true;
}
bool
ThreadPlanStepThrough::ShouldStop (Event *event_ptr)
{
return true;
}
bool
ThreadPlanStepThrough::StopOthers ()
{
return m_stop_others;
}
StateType
ThreadPlanStepThrough::RunState ()
{
return eStateStepping;
}
bool
ThreadPlanStepThrough::WillResume (StateType resume_state, bool current_plan)
{
ThreadPlan::WillResume(resume_state, current_plan);
if (current_plan)
{
ThreadPlanSP sub_plan_sp(m_thread.GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (m_thread, m_stop_others));
// If that didn't come up with anything, try the ObjC runtime plugin:
if (sub_plan_sp == NULL)
{
ObjCLanguageRuntime *objc_runtime = m_thread.GetProcess().GetObjCLanguageRuntime();
if (objc_runtime)
sub_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (m_thread, m_stop_others);
}
if (sub_plan_sp != NULL)
PushPlan (sub_plan_sp);
}
return true;
}
bool
ThreadPlanStepThrough::WillStop ()
{
return true;
}
bool
ThreadPlanStepThrough::MischiefManaged ()
{
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
// Stop if we're happy with the place we've landed...
if (!HappyToStopHere())
{
// If we are still at the PC we were trying to step over.
return false;
}
else
{
if (log)
log->Printf("Completed step through step plan.");
ThreadPlan::MischiefManaged ();
return true;
}
}
bool
ThreadPlanStepThrough::HappyToStopHere()
{
// This should again ask the various trampolines whether we are still at a
// trampoline point, and if so, continue through the possibly nested trampolines.
return true;
}
|