1 //===-- SBBreakpointLocation.cpp --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SBBreakpointLocation.h"
11 #include "lldb/API/SBDefines.h"
12 #include "lldb/API/SBAddress.h"
13 #include "lldb/API/SBDebugger.h"
14 #include "lldb/API/SBStream.h"
16 #include "lldb/lldb-types.h"
17 #include "lldb/lldb-defines.h"
18 #include "lldb/Breakpoint/Breakpoint.h"
19 #include "lldb/Breakpoint/BreakpointLocation.h"
20 #include "lldb/Target/ThreadSpec.h"
21 #include "lldb/Core/Log.h"
22 #include "lldb/Core/Stream.h"
23 #include "lldb/Core/StreamFile.h"
24 #include "lldb/Target/Target.h"
25 #include "lldb/Target/ThreadSpec.h"
28 using namespace lldb_private;
31 SBBreakpointLocation::SBBreakpointLocation () :
36 SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) :
37 m_opaque_sp (break_loc_sp)
39 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
44 GetDescription (sstr, lldb::eDescriptionLevelBrief);
45 log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp"
46 "=%p) => this.sp = %p (%s)", break_loc_sp.get(), m_opaque_sp.get(), sstr.GetData());
50 SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) :
51 m_opaque_sp (rhs.m_opaque_sp)
55 const SBBreakpointLocation &
56 SBBreakpointLocation::operator = (const SBBreakpointLocation &rhs)
59 m_opaque_sp = rhs.m_opaque_sp;
64 SBBreakpointLocation::~SBBreakpointLocation ()
69 SBBreakpointLocation::IsValid() const
71 return m_opaque_sp.get() != NULL;
75 SBBreakpointLocation::GetAddress ()
78 return SBAddress(&m_opaque_sp->GetAddress());
84 SBBreakpointLocation::GetLoadAddress ()
86 addr_t ret_addr = LLDB_INVALID_ADDRESS;
90 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
91 ret_addr = m_opaque_sp->GetLoadAddress();
98 SBBreakpointLocation::SetEnabled (bool enabled)
102 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
103 m_opaque_sp->SetEnabled (enabled);
108 SBBreakpointLocation::IsEnabled ()
112 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
113 return m_opaque_sp->IsEnabled();
120 SBBreakpointLocation::GetIgnoreCount ()
124 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
125 return m_opaque_sp->GetIgnoreCount();
132 SBBreakpointLocation::SetIgnoreCount (uint32_t n)
136 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
137 m_opaque_sp->SetIgnoreCount (n);
142 SBBreakpointLocation::SetCondition (const char *condition)
146 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
147 m_opaque_sp->SetCondition (condition);
152 SBBreakpointLocation::GetCondition ()
156 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
157 return m_opaque_sp->GetConditionText ();
163 SBBreakpointLocation::SetThreadID (tid_t thread_id)
167 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
168 m_opaque_sp->SetThreadID (thread_id);
173 SBBreakpointLocation::GetThreadID ()
175 tid_t tid = LLDB_INVALID_THREAD_ID;
178 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
179 return m_opaque_sp->GetThreadID();
185 SBBreakpointLocation::SetThreadIndex (uint32_t index)
189 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
190 m_opaque_sp->SetThreadIndex (index);
195 SBBreakpointLocation::GetThreadIndex() const
197 uint32_t thread_idx = UINT32_MAX;
200 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
201 return m_opaque_sp->GetThreadIndex();
208 SBBreakpointLocation::SetThreadName (const char *thread_name)
212 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
213 m_opaque_sp->SetThreadName (thread_name);
218 SBBreakpointLocation::GetThreadName () const
222 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
223 return m_opaque_sp->GetThreadName();
229 SBBreakpointLocation::SetQueueName (const char *queue_name)
233 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
234 m_opaque_sp->SetQueueName (queue_name);
239 SBBreakpointLocation::GetQueueName () const
243 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
244 m_opaque_sp->GetQueueName ();
250 SBBreakpointLocation::IsResolved ()
254 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
255 return m_opaque_sp->IsResolved();
261 SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
263 // Uninstall the callbacks?
264 m_opaque_sp = break_loc_sp;
268 SBBreakpointLocation::GetDescription (SBStream &description, DescriptionLevel level)
270 Stream &strm = description.ref();
274 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
275 m_opaque_sp->GetDescription (&strm, level);
279 strm.PutCString ("No value");
285 SBBreakpointLocation::GetID ()
289 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
290 return m_opaque_sp->GetID ();
293 return LLDB_INVALID_BREAK_ID;
297 SBBreakpointLocation::GetBreakpoint ()
299 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
302 // log->Printf ("SBBreakpointLocation::GetBreakpoint ()");
307 Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
308 *sb_bp = m_opaque_sp->GetBreakpoint ().shared_from_this();
314 sb_bp.GetDescription (sstr);
315 log->Printf ("SBBreakpointLocation(%p)::GetBreakpoint () => SBBreakpoint(%p) %s",
316 m_opaque_sp.get(), sb_bp.get(), sstr.GetData());