diff options
author | Greg Clayton <gclayton@apple.com> | 2011-05-19 18:17:41 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-05-19 18:17:41 +0000 |
commit | 92bb12ca3e6dfbbebf906257f758d0b1a30ed425 (patch) | |
tree | 2b6f65bd2bf3fbc8af09f6c56987a8214d8cc3c0 | |
parent | 92ab6db6c8d2ebd4c71eb4d2b45d2233bfbef6ab (diff) | |
download | bcm5719-llvm-92bb12ca3e6dfbbebf906257f758d0b1a30ed425.tar.gz bcm5719-llvm-92bb12ca3e6dfbbebf906257f758d0b1a30ed425.zip |
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.
llvm-svn: 131658
-rw-r--r-- | lldb/include/lldb/Breakpoint/StoppointLocation.h | 58 | ||||
-rw-r--r-- | lldb/include/lldb/Core/Address.h | 20 | ||||
-rw-r--r-- | lldb/source/Breakpoint/StoppointLocation.cpp | 64 | ||||
-rw-r--r-- | lldb/source/Core/Address.cpp | 24 | ||||
-rw-r--r-- | lldb/source/Target/Process.cpp | 10 |
5 files changed, 97 insertions, 79 deletions
diff --git a/lldb/include/lldb/Breakpoint/StoppointLocation.h b/lldb/include/lldb/Breakpoint/StoppointLocation.h index 57a85af753b..871bb464346 100644 --- a/lldb/include/lldb/Breakpoint/StoppointLocation.h +++ b/lldb/include/lldb/Breakpoint/StoppointLocation.h @@ -46,37 +46,75 @@ public: // 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: //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index a22ba1e5253..2f69bc87579 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -299,6 +299,26 @@ public: 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 diff --git a/lldb/source/Breakpoint/StoppointLocation.cpp b/lldb/source/Breakpoint/StoppointLocation.cpp index 8d7325f0389..5613f90619c 100644 --- a/lldb/source/Breakpoint/StoppointLocation.cpp +++ b/lldb/source/Breakpoint/StoppointLocation.cpp @@ -46,67 +46,3 @@ StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, size_t size, 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 -{ - -} diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index de4e4d39164..7ab02a40f9a 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -301,6 +301,8 @@ Address::GetCallableLoadAddress (Target *target) const { 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 @@ Address::GetCallableLoadAddress (Target *target) const 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 { diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index d5a441bccba..58df901f2ad 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1323,7 +1323,7 @@ Process::EnableBreakpointSiteByID (lldb::user_id_t break_id) 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 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, } // 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 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, 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 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, // 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(); |