[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- ThreadPlanStepInstruction.cpp -------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-12-15 09:33:19 +08:00
|
|
|
#include "lldb/Target/ThreadPlanStepInstruction.h"
|
2010-08-04 09:40:35 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/RegisterContext.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2010-08-04 09:40:35 +08:00
|
|
|
#include "lldb/Target/StopInfo.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2017-03-04 04:56:28 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
// ThreadPlanStepInstruction: Step over the current instruction
|
|
|
|
|
|
|
|
ThreadPlanStepInstruction::ThreadPlanStepInstruction(Thread &thread,
|
|
|
|
bool step_over,
|
|
|
|
bool stop_other_threads,
|
|
|
|
Vote stop_vote,
|
|
|
|
Vote run_vote)
|
2010-06-19 12:45:32 +08:00
|
|
|
: ThreadPlan(ThreadPlan::eKindStepInstruction,
|
|
|
|
"Step over single instruction", thread, stop_vote, run_vote),
|
2010-07-16 20:32:33 +08:00
|
|
|
m_instruction_addr(0), m_stop_other_threads(stop_other_threads),
|
2012-03-02 04:01:22 +08:00
|
|
|
m_step_over(step_over) {
|
2014-07-09 03:28:57 +08:00
|
|
|
m_takes_iteration_count = true;
|
|
|
|
SetUpState();
|
|
|
|
}
|
|
|
|
|
2015-12-15 09:33:19 +08:00
|
|
|
ThreadPlanStepInstruction::~ThreadPlanStepInstruction() = default;
|
2014-07-09 03:28:57 +08:00
|
|
|
|
|
|
|
void ThreadPlanStepInstruction::SetUpState() {
|
2010-06-09 00:52:24 +08:00
|
|
|
m_instruction_addr = m_thread.GetRegisterContext()->GetPC(0);
|
2014-07-09 03:28:57 +08:00
|
|
|
StackFrameSP start_frame_sp(m_thread.GetStackFrameAtIndex(0));
|
|
|
|
m_stack_id = start_frame_sp->GetStackID();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-12-15 09:33:19 +08:00
|
|
|
m_start_has_symbol =
|
|
|
|
start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != nullptr;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-04 17:33:30 +08:00
|
|
|
StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
|
2013-07-25 08:59:01 +08:00
|
|
|
if (parent_frame_sp)
|
|
|
|
m_parent_frame_id = parent_frame_sp->GetStackID();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThreadPlanStepInstruction::GetDescription(Stream *s,
|
|
|
|
lldb::DescriptionLevel level) {
|
2018-11-15 09:18:15 +08:00
|
|
|
auto PrintFailureIfAny = [&]() {
|
|
|
|
if (m_status.Success())
|
|
|
|
return;
|
|
|
|
s->Printf(" failed (%s)", m_status.AsCString());
|
|
|
|
};
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (level == lldb::eDescriptionLevelBrief) {
|
|
|
|
if (m_step_over)
|
|
|
|
s->Printf("instruction step over");
|
|
|
|
else
|
|
|
|
s->Printf("instruction step into");
|
2018-11-15 09:18:15 +08:00
|
|
|
|
|
|
|
PrintFailureIfAny();
|
2010-06-09 00:52:24 +08:00
|
|
|
} else {
|
|
|
|
s->Printf("Stepping one instruction past ");
|
2019-12-05 21:41:09 +08:00
|
|
|
DumpAddress(s->AsRawOstream(), m_instruction_addr, sizeof(addr_t));
|
2013-07-26 08:27:57 +08:00
|
|
|
if (!m_start_has_symbol)
|
|
|
|
s->Printf(" which has no symbol");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (m_step_over)
|
|
|
|
s->Printf(" stepping over calls");
|
|
|
|
else
|
|
|
|
s->Printf(" stepping into calls");
|
2018-11-15 09:18:15 +08:00
|
|
|
|
|
|
|
PrintFailureIfAny();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ThreadPlanStepInstruction::ValidatePlan(Stream *error) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// Since we read the instruction we're stepping over from the thread, this
|
|
|
|
// plan will always work.
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 08:35:16 +08:00
|
|
|
bool ThreadPlanStepInstruction::DoPlanExplainsStop(Event *event_ptr) {
|
2013-06-04 09:40:51 +08:00
|
|
|
StopInfoSP stop_info_sp = GetPrivateStopInfo();
|
2010-10-20 08:39:53 +08:00
|
|
|
if (stop_info_sp) {
|
|
|
|
StopReason reason = stop_info_sp->GetStopReason();
|
2015-12-15 09:33:19 +08:00
|
|
|
return (reason == eStopReasonTrace || reason == eStopReasonNone);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-09 03:28:57 +08:00
|
|
|
bool ThreadPlanStepInstruction::IsPlanStale() {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
|
|
|
|
StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
|
|
|
|
if (cur_frame_id == m_stack_id) {
|
2017-02-15 19:42:47 +08:00
|
|
|
// Set plan Complete when we reach next instruction
|
|
|
|
uint64_t pc = m_thread.GetRegisterContext()->GetPC(0);
|
|
|
|
uint32_t max_opcode_size = m_thread.CalculateTarget()
|
|
|
|
->GetArchitecture().GetMaximumOpcodeByteSize();
|
|
|
|
bool next_instruction_reached = (pc > m_instruction_addr) &&
|
|
|
|
(pc <= m_instruction_addr + max_opcode_size);
|
|
|
|
if (next_instruction_reached) {
|
|
|
|
SetPlanComplete();
|
|
|
|
}
|
2015-12-15 09:33:19 +08:00
|
|
|
return (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr);
|
2014-07-09 03:28:57 +08:00
|
|
|
} else if (cur_frame_id < m_stack_id) {
|
|
|
|
// If the current frame is younger than the start frame and we are stepping
|
2018-05-01 00:49:04 +08:00
|
|
|
// over, then we need to continue, but if we are doing just one step, we're
|
|
|
|
// done.
|
2015-12-15 09:33:19 +08:00
|
|
|
return !m_step_over;
|
2014-07-09 03:28:57 +08:00
|
|
|
} else {
|
|
|
|
if (log) {
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"ThreadPlanStepInstruction::IsPlanStale - Current frame is "
|
|
|
|
"older than start frame, plan is stale.");
|
2014-07-09 03:28:57 +08:00
|
|
|
}
|
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-07-09 03:28:57 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
|
|
|
|
if (m_step_over) {
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-11-21 06:04:45 +08:00
|
|
|
StackFrameSP cur_frame_sp = m_thread.GetStackFrameAtIndex(0);
|
2012-03-02 04:01:22 +08:00
|
|
|
if (!cur_frame_sp) {
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(
|
|
|
|
log,
|
|
|
|
"ThreadPlanStepInstruction couldn't get the 0th frame, stopping.");
|
2014-11-21 06:04:45 +08:00
|
|
|
SetPlanComplete();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-25 08:59:01 +08:00
|
|
|
StackID cur_frame_zero_id = cur_frame_sp->GetStackID();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-03-02 04:01:22 +08:00
|
|
|
if (cur_frame_zero_id == m_stack_id || m_stack_id < cur_frame_zero_id) {
|
2013-07-25 08:59:01 +08:00
|
|
|
if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr) {
|
|
|
|
if (--m_iteration_count <= 0) {
|
2014-03-13 10:47:14 +08:00
|
|
|
SetPlanComplete();
|
2013-07-25 08:59:01 +08:00
|
|
|
return true;
|
|
|
|
} else {
|
2013-07-26 08:27:57 +08:00
|
|
|
// We are still stepping, reset the start pc, and in case we've
|
2018-05-01 00:49:04 +08:00
|
|
|
// stepped out, reset the current stack id.
|
2010-06-09 00:52:24 +08:00
|
|
|
SetUpState();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else
|
2014-07-09 03:28:57 +08:00
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
} else {
|
2016-02-04 03:45:31 +08:00
|
|
|
// We've stepped in, step back out again:
|
|
|
|
StackFrame *return_frame = m_thread.GetStackFrameAtIndex(1).get();
|
2013-07-26 08:27:57 +08:00
|
|
|
if (return_frame) {
|
2016-02-04 03:45:31 +08:00
|
|
|
if (return_frame->GetStackID() != m_parent_frame_id ||
|
2010-06-09 00:52:24 +08:00
|
|
|
m_start_has_symbol) {
|
2014-07-09 03:28:57 +08:00
|
|
|
// next-instruction shouldn't step out of inlined functions. But we
|
2018-05-01 00:49:04 +08:00
|
|
|
// may have stepped into a real function that starts with an inlined
|
|
|
|
// function, and we do want to step out of that...
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-07-09 03:28:57 +08:00
|
|
|
if (cur_frame_sp->IsInlined()) {
|
|
|
|
StackFrameSP parent_frame_sp =
|
|
|
|
m_thread.GetFrameWithStackID(m_stack_id);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-11-21 06:04:45 +08:00
|
|
|
if (parent_frame_sp &&
|
|
|
|
parent_frame_sp->GetConcreteFrameIndex() ==
|
2014-07-09 03:28:57 +08:00
|
|
|
cur_frame_sp->GetConcreteFrameIndex()) {
|
|
|
|
SetPlanComplete();
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log) {
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"Frame we stepped into is inlined into the frame "
|
|
|
|
"we were stepping from, stopping.");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-07-09 03:28:57 +08:00
|
|
|
return true;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log) {
|
2013-07-25 08:59:01 +08:00
|
|
|
StreamString s;
|
|
|
|
s.PutCString("Stepped in to: ");
|
|
|
|
addr_t stop_addr =
|
2010-06-09 00:52:24 +08:00
|
|
|
m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
|
2019-12-05 21:41:09 +08:00
|
|
|
DumpAddress(s.AsRawOstream(), stop_addr,
|
|
|
|
m_thread.CalculateTarget()
|
|
|
|
->GetArchitecture()
|
|
|
|
.GetAddressByteSize());
|
2013-07-25 08:59:01 +08:00
|
|
|
s.PutCString(" stepping out to: ");
|
|
|
|
addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
|
2019-12-05 21:41:09 +08:00
|
|
|
DumpAddress(s.AsRawOstream(), return_addr,
|
|
|
|
m_thread.CalculateTarget()
|
|
|
|
->GetArchitecture()
|
|
|
|
.GetAddressByteSize());
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "%s.", s.GetData());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// StepInstruction should probably have the tri-state RunMode, but
|
|
|
|
// for now it is safer to run others.
|
2013-07-25 08:59:01 +08:00
|
|
|
const bool stop_others = false;
|
2014-03-13 10:47:14 +08:00
|
|
|
m_thread.QueueThreadPlanForStepOutNoShouldStop(
|
2018-11-15 09:18:15 +08:00
|
|
|
false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion, 0,
|
|
|
|
m_status);
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
if (log) {
|
2013-07-26 08:27:57 +08:00
|
|
|
log->PutCString(
|
2014-07-09 03:28:57 +08:00
|
|
|
"The stack id we are stepping in changed, but our parent frame "
|
2013-07-26 08:27:57 +08:00
|
|
|
"did not when stepping from code with no symbols. "
|
2013-07-25 08:59:01 +08:00
|
|
|
"We are probably just confused about where we are, stopping.");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-07-25 08:59:01 +08:00
|
|
|
SetPlanComplete();
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
} else {
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "Could not find previous frame, stopping.");
|
2010-06-09 00:52:24 +08:00
|
|
|
SetPlanComplete();
|
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2010-06-09 00:52:24 +08:00
|
|
|
lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC(0);
|
|
|
|
if (pc_addr != m_instruction_addr) {
|
2014-07-09 03:28:57 +08:00
|
|
|
if (--m_iteration_count <= 0) {
|
2013-07-25 08:59:01 +08:00
|
|
|
SetPlanComplete();
|
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2014-07-09 03:28:57 +08:00
|
|
|
// We are still stepping, reset the start pc, and in case we've stepped
|
2018-05-01 00:49:04 +08:00
|
|
|
// in or out, reset the current stack id.
|
2014-07-09 03:28:57 +08:00
|
|
|
SetUpState();
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} else
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ThreadPlanStepInstruction::StopOthers() { return m_stop_other_threads; }
|
|
|
|
|
2010-11-12 03:26:09 +08:00
|
|
|
StateType ThreadPlanStepInstruction::GetPlanRunState() {
|
2010-06-09 00:52:24 +08:00
|
|
|
return eStateStepping;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ThreadPlanStepInstruction::WillStop() { return true; }
|
|
|
|
|
|
|
|
bool ThreadPlanStepInstruction::MischiefManaged() {
|
|
|
|
if (IsPlanComplete()) {
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "Completed single instruction step plan.");
|
2010-06-09 00:52:24 +08:00
|
|
|
ThreadPlan::MischiefManaged();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|