[Lldb-commits] [lldb] r131658 - in /lldb/trunk: include/lldb/Breakpoint/StoppointLocation.h include/lldb/Core/Address.h source/Breakpoint/StoppointLocation.cpp source/Core/Address.cpp source/Target/Process.cpp
Greg Clayton
gclayton at apple.com
Thu May 19 11:17:41 PDT 2011
Author: gclayton
Date: Thu May 19 13:17:41 2011
New Revision: 131658
URL: http://llvm.org/viewvc/llvm-project?rev=131658&view=rev
Log:
Moved a lot of simple functions from StoppointLocation.cpp to be inlined in
StoppointLocation.h.
Added a new lldb_private::Address function:
addr_t
Address::GetOpcodeLoadAddress (Target *target) const;
This will strip any special bits from an address to make sure it is suitable
for use in addressing an opcode. Often ARM addresses have an extra bit zero
that can be set to indicate ARM vs Thumb addresses (gotten from return address
registers, or symbol addresses that may be marked up specially). We need to
strip these bits off prior to setting breakpoints, so we can centralized the
place to do this inside the Address class.
Modified:
lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h
lldb/trunk/include/lldb/Core/Address.h
lldb/trunk/source/Breakpoint/StoppointLocation.cpp
lldb/trunk/source/Core/Address.cpp
lldb/trunk/source/Target/Process.cpp
Modified: lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h?rev=131658&r1=131657&r2=131658&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h Thu May 19 13:17:41 2011
@@ -46,37 +46,75 @@
// Methods
//------------------------------------------------------------------
virtual lldb::addr_t
- GetLoadAddress () const;
+ GetLoadAddress() const
+ {
+ return m_addr;
+ }
+
+ virtual lldb::addr_t
+ SetLoadAddress () const
+ {
+ return m_addr;
+ }
size_t
- GetByteSize () const;
+ GetByteSize () const
+ {
+ return m_byte_size;
+ }
uint32_t
- GetHitCount () const;
+ GetHitCount () const
+ {
+ return m_hit_count;
+ }
void
IncrementHitCount ();
uint32_t
- GetHardwareIndex () const;
+ GetHardwareIndex () const
+ {
+ return m_hw_index;
+ }
+
bool
- HardwarePreferred () const;
+ HardwarePreferred () const
+ {
+ return m_hw_preferred;
+ }
bool
- IsHardware () const;
+ IsHardware () const
+ {
+ return m_hw_index != LLDB_INVALID_INDEX32;
+ }
+
virtual bool
- ShouldStop (StoppointCallbackContext *context);
+ ShouldStop (StoppointCallbackContext *context)
+ {
+ return true;
+ }
virtual void
- Dump (Stream *stream) const;
+ Dump (Stream *stream) const
+ {
+ }
void
- SetHardwareIndex (uint32_t index);
+ SetHardwareIndex (uint32_t index)
+ {
+ m_hw_index = index;
+ }
+
lldb::break_id_t
- GetID () const;
+ GetID () const
+ {
+ return m_loc_id;
+ }
protected:
//------------------------------------------------------------------
Modified: lldb/trunk/include/lldb/Core/Address.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=131658&r1=131657&r2=131658&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Address.h (original)
+++ lldb/trunk/include/lldb/Core/Address.h Thu May 19 13:17:41 2011
@@ -299,6 +299,26 @@
GetCallableLoadAddress (Target *target) const;
//------------------------------------------------------------------
+ /// Get the load address as an opcode load address.
+ ///
+ /// This function will first resolve its address to a load address.
+ /// Then, if the address turns out to be in code address, return the
+ /// load address for a an opcode. This address object might have
+ /// extra bits set (bit zero will be set to Thumb functions for an
+ /// ARM target) that are required for changing the program counter
+ /// and this function will remove any bits that are intended for
+ /// these special purposes. The result of this function can be used
+ /// to safely write a software breakpoint trap to memory.
+ ///
+ /// @return
+ /// The valid load virtual address with extra callable bits
+ /// removed, or LLDB_INVALID_ADDRESS if the address is currently
+ /// not loaded.
+ //------------------------------------------------------------------
+ lldb::addr_t
+ GetOpcodeLoadAddress (Target *target) const;
+
+ //------------------------------------------------------------------
/// Get the section relative offset value.
///
/// @return
Modified: lldb/trunk/source/Breakpoint/StoppointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/StoppointLocation.cpp?rev=131658&r1=131657&r2=131658&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/StoppointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/StoppointLocation.cpp Thu May 19 13:17:41 2011
@@ -46,67 +46,3 @@
StoppointLocation::~StoppointLocation()
{
}
-
-
-size_t
-StoppointLocation::GetByteSize () const
-{
- return m_byte_size;
-}
-
-addr_t
-StoppointLocation::GetLoadAddress() const
-{
- return m_addr;
-}
-
-uint32_t
-StoppointLocation::GetHitCount () const
-{
- return m_hit_count;
-}
-
-bool
-StoppointLocation::HardwarePreferred () const
-{
- return m_hw_preferred;
-}
-
-bool
-StoppointLocation::IsHardware () const
-{
- return m_hw_index != LLDB_INVALID_INDEX32;
-}
-
-uint32_t
-StoppointLocation::GetHardwareIndex () const
-{
- return m_hw_index;
-}
-
-void
-StoppointLocation::SetHardwareIndex (uint32_t hw_index)
-{
- m_hw_index = hw_index;
-}
-
-// RETURNS - true if we should stop at this breakpoint, false if we
-// should continue.
-
-bool
-StoppointLocation::ShouldStop (StoppointCallbackContext *context)
-{
- return true;
-}
-
-break_id_t
-StoppointLocation::GetID() const
-{
- return m_loc_id;
-}
-
-void
-StoppointLocation::Dump (Stream *stream) const
-{
-
-}
Modified: lldb/trunk/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=131658&r1=131657&r2=131658&view=diff
==============================================================================
--- lldb/trunk/source/Core/Address.cpp (original)
+++ lldb/trunk/source/Core/Address.cpp Thu May 19 13:17:41 2011
@@ -301,6 +301,8 @@
{
addr_t code_addr = GetLoadAddress (target);
+ // Make sure we have section, otherwise the call to GetAddressClass() will
+ // fail because it uses the section to get to the module.
if (m_section && code_addr != LLDB_INVALID_ADDRESS)
{
switch (target->GetArchitecture().GetMachine())
@@ -332,6 +334,28 @@
return code_addr;
}
+addr_t
+Address::GetOpcodeLoadAddress (Target *target) const
+{
+ addr_t code_addr = GetLoadAddress (target);
+
+ if (code_addr != LLDB_INVALID_ADDRESS)
+ {
+ switch (target->GetArchitecture().GetMachine())
+ {
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ // Strip bit zero to make sure we end up on an opcode boundary
+ return code_addr & ~(1ull);
+ break;
+
+ default:
+ break;
+ }
+ }
+ return code_addr;
+}
+
bool
Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const
{
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=131658&r1=131657&r2=131658&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu May 19 13:17:41 2011
@@ -1323,7 +1323,7 @@
lldb::break_id_t
Process::CreateBreakpointSite (BreakpointLocationSP &owner, bool use_hardware)
{
- const addr_t load_addr = owner->GetAddress().GetLoadAddress (&m_target);
+ const addr_t load_addr = owner->GetAddress().GetOpcodeLoadAddress (&m_target);
if (load_addr != LLDB_INVALID_ADDRESS)
{
BreakpointSiteSP bp_site_sp;
@@ -3240,7 +3240,7 @@
}
// Save this value for restoration of the execution context after we run
- uint32_t tid = exe_ctx.thread->GetIndexID();
+ const uint32_t thread_idx_id = exe_ctx.thread->GetIndexID();
// N.B. Running the target may unset the currently selected thread and frame. We don't want to do that either,
// so we should arrange to reset them as well.
@@ -3378,12 +3378,12 @@
case lldb::eStateStopped:
{
// Yay, we're done. Now make sure that our thread plan actually completed.
- ThreadSP thread_sp = exe_ctx.process->GetThreadList().FindThreadByIndexID (tid);
+ ThreadSP thread_sp = exe_ctx.process->GetThreadList().FindThreadByIndexID (thread_idx_id);
if (!thread_sp)
{
// Ooh, our thread has vanished. Unlikely that this was successful execution...
if (log)
- log->Printf ("Execution completed but our thread has vanished.");
+ log->Printf ("Execution completed but our thread (index-id=%u) has vanished.", thread_idx_id);
return_value = eExecutionInterrupted;
}
else
@@ -3733,7 +3733,7 @@
// Thread we ran the function in may have gone away because we ran the target
// Check that it's still there.
- exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(tid, true).get();
+ exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(thread_idx_id, true).get();
if (exe_ctx.thread)
exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get();
More information about the lldb-commits
mailing list