summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/API/SBAddress.h4
-rw-r--r--lldb/include/lldb/API/SBInstruction.h2
-rw-r--r--lldb/include/lldb/API/SBInstructionList.h9
-rw-r--r--lldb/include/lldb/Core/Disassembler.h2
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py9
-rw-r--r--lldb/scripts/interface/SBInstruction.i3
-rw-r--r--lldb/scripts/interface/SBInstructionList.i3
-rw-r--r--lldb/source/API/SBAddress.cpp6
-rw-r--r--lldb/source/API/SBInstruction.cpp7
-rw-r--r--lldb/source/API/SBInstructionList.cpp26
-rw-r--r--lldb/source/Core/Disassembler.cpp4
11 files changed, 70 insertions, 5 deletions
diff --git a/lldb/include/lldb/API/SBAddress.h b/lldb/include/lldb/API/SBAddress.h
index ddbe5a74278..9e697beffdd 100644
--- a/lldb/include/lldb/API/SBAddress.h
+++ b/lldb/include/lldb/API/SBAddress.h
@@ -103,6 +103,8 @@ protected:
const lldb_private::Address *operator->() const;
+ friend bool operator==(const SBAddress &lhs, const SBAddress &rhs);
+
lldb_private::Address *get();
lldb_private::Address &ref();
@@ -117,6 +119,8 @@ private:
std::unique_ptr<lldb_private::Address> m_opaque_ap;
};
+bool operator==(const SBAddress &lhs, const SBAddress &rhs);
+
} // namespace lldb
#endif // LLDB_SBAddress_h_
diff --git a/lldb/include/lldb/API/SBInstruction.h b/lldb/include/lldb/API/SBInstruction.h
index 0fc12eb61cb..23daf1c5663 100644
--- a/lldb/include/lldb/API/SBInstruction.h
+++ b/lldb/include/lldb/API/SBInstruction.h
@@ -53,6 +53,8 @@ public:
bool HasDelaySlot();
+ bool CanSetBreakpoint();
+
void Print(FILE *out);
bool GetDescription(lldb::SBStream &description);
diff --git a/lldb/include/lldb/API/SBInstructionList.h b/lldb/include/lldb/API/SBInstructionList.h
index 29baef5790e..0323a3c80c0 100644
--- a/lldb/include/lldb/API/SBInstructionList.h
+++ b/lldb/include/lldb/API/SBInstructionList.h
@@ -32,6 +32,15 @@ public:
lldb::SBInstruction GetInstructionAtIndex(uint32_t idx);
+ // ----------------------------------------------------------------------
+ // Returns the number of instructions between the start and end address.
+ // If canSetBreakpoint is true then the count will be the number of
+ // instructions on which a breakpoint can be set.
+ // ----------------------------------------------------------------------
+ size_t GetInstructionsCount(const SBAddress &start,
+ const SBAddress &end,
+ bool canSetBreakpoint = false);
+
void Clear();
void AppendInstruction(lldb::SBInstruction inst);
diff --git a/lldb/include/lldb/Core/Disassembler.h b/lldb/include/lldb/Core/Disassembler.h
index 929b668c092..addc83ad5e9 100644
--- a/lldb/include/lldb/Core/Disassembler.h
+++ b/lldb/include/lldb/Core/Disassembler.h
@@ -173,6 +173,8 @@ public:
virtual bool HasDelaySlot();
+ bool CanSetBreakpoint ();
+
virtual size_t Decode(const Disassembler &disassembler,
const DataExtractor &data,
lldb::offset_t data_offset) = 0;
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
index 00ddc628607..4dfeae3f5e1 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -62,12 +62,11 @@ class StepOverBreakpointsTestCase(TestBase):
instructions = function.GetInstructions(self.target)
addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress()
addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress()
- for i in range(instructions.GetSize()) :
- addr = instructions.GetInstructionAtIndex(i).GetAddress()
- if (addr == addr_1) : index_1 = i
- if (addr == addr_4) : index_4 = i
- steps_expected = index_4 - index_1
+ # if third argument is true then the count will be the number of
+ # instructions on which a breakpoint can be set.
+ # start = addr_1, end = addr_4, canSetBreakpoint = True
+ steps_expected = instructions.GetInstructionsCount(addr_1, addr_4, True)
step_count = 0
# Step from breakpoint_1 to breakpoint_4
while True:
diff --git a/lldb/scripts/interface/SBInstruction.i b/lldb/scripts/interface/SBInstruction.i
index d5b60201e95..c78799c6fe6 100644
--- a/lldb/scripts/interface/SBInstruction.i
+++ b/lldb/scripts/interface/SBInstruction.i
@@ -54,6 +54,9 @@ public:
bool
HasDelaySlot ();
+ bool
+ CanSetBreakpoint ();
+
void
Print (FILE *out);
diff --git a/lldb/scripts/interface/SBInstructionList.i b/lldb/scripts/interface/SBInstructionList.i
index 32603be5cc1..f4b572c341c 100644
--- a/lldb/scripts/interface/SBInstructionList.i
+++ b/lldb/scripts/interface/SBInstructionList.i
@@ -44,6 +44,9 @@ public:
lldb::SBInstruction
GetInstructionAtIndex (uint32_t idx);
+ size_t GetInstructionsCount(const SBAddress &start, const SBAddress &end,
+ bool canSetBreakpoint);
+
void
Clear ();
diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp
index b452ce327ab..a3493d7c743 100644
--- a/lldb/source/API/SBAddress.cpp
+++ b/lldb/source/API/SBAddress.cpp
@@ -55,6 +55,12 @@ const SBAddress &SBAddress::operator=(const SBAddress &rhs) {
return *this;
}
+bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) {
+ if (lhs.IsValid() && rhs.IsValid())
+ return lhs.ref() == rhs.ref();
+ return false;
+}
+
bool SBAddress::IsValid() const {
return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid();
}
diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp
index c47307c733a..8b7deb7011b 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/lldb/source/API/SBInstruction.cpp
@@ -176,6 +176,13 @@ bool SBInstruction::HasDelaySlot() {
return false;
}
+bool SBInstruction::CanSetBreakpoint () {
+ lldb::InstructionSP inst_sp(GetOpaque());
+ if (inst_sp)
+ return inst_sp->CanSetBreakpoint();
+ return false;
+}
+
lldb::InstructionSP SBInstruction::GetOpaque() {
if (m_opaque_sp)
return m_opaque_sp->GetSP();
diff --git a/lldb/source/API/SBInstructionList.cpp b/lldb/source/API/SBInstructionList.cpp
index 04c37f50c2d..3edb9eae98c 100644
--- a/lldb/source/API/SBInstructionList.cpp
+++ b/lldb/source/API/SBInstructionList.cpp
@@ -9,6 +9,7 @@
#include "lldb/API/SBInstructionList.h"
#include "lldb/API/SBInstruction.h"
+#include "lldb/API/SBAddress.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
@@ -49,6 +50,31 @@ SBInstruction SBInstructionList::GetInstructionAtIndex(uint32_t idx) {
return inst;
}
+size_t SBInstructionList::GetInstructionsCount(const SBAddress &start,
+ const SBAddress &end,
+ bool canSetBreakpoint) {
+ size_t num_instructions = GetSize();
+ size_t i = 0;
+ SBAddress addr;
+ size_t lower_index = 0;
+ size_t upper_index = 0;
+ size_t instructions_to_skip = 0;
+ for (i = 0; i < num_instructions; ++i) {
+ addr = GetInstructionAtIndex(i).GetAddress();
+ if (start == addr)
+ lower_index = i;
+ if (end == addr)
+ upper_index = i;
+ }
+ if (canSetBreakpoint)
+ for (i = lower_index; i <= upper_index; ++i) {
+ SBInstruction insn = GetInstructionAtIndex(i);
+ if (!insn.CanSetBreakpoint())
+ ++instructions_to_skip;
+ }
+ return upper_index - lower_index - instructions_to_skip;
+}
+
void SBInstructionList::Clear() { m_opaque_sp.reset(); }
void SBInstructionList::AppendInstruction(SBInstruction insn) {}
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index 3880bfd16ec..51d93d9acdb 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -759,6 +759,10 @@ bool Instruction::DumpEmulation(const ArchSpec &arch) {
return false;
}
+bool Instruction::CanSetBreakpoint () {
+ return !HasDelaySlot();
+}
+
bool Instruction::HasDelaySlot() {
// Default is false.
return false;
OpenPOWER on IntegriCloud