aboutsummaryrefslogtreecommitdiff
path: root/source/Target/ThreadPlanStepRange.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Target/ThreadPlanStepRange.cpp')
-rw-r--r--source/Target/ThreadPlanStepRange.cpp65
1 files changed, 28 insertions, 37 deletions
diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp
index 3aed85859507..02667f8236ea 100644
--- a/source/Target/ThreadPlanStepRange.cpp
+++ b/source/Target/ThreadPlanStepRange.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepRange.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepRange.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/Disassembler.h"
@@ -31,7 +30,6 @@
using namespace lldb;
using namespace lldb_private;
-
//----------------------------------------------------------------------
// ThreadPlanStepRange: Step through a stack range, either stepping over or into
// based on the value of \a type.
@@ -127,7 +125,7 @@ ThreadPlanStepRange::DumpRanges(Stream *s)
{
for (size_t i = 0; i < num_ranges; i++)
{
- s->PutCString("%d: ");
+ s->Printf(" %" PRIu64 ": ", uint64_t(i));
m_address_ranges[i].Dump (s, m_thread.CalculateTarget().get(), Address::DumpStyleLoadAddress);
}
}
@@ -162,7 +160,7 @@ ThreadPlanStepRange::InRange ()
if (m_addr_context.line_entry.line == new_context.line_entry.line)
{
m_addr_context = new_context;
- AddRange(m_addr_context.line_entry.range);
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
ret_value = true;
if (log)
{
@@ -181,7 +179,7 @@ ThreadPlanStepRange::InRange ()
{
new_context.line_entry.line = m_addr_context.line_entry.line;
m_addr_context = new_context;
- AddRange(m_addr_context.line_entry.range);
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
ret_value = true;
if (log)
{
@@ -221,12 +219,9 @@ ThreadPlanStepRange::InRange ()
new_context.line_entry.line,
s.GetData());
}
-
}
}
-
}
-
}
if (!ret_value && log)
@@ -239,7 +234,7 @@ bool
ThreadPlanStepRange::InSymbol()
{
lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
- if (m_addr_context.function != NULL)
+ if (m_addr_context.function != nullptr)
{
return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, m_thread.CalculateTarget().get());
}
@@ -291,11 +286,7 @@ ThreadPlanStepRange::CompareCurrentFrameToStartFrame()
bool
ThreadPlanStepRange::StopOthers ()
{
- if (m_stop_others == lldb::eOnlyThisThread
- || m_stop_others == lldb::eOnlyDuringStepping)
- return true;
- else
- return false;
+ return (m_stop_others == lldb::eOnlyThisThread || m_stop_others == lldb::eOnlyDuringStepping);
}
InstructionList *
@@ -308,14 +299,14 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_
{
// Some joker added a zero size range to the stepping range...
if (m_address_ranges[i].GetByteSize() == 0)
- return NULL;
+ return nullptr;
if (!m_instruction_ranges[i])
{
//Disassemble the address range given:
ExecutionContext exe_ctx (m_thread.GetProcess());
- const char *plugin_name = NULL;
- const char *flavor = NULL;
+ const char *plugin_name = nullptr;
+ const char *flavor = nullptr;
const bool prefer_file_cache = true;
m_instruction_ranges[i] = Disassembler::DisassembleRange(GetTarget().GetArchitecture(),
plugin_name,
@@ -323,18 +314,17 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_
exe_ctx,
m_address_ranges[i],
prefer_file_cache);
-
}
if (!m_instruction_ranges[i])
- return NULL;
+ return nullptr;
else
{
// Find where we are in the instruction list as well. If we aren't at an instruction,
- // return NULL. In this case, we're probably lost, and shouldn't try to do anything fancy.
+ // return nullptr. In this case, we're probably lost, and shouldn't try to do anything fancy.
insn_offset = m_instruction_ranges[i]->GetInstructionList().GetIndexOfInstructionAtLoadAddress(addr, GetTarget());
if (insn_offset == UINT32_MAX)
- return NULL;
+ return nullptr;
else
{
range_index = i;
@@ -343,7 +333,7 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_
}
}
}
- return NULL;
+ return nullptr;
}
void
@@ -376,7 +366,7 @@ ThreadPlanStepRange::SetNextBranchBreakpoint ()
size_t pc_index;
size_t range_index;
InstructionList *instructions = GetInstructionsForAddress (cur_addr, range_index, pc_index);
- if (instructions == NULL)
+ if (instructions == nullptr)
return false;
else
{
@@ -389,13 +379,23 @@ ThreadPlanStepRange::SetNextBranchBreakpoint ()
// If we didn't find a branch, run to the end of the range.
if (branch_index == UINT32_MAX)
{
- branch_index = instructions->GetSize() - 1;
+ uint32_t last_index = instructions->GetSize() - 1;
+ if (last_index - pc_index > 1)
+ {
+ InstructionSP last_inst = instructions->GetInstructionAtIndex(last_index);
+ size_t last_inst_size = last_inst->GetOpcode().GetByteSize();
+ run_to_address = last_inst->GetAddress();
+ run_to_address.Slide(last_inst_size);
+ }
+ }
+ else if (branch_index - pc_index > 1)
+ {
+ run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
}
- if (branch_index - pc_index > 1)
+ if (run_to_address.IsValid())
{
const bool is_internal = true;
- run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
m_next_branch_bp_sp = GetTarget().CreateBreakpoint(run_to_address, is_internal, false);
if (m_next_branch_bp_sp)
{
@@ -501,15 +501,7 @@ ThreadPlanStepRange::MischiefManaged ()
else
{
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
- if (frame_order != eFrameCompareOlder)
- {
- if (m_no_more_plans)
- done = true;
- else
- done = false;
- }
- else
- done = true;
+ done = (frame_order != eFrameCompareOlder) ? m_no_more_plans : true;
}
}
@@ -526,7 +518,6 @@ ThreadPlanStepRange::MischiefManaged ()
{
return false;
}
-
}
bool