2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBBreakpoint.cpp ----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBBreakpoint.h"
|
|
|
|
#include "lldb/API/SBBreakpointLocation.h"
|
|
|
|
#include "lldb/API/SBDebugger.h"
|
2010-07-24 07:33:17 +08:00
|
|
|
#include "lldb/API/SBEvent.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBProcess.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBThread.h"
|
|
|
|
|
|
|
|
#include "lldb/Breakpoint/Breakpoint.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
|
|
|
#include "lldb/Breakpoint/StoppointCallbackContext.h"
|
|
|
|
#include "lldb/Core/Address.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Core/StreamFile.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
2013-12-06 09:12:00 +08:00
|
|
|
#include "lldb/Target/SectionLoadList.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-18 09:47:08 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
#include "lldb/Target/ThreadSpec.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include "lldb/lldb-enumerations.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
struct CallbackData
|
|
|
|
{
|
|
|
|
SBBreakpoint::BreakpointHitCallback callback;
|
|
|
|
void *callback_baton;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SBBreakpointCallbackBaton : public Baton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SBBreakpointCallbackBaton (SBBreakpoint::BreakpointHitCallback callback, void *baton) :
|
|
|
|
Baton (new CallbackData)
|
|
|
|
{
|
|
|
|
CallbackData *data = (CallbackData *)m_data;
|
|
|
|
data->callback = callback;
|
|
|
|
data->callback_baton = baton;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~SBBreakpointCallbackBaton()
|
|
|
|
{
|
|
|
|
CallbackData *data = (CallbackData *)m_data;
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
delete data;
|
|
|
|
m_data = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
SBBreakpoint::SBBreakpoint () :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint::SBBreakpoint (const SBBreakpoint& rhs) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (rhs.m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (bp_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint::~SBBreakpoint()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const SBBreakpoint &
|
|
|
|
SBBreakpoint::operator = (const SBBreakpoint& rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2010-12-13 03:25:26 +08:00
|
|
|
bool
|
|
|
|
SBBreakpoint::operator == (const lldb::SBBreakpoint& rhs)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp && rhs.m_opaque_sp)
|
|
|
|
return m_opaque_sp.get() == rhs.m_opaque_sp.get();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-03 09:29:27 +08:00
|
|
|
bool
|
|
|
|
SBBreakpoint::operator != (const lldb::SBBreakpoint& rhs)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp && rhs.m_opaque_sp)
|
|
|
|
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
|
|
|
|
return (m_opaque_sp && !rhs.m_opaque_sp) || (rhs.m_opaque_sp && !m_opaque_sp);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
break_id_t
|
|
|
|
SBBreakpoint::GetID () const
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-12-21 04:49:23 +08:00
|
|
|
break_id_t break_id = LLDB_INVALID_BREAK_ID;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
break_id = m_opaque_sp->GetID();
|
|
|
|
|
|
|
|
if (log)
|
2010-10-26 11:11:13 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
if (break_id == LLDB_INVALID_BREAK_ID)
|
|
|
|
log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", m_opaque_sp.get());
|
|
|
|
else
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBBreakpoint(%p)::GetID () => %u", m_opaque_sp.get(), break_id);
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-12-21 04:49:23 +08:00
|
|
|
return break_id;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBBreakpoint::IsValid() const
|
|
|
|
{
|
2012-08-11 08:35:26 +08:00
|
|
|
return (bool) m_opaque_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBBreakpoint::ClearAllBreakpointSites ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->ClearAllBreakpointSites ();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpointLocation
|
|
|
|
SBBreakpoint::FindLocationByAddress (addr_t vm_addr)
|
|
|
|
{
|
|
|
|
SBBreakpointLocation sb_bp_location;
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (vm_addr != LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-09 00:52:24 +08:00
|
|
|
Address address;
|
2010-09-15 07:36:40 +08:00
|
|
|
Target &target = m_opaque_sp->GetTarget();
|
|
|
|
if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
address.SetRawAddress (vm_addr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_bp_location.SetLocation (m_opaque_sp->FindLocationByAddress (address));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb_bp_location;
|
|
|
|
}
|
|
|
|
|
|
|
|
break_id_t
|
|
|
|
SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
break_id_t break_id = LLDB_INVALID_BREAK_ID;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-12-21 04:49:23 +08:00
|
|
|
if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
|
|
|
Address address;
|
|
|
|
Target &target = m_opaque_sp->GetTarget();
|
|
|
|
if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
address.SetRawAddress (vm_addr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-12-21 04:49:23 +08:00
|
|
|
break_id = m_opaque_sp->FindLocationIDByAddress (address);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-12-21 04:49:23 +08:00
|
|
|
return break_id;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpointLocation
|
|
|
|
SBBreakpoint::FindLocationByID (break_id_t bp_loc_id)
|
|
|
|
{
|
|
|
|
SBBreakpointLocation sb_bp_location;
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
return sb_bp_location;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpointLocation
|
|
|
|
SBBreakpoint::GetLocationAtIndex (uint32_t index)
|
|
|
|
{
|
|
|
|
SBBreakpointLocation sb_bp_location;
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
return sb_bp_location;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBBreakpoint::SetEnabled (bool enable)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBBreakpoint(%p)::SetEnabled (enabled=%i)", m_opaque_sp.get(), enable);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->SetEnabled (enable);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBBreakpoint::IsEnabled ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->IsEnabled();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-06 03:16:31 +08:00
|
|
|
void
|
|
|
|
SBBreakpoint::SetOneShot (bool one_shot)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2012-10-06 03:16:31 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf ("SBBreakpoint(%p)::SetOneShot (one_shot=%i)", m_opaque_sp.get(), one_shot);
|
|
|
|
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
|
|
|
m_opaque_sp->SetOneShot (one_shot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBBreakpoint::IsOneShot () const
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
|
|
|
return m_opaque_sp->IsOneShot();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-26 07:55:19 +08:00
|
|
|
bool
|
|
|
|
SBBreakpoint::IsInternal ()
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
|
|
|
return m_opaque_sp->IsInternal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
2010-07-10 04:39:50 +08:00
|
|
|
SBBreakpoint::SetIgnoreCount (uint32_t count)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBBreakpoint(%p)::SetIgnoreCount (count=%u)", m_opaque_sp.get(), count);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->SetIgnoreCount (count);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-22 09:15:49 +08:00
|
|
|
void
|
|
|
|
SBBreakpoint::SetCondition (const char *condition)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
|
|
|
m_opaque_sp->SetCondition (condition);
|
|
|
|
}
|
2010-10-22 09:15:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBBreakpoint::GetCondition ()
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
|
|
|
return m_opaque_sp->GetConditionText ();
|
|
|
|
}
|
|
|
|
return NULL;
|
2010-10-22 09:15:49 +08:00
|
|
|
}
|
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
uint32_t
|
|
|
|
SBBreakpoint::GetHitCount () const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
uint32_t count = 0;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-10-30 12:51:46 +08:00
|
|
|
count = m_opaque_sp->GetHitCount();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBBreakpoint(%p)::GetHitCount () => %u", m_opaque_sp.get(), count);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-30 12:51:46 +08:00
|
|
|
return count;
|
2010-07-24 07:33:17 +08:00
|
|
|
}
|
|
|
|
|
2010-07-10 04:39:50 +08:00
|
|
|
uint32_t
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint::GetIgnoreCount () const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
uint32_t count = 0;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-10-30 12:51:46 +08:00
|
|
|
count = m_opaque_sp->GetIgnoreCount();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBBreakpoint(%p)::GetIgnoreCount () => %u", m_opaque_sp.get(), count);
|
|
|
|
|
|
|
|
return count;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-10-30 12:51:46 +08:00
|
|
|
SBBreakpoint::SetThreadID (tid_t tid)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-10-30 12:51:46 +08:00
|
|
|
m_opaque_sp->SetThreadID (tid);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")", m_opaque_sp.get(), tid);
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tid_t
|
|
|
|
SBBreakpoint::GetThreadID ()
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
tid_t tid = LLDB_INVALID_THREAD_ID;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-10-30 12:51:46 +08:00
|
|
|
tid = m_opaque_sp->GetThreadID();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf ("SBBreakpoint(%p)::GetThreadID () => 0x%4.4" PRIx64, m_opaque_sp.get(), tid);
|
2010-10-30 12:51:46 +08:00
|
|
|
return tid;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-06-18 09:47:08 +08:00
|
|
|
void
|
|
|
|
SBBreakpoint::SetThreadIndex (uint32_t index)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBBreakpoint(%p)::SetThreadIndex (%u)", m_opaque_sp.get(), index);
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBBreakpoint::GetThreadIndex() const
|
|
|
|
{
|
2010-12-16 04:50:06 +08:00
|
|
|
uint32_t thread_idx = UINT32_MAX;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-18 09:47:08 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
|
|
|
const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
|
2010-12-16 05:39:37 +08:00
|
|
|
if (thread_spec != NULL)
|
2010-10-30 12:51:46 +08:00
|
|
|
thread_idx = thread_spec->GetIndex();
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2010-12-16 04:50:06 +08:00
|
|
|
log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), thread_idx);
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-12-16 05:39:37 +08:00
|
|
|
return thread_idx;
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
SBBreakpoint::SetThreadName (const char *thread_name)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBBreakpoint(%p)::SetThreadName (%s)", m_opaque_sp.get(), thread_name);
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBBreakpoint::GetThreadName () const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
const char *name = NULL;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-18 09:47:08 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
|
|
|
const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
|
2010-12-16 05:39:37 +08:00
|
|
|
if (thread_spec != NULL)
|
2010-10-30 12:51:46 +08:00
|
|
|
name = thread_spec->GetName();
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBBreakpoint(%p)::GetThreadName () => %s", m_opaque_sp.get(), name);
|
|
|
|
|
|
|
|
return name;
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBBreakpoint::SetQueueName (const char *queue_name)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBBreakpoint(%p)::SetQueueName (%s)", m_opaque_sp.get(), queue_name);
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBBreakpoint::GetQueueName () const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
const char *name = NULL;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-18 09:47:08 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
|
|
|
const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
|
|
|
|
if (thread_spec)
|
2010-10-30 12:51:46 +08:00
|
|
|
name = thread_spec->GetQueueName();
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBBreakpoint(%p)::GetQueueName () => %s", m_opaque_sp.get(), name);
|
|
|
|
|
|
|
|
return name;
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t
|
|
|
|
SBBreakpoint::GetNumResolvedLocations() const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
size_t num_resolved = 0;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-10-30 12:51:46 +08:00
|
|
|
num_resolved = m_opaque_sp->GetNumResolvedLocations();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64, m_opaque_sp.get(), (uint64_t)num_resolved);
|
2010-10-30 12:51:46 +08:00
|
|
|
return num_resolved;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBBreakpoint::GetNumLocations() const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
size_t num_locs = 0;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-10-30 12:51:46 +08:00
|
|
|
num_locs = m_opaque_sp->GetNumLocations();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf ("SBBreakpoint(%p)::GetNumLocations () => %" PRIu64, m_opaque_sp.get(), (uint64_t)num_locs);
|
2010-10-30 12:51:46 +08:00
|
|
|
return num_locs;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool
|
2010-10-07 12:19:01 +08:00
|
|
|
SBBreakpoint::GetDescription (SBStream &s)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-10-07 12:19:01 +08:00
|
|
|
s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
|
|
|
|
m_opaque_sp->GetResolverDescription (s.get());
|
|
|
|
m_opaque_sp->GetFilterDescription (s.get());
|
|
|
|
const size_t num_locations = m_opaque_sp->GetNumLocations ();
|
2012-11-30 05:49:15 +08:00
|
|
|
s.Printf(", locations = %" PRIu64, (uint64_t)num_locations);
|
2010-10-07 12:19:01 +08:00
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-10-07 12:19:01 +08:00
|
|
|
s.Printf ("No value");
|
|
|
|
return false;
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
SBBreakpoint::PrivateBreakpointHitCallback
|
|
|
|
(
|
|
|
|
void *baton,
|
|
|
|
StoppointCallbackContext *ctx,
|
|
|
|
lldb::user_id_t break_id,
|
|
|
|
lldb::user_id_t break_loc_id
|
|
|
|
)
|
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
ExecutionContext exe_ctx (ctx->exe_ctx_ref);
|
|
|
|
BreakpointSP bp_sp(exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));
|
2010-06-09 00:52:24 +08:00
|
|
|
if (baton && bp_sp)
|
|
|
|
{
|
|
|
|
CallbackData *data = (CallbackData *)baton;
|
|
|
|
lldb_private::Breakpoint *bp = bp_sp.get();
|
|
|
|
if (bp && data->callback)
|
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
2011-09-22 12:58:26 +08:00
|
|
|
if (process)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 04:56:30 +08:00
|
|
|
SBProcess sb_process (process->shared_from_this());
|
2010-06-09 00:52:24 +08:00
|
|
|
SBThread sb_thread;
|
|
|
|
SBBreakpointLocation sb_location;
|
|
|
|
assert (bp_sp);
|
|
|
|
sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id));
|
2012-02-21 08:09:25 +08:00
|
|
|
Thread *thread = exe_ctx.GetThreadPtr();
|
2011-09-22 12:58:26 +08:00
|
|
|
if (thread)
|
2012-01-30 04:56:30 +08:00
|
|
|
sb_thread.SetThread(thread->shared_from_this());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
return data->callback (data->callback_baton,
|
|
|
|
sb_process,
|
|
|
|
sb_thread,
|
|
|
|
sb_location);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true; // Return true if we should stop at this breakpoint
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)", m_opaque_sp.get(), callback, baton);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
|
2010-06-09 00:52:24 +08:00
|
|
|
BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton));
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lldb_private::Breakpoint *
|
|
|
|
SBBreakpoint::operator->() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::Breakpoint *
|
|
|
|
SBBreakpoint::get() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::BreakpointSP &
|
|
|
|
SBBreakpoint::operator *()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const lldb::BreakpointSP &
|
|
|
|
SBBreakpoint::operator *() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-08 13:23:15 +08:00
|
|
|
bool
|
|
|
|
SBBreakpoint::EventIsBreakpointEvent (const lldb::SBEvent &event)
|
|
|
|
{
|
|
|
|
return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
BreakpointEventType
|
|
|
|
SBBreakpoint::GetBreakpointEventTypeFromEvent (const SBEvent& event)
|
|
|
|
{
|
|
|
|
if (event.IsValid())
|
|
|
|
return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (event.GetSP());
|
|
|
|
return eBreakpointEventTypeInvalidType;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint
|
|
|
|
SBBreakpoint::GetBreakpointFromEvent (const lldb::SBEvent& event)
|
|
|
|
{
|
|
|
|
SBBreakpoint sb_breakpoint;
|
|
|
|
if (event.IsValid())
|
|
|
|
sb_breakpoint.m_opaque_sp = Breakpoint::BreakpointEventData::GetBreakpointFromEvent (event.GetSP());
|
|
|
|
return sb_breakpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpointLocation
|
|
|
|
SBBreakpoint::GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx)
|
|
|
|
{
|
|
|
|
SBBreakpointLocation sb_breakpoint_loc;
|
|
|
|
if (event.IsValid())
|
|
|
|
sb_breakpoint_loc.SetLocation (Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (event.GetSP(), loc_idx));
|
|
|
|
return sb_breakpoint_loc;
|
|
|
|
}
|
|
|
|
|
2012-02-08 13:23:15 +08:00
|
|
|
uint32_t
|
|
|
|
SBBreakpoint::GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event)
|
|
|
|
{
|
|
|
|
uint32_t num_locations = 0;
|
|
|
|
if (event.IsValid())
|
|
|
|
num_locations = (Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (event.GetSP()));
|
|
|
|
return num_locations;
|
|
|
|
}
|
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
|