Fix Rendezvous breakpoint to only be set once, resolve addr in BreakpointLocationList::FindByAddress

Differential Revision: http://llvm-reviews.chandlerc.com/D1145

llvm-svn: 186458
This commit is contained in:
Michael Sartain
2013-07-16 21:22:53 +00:00
parent 3b537d4023
commit c87e752bb5
3 changed files with 43 additions and 8 deletions

View File

@@ -14,7 +14,9 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocationList.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/Section.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@@ -114,7 +116,24 @@ BreakpointLocationList::FindByAddress (const Address &addr) const
BreakpointLocationSP bp_loc_sp;
if (!m_locations.empty())
{
addr_map::const_iterator pos = m_address_to_location.find (addr);
Address so_addr;
if (addr.IsSectionOffset())
{
so_addr = addr;
}
else
{
// Try and resolve as a load address if possible.
m_owner.GetTarget().GetSectionLoadList().ResolveLoadAddress (addr.GetOffset(), so_addr);
if (!so_addr.IsValid())
{
// The address didn't resolve, so just set to passed in addr.
so_addr = addr;
}
}
addr_map::const_iterator pos = m_address_to_location.find (so_addr);
if (pos != m_address_to_location.end())
bp_loc_sp = pos->second;
}

View File

@@ -20,6 +20,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "AuxVector.h"
#include "DynamicLoaderPOSIXDYLD.h"
@@ -93,12 +94,18 @@ DynamicLoaderPOSIXDYLD::DynamicLoaderPOSIXDYLD(Process *process)
m_rendezvous(process),
m_load_offset(LLDB_INVALID_ADDRESS),
m_entry_point(LLDB_INVALID_ADDRESS),
m_auxv()
m_auxv(),
m_dyld_bid(LLDB_INVALID_BREAK_ID)
{
}
DynamicLoaderPOSIXDYLD::~DynamicLoaderPOSIXDYLD()
{
if (m_dyld_bid != LLDB_INVALID_BREAK_ID)
{
m_process->GetTarget().RemoveBreakpointByID (m_dyld_bid);
m_dyld_bid = LLDB_INVALID_BREAK_ID;
}
}
void
@@ -263,13 +270,19 @@ DynamicLoaderPOSIXDYLD::EntryBreakpointHit(void *baton,
void
DynamicLoaderPOSIXDYLD::SetRendezvousBreakpoint()
{
Breakpoint *dyld_break;
addr_t break_addr;
addr_t break_addr = m_rendezvous.GetBreakAddress();
Target &target = m_process->GetTarget();
break_addr = m_rendezvous.GetBreakAddress();
dyld_break = m_process->GetTarget().CreateBreakpoint(break_addr, true).get();
dyld_break->SetCallback(RendezvousBreakpointHit, this, true);
dyld_break->SetBreakpointKind ("shared-library-event");
if (m_dyld_bid == LLDB_INVALID_BREAK_ID)
{
Breakpoint *dyld_break = target.CreateBreakpoint (break_addr, true).get();
dyld_break->SetCallback(RendezvousBreakpointHit, this, true);
dyld_break->SetBreakpointKind ("shared-library-event");
m_dyld_bid = dyld_break->GetID();
}
// Make sure our breakpoint is at the right address.
assert (target.GetBreakpointByID(m_dyld_bid)->FindLocationByAddress(break_addr)->GetBreakpoint().GetID() == m_dyld_bid);
}
bool

View File

@@ -92,6 +92,9 @@ protected:
/// Auxiliary vector of the inferior process.
std::unique_ptr<AuxVector> m_auxv;
/// Rendezvous breakpoint.
lldb::break_id_t m_dyld_bid;
/// Enables a breakpoint on a function called by the runtime
/// linker each time a module is loaded or unloaded.
void