blob: e2240dfcd443502db3532ced8760edded7d8e49e [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- SBBreakpointLocation.cpp --------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/API/SBBreakpointLocation.h"
11#include "lldb/API/SBDefines.h"
12#include "lldb/API/SBDebugger.h"
Caroline Tice98f930f2010-09-20 05:20:02 +000013#include "lldb/API/SBStream.h"
Chris Lattner24943d22010-06-08 16:52:24 +000014
15#include "lldb/lldb-types.h"
16#include "lldb/lldb-defines.h"
17#include "lldb/Breakpoint/BreakpointLocation.h"
Jim Ingham3c7b5b92010-06-16 02:00:15 +000018#include "lldb/Target/ThreadSpec.h"
Caroline Tice7826c882010-10-26 03:11:13 +000019#include "lldb/Core/Log.h"
Chris Lattner24943d22010-06-08 16:52:24 +000020#include "lldb/Core/Stream.h"
21#include "lldb/Core/StreamFile.h"
Jim Ingham8e5e38f2010-06-18 01:47:08 +000022#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000023
24using namespace lldb;
25using namespace lldb_private;
26
27
Greg Clayton538eb822010-11-05 23:17:00 +000028SBBreakpointLocation::SBBreakpointLocation () :
29 m_opaque_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +000030{
31}
32
33SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000034 m_opaque_sp (break_loc_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000035{
Greg Claytone005f2c2010-11-06 01:53:30 +000036 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +000037
38 if (log)
39 {
40 SBStream sstr;
41 GetDescription (lldb::eDescriptionLevelBrief, sstr);
Caroline Tice61ba7ec2010-10-26 23:49:36 +000042 log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp"
43 "=%p) => this.sp = %p (%s)", break_loc_sp.get(), m_opaque_sp.get(), sstr.GetData());
Caroline Tice7826c882010-10-26 03:11:13 +000044 }
Chris Lattner24943d22010-06-08 16:52:24 +000045}
46
Greg Clayton538eb822010-11-05 23:17:00 +000047SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) :
48 m_opaque_sp (rhs.m_opaque_sp)
49{
50}
51
52const SBBreakpointLocation &
53SBBreakpointLocation::operator = (const SBBreakpointLocation &rhs)
54{
55 if (this != &rhs)
56 m_opaque_sp = rhs.m_opaque_sp;
57 return *this;
58}
59
60
Chris Lattner24943d22010-06-08 16:52:24 +000061SBBreakpointLocation::~SBBreakpointLocation ()
62{
63}
64
65bool
66SBBreakpointLocation::IsValid() const
67{
Greg Clayton63094e02010-06-23 01:19:29 +000068 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000069}
70
71addr_t
72SBBreakpointLocation::GetLoadAddress ()
73{
74 addr_t ret_addr = LLDB_INVALID_ADDRESS;
75
Greg Clayton63094e02010-06-23 01:19:29 +000076 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000077 {
Greg Clayton63094e02010-06-23 01:19:29 +000078 ret_addr = m_opaque_sp->GetLoadAddress();
Chris Lattner24943d22010-06-08 16:52:24 +000079 }
80
81 return ret_addr;
82}
83
84void
85SBBreakpointLocation::SetEnabled (bool enabled)
86{
Greg Clayton63094e02010-06-23 01:19:29 +000087 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000088 {
Greg Clayton63094e02010-06-23 01:19:29 +000089 m_opaque_sp->SetEnabled (enabled);
Chris Lattner24943d22010-06-08 16:52:24 +000090 }
91}
92
93bool
94SBBreakpointLocation::IsEnabled ()
95{
Greg Clayton63094e02010-06-23 01:19:29 +000096 if (m_opaque_sp)
97 return m_opaque_sp->IsEnabled();
Chris Lattner24943d22010-06-08 16:52:24 +000098 else
99 return false;
100}
101
Greg Clayton54e7afa2010-07-09 20:39:50 +0000102uint32_t
Chris Lattner24943d22010-06-08 16:52:24 +0000103SBBreakpointLocation::GetIgnoreCount ()
104{
Greg Clayton63094e02010-06-23 01:19:29 +0000105 if (m_opaque_sp)
106 return m_opaque_sp->GetIgnoreCount();
Chris Lattner24943d22010-06-08 16:52:24 +0000107 else
108 return 0;
109}
110
111void
Greg Clayton54e7afa2010-07-09 20:39:50 +0000112SBBreakpointLocation::SetIgnoreCount (uint32_t n)
Chris Lattner24943d22010-06-08 16:52:24 +0000113{
Greg Clayton63094e02010-06-23 01:19:29 +0000114 if (m_opaque_sp)
115 m_opaque_sp->SetIgnoreCount (n);
Chris Lattner24943d22010-06-08 16:52:24 +0000116}
117
118void
Jim Inghame3740832010-10-22 01:15:49 +0000119SBBreakpointLocation::SetCondition (const char *condition)
120{
121 m_opaque_sp->SetCondition (condition);
122}
123
124const char *
125SBBreakpointLocation::GetCondition ()
126{
127 return m_opaque_sp->GetConditionText ();
128}
129
130void
Chris Lattner24943d22010-06-08 16:52:24 +0000131SBBreakpointLocation::SetThreadID (tid_t thread_id)
132{
Greg Clayton63094e02010-06-23 01:19:29 +0000133 if (m_opaque_sp)
134 m_opaque_sp->SetThreadID (thread_id);
Chris Lattner24943d22010-06-08 16:52:24 +0000135}
136
137tid_t
138SBBreakpointLocation::GetThreadID ()
139{
140 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
Greg Clayton63094e02010-06-23 01:19:29 +0000141 if (m_opaque_sp)
142 sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
Chris Lattner24943d22010-06-08 16:52:24 +0000143 return sb_thread_id;
144}
145
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000146void
147SBBreakpointLocation::SetThreadIndex (uint32_t index)
148{
Greg Clayton63094e02010-06-23 01:19:29 +0000149 if (m_opaque_sp)
150 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000151}
152
153uint32_t
154SBBreakpointLocation::GetThreadIndex() const
155{
Greg Clayton63094e02010-06-23 01:19:29 +0000156 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000157 {
Greg Clayton63094e02010-06-23 01:19:29 +0000158 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000159 if (thread_spec == NULL)
160 return 0;
161 else
162 return thread_spec->GetIndex();
163 }
164 return 0;
165}
166
167
168void
169SBBreakpointLocation::SetThreadName (const char *thread_name)
170{
Greg Clayton63094e02010-06-23 01:19:29 +0000171 if (m_opaque_sp)
172 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000173}
174
175const char *
176SBBreakpointLocation::GetThreadName () const
177{
Greg Clayton63094e02010-06-23 01:19:29 +0000178 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000179 {
Greg Clayton63094e02010-06-23 01:19:29 +0000180 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000181 if (thread_spec == NULL)
182 return NULL;
183 else
184 return thread_spec->GetName();
185 }
186 return NULL;
187}
188
189void
190SBBreakpointLocation::SetQueueName (const char *queue_name)
191{
Greg Clayton63094e02010-06-23 01:19:29 +0000192 if (m_opaque_sp)
193 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000194}
195
196const char *
197SBBreakpointLocation::GetQueueName () const
198{
Greg Clayton63094e02010-06-23 01:19:29 +0000199 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000200 {
Greg Clayton63094e02010-06-23 01:19:29 +0000201 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000202 if (thread_spec == NULL)
203 return NULL;
204 else
205 return thread_spec->GetQueueName();
206 }
207 return NULL;
208}
209
Chris Lattner24943d22010-06-08 16:52:24 +0000210bool
211SBBreakpointLocation::IsResolved ()
212{
Greg Clayton63094e02010-06-23 01:19:29 +0000213 if (m_opaque_sp)
214 return m_opaque_sp->IsResolved();
Chris Lattner24943d22010-06-08 16:52:24 +0000215 else
216 return false;
217}
218
219void
220SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
221{
Greg Clayton63094e02010-06-23 01:19:29 +0000222 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000223 {
224 // Uninstall the callbacks?
225 }
Greg Clayton63094e02010-06-23 01:19:29 +0000226 m_opaque_sp = break_loc_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000227}
228
Caroline Tice98f930f2010-09-20 05:20:02 +0000229bool
Caroline Tice7826c882010-10-26 03:11:13 +0000230SBBreakpointLocation::GetDescription (DescriptionLevel level, SBStream &description)
Chris Lattner24943d22010-06-08 16:52:24 +0000231{
Greg Clayton63094e02010-06-23 01:19:29 +0000232 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000233 {
Caroline Ticee49ec182010-09-22 23:01:29 +0000234 description.ref();
Caroline Tice98f930f2010-09-20 05:20:02 +0000235 m_opaque_sp->GetDescription (description.get(), level);
236 description.get()->EOL();
Chris Lattner24943d22010-06-08 16:52:24 +0000237 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000238 else
239 description.Printf ("No value");
240
241 return true;
242}
243
Chris Lattner24943d22010-06-08 16:52:24 +0000244SBBreakpoint
245SBBreakpointLocation::GetBreakpoint ()
246{
Greg Claytone005f2c2010-11-06 01:53:30 +0000247 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000248
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000249 //if (log)
250 // log->Printf ("SBBreakpointLocation::GetBreakpoint ()");
Caroline Tice7826c882010-10-26 03:11:13 +0000251
Chris Lattner24943d22010-06-08 16:52:24 +0000252 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000253 if (m_opaque_sp)
254 *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
Caroline Tice7826c882010-10-26 03:11:13 +0000255
256 if (log)
257 {
258 SBStream sstr;
259 sb_bp.GetDescription (sstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000260 log->Printf ("SBBreakpointLocation(%p)::GetBreakpoint () => SBBreakpoint(%p) %s",
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000261 m_opaque_sp.get(), sb_bp.get(), sstr.GetData());
Caroline Tice7826c882010-10-26 03:11:13 +0000262 }
Chris Lattner24943d22010-06-08 16:52:24 +0000263 return sb_bp;
264}
265