2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBBreakpointLocation.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/SBBreakpointLocation.h"
|
|
|
|
#include "lldb/API/SBDefines.h"
|
|
|
|
#include "lldb/API/SBDebugger.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#include "lldb/lldb-types.h"
|
|
|
|
#include "lldb/lldb-defines.h"
|
2010-11-19 02:52:36 +08:00
|
|
|
#include "lldb/Breakpoint/Breakpoint.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
2010-06-16 10:00:15 +08:00
|
|
|
#include "lldb/Target/ThreadSpec.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"
|
2010-12-21 04:49:23 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-18 09:47:08 +08:00
|
|
|
#include "lldb/Target/ThreadSpec.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
2010-11-06 07:17:00 +08:00
|
|
|
SBBreakpointLocation::SBBreakpointLocation () :
|
|
|
|
m_opaque_sp ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (break_loc_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
GetDescription (lldb::eDescriptionLevelBrief, sstr);
|
2010-10-27 07:49:36 +08:00
|
|
|
log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp"
|
|
|
|
"=%p) => this.sp = %p (%s)", break_loc_sp.get(), m_opaque_sp.get(), sstr.GetData());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-11-06 07:17:00 +08:00
|
|
|
SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) :
|
|
|
|
m_opaque_sp (rhs.m_opaque_sp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const SBBreakpointLocation &
|
|
|
|
SBBreakpointLocation::operator = (const SBBreakpointLocation &rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpointLocation::~SBBreakpointLocation ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBBreakpointLocation::IsValid() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() != NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
addr_t
|
|
|
|
SBBreakpointLocation::GetLoadAddress ()
|
|
|
|
{
|
|
|
|
addr_t ret_addr = LLDB_INVALID_ADDRESS;
|
|
|
|
|
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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
ret_addr = m_opaque_sp->GetLoadAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBBreakpointLocation::SetEnabled (bool enabled)
|
|
|
|
{
|
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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->SetEnabled (enabled);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBBreakpointLocation::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->GetBreakpoint().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;
|
|
|
|
}
|
|
|
|
|
2010-07-10 04:39:50 +08:00
|
|
|
uint32_t
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpointLocation::GetIgnoreCount ()
|
|
|
|
{
|
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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->GetIgnoreCount();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-07-10 04:39:50 +08:00
|
|
|
SBBreakpointLocation::SetIgnoreCount (uint32_t n)
|
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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->SetIgnoreCount (n);
|
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
|
|
|
|
SBBreakpointLocation::SetCondition (const char *condition)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
|
|
|
|
m_opaque_sp->SetCondition (condition);
|
|
|
|
}
|
2010-10-22 09:15:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBBreakpointLocation::GetCondition ()
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
|
|
|
|
return m_opaque_sp->GetConditionText ();
|
|
|
|
}
|
|
|
|
return NULL;
|
2010-10-22 09:15:49 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
SBBreakpointLocation::SetThreadID (tid_t 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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->SetThreadID (thread_id);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tid_t
|
|
|
|
SBBreakpointLocation::GetThreadID ()
|
|
|
|
{
|
2010-12-21 04:49:23 +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->GetBreakpoint().GetTarget().GetAPIMutex());
|
|
|
|
const ThreadSpec *thread_spec = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate();
|
|
|
|
if (thread_spec)
|
|
|
|
tid = thread_spec->GetTID();
|
|
|
|
}
|
|
|
|
return tid;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-06-18 09:47:08 +08:00
|
|
|
void
|
|
|
|
SBBreakpointLocation::SetThreadIndex (uint32_t 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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBBreakpointLocation::GetThreadIndex() const
|
|
|
|
{
|
2010-12-21 04:49:23 +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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
|
2010-12-21 04:49:23 +08:00
|
|
|
if (thread_spec)
|
|
|
|
thread_idx = thread_spec->GetIndex();
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
2010-12-21 04:49:23 +08:00
|
|
|
return thread_idx;
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
SBBreakpointLocation::SetThreadName (const char *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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBBreakpointLocation::GetThreadName () const
|
|
|
|
{
|
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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
|
2010-12-21 04:49:23 +08:00
|
|
|
if (thread_spec)
|
2010-06-18 09:47:08 +08:00
|
|
|
return thread_spec->GetName();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBBreakpointLocation::SetQueueName (const char *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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBBreakpointLocation::GetQueueName () const
|
|
|
|
{
|
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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
|
2010-12-21 04:49:23 +08:00
|
|
|
if (thread_spec)
|
2010-06-18 09:47:08 +08:00
|
|
|
return thread_spec->GetQueueName();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
SBBreakpointLocation::IsResolved ()
|
|
|
|
{
|
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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->IsResolved();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
// Uninstall the callbacks?
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp = break_loc_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool
|
2010-10-26 11:11:13 +08:00
|
|
|
SBBreakpointLocation::GetDescription (DescriptionLevel level, SBStream &description)
|
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->GetBreakpoint().GetTarget().GetAPIMutex());
|
2010-09-23 07:01:29 +08:00
|
|
|
description.ref();
|
2010-09-20 13:20:02 +08:00
|
|
|
m_opaque_sp->GetDescription (description.get(), level);
|
|
|
|
description.get()->EOL();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-09-20 13:20:02 +08:00
|
|
|
else
|
|
|
|
description.Printf ("No value");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint
|
|
|
|
SBBreakpointLocation::GetBreakpoint ()
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-27 07:49:36 +08:00
|
|
|
//if (log)
|
|
|
|
// log->Printf ("SBBreakpointLocation::GetBreakpoint ()");
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint sb_bp;
|
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->GetBreakpoint().GetTarget().GetAPIMutex());
|
|
|
|
*sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
sb_bp.GetDescription (sstr);
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBBreakpointLocation(%p)::GetBreakpoint () => SBBreakpoint(%p) %s",
|
2010-10-27 07:49:36 +08:00
|
|
|
m_opaque_sp.get(), sb_bp.get(), sstr.GetData());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|