blob: cb936241efa30844f97d64d81d1fdd327847fe2f [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
Chris Lattner24943d22010-06-08 16:52:24 +000028SBBreakpointLocation::SBBreakpointLocation ()
29{
30}
31
32SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000033 m_opaque_sp (break_loc_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000034{
Caroline Tice61ba7ec2010-10-26 23:49:36 +000035 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
Caroline Tice7826c882010-10-26 03:11:13 +000036
37 if (log)
38 {
39 SBStream sstr;
40 GetDescription (lldb::eDescriptionLevelBrief, sstr);
Caroline Tice61ba7ec2010-10-26 23:49:36 +000041 log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp"
42 "=%p) => this.sp = %p (%s)", break_loc_sp.get(), m_opaque_sp.get(), sstr.GetData());
Caroline Tice7826c882010-10-26 03:11:13 +000043 }
Chris Lattner24943d22010-06-08 16:52:24 +000044}
45
46SBBreakpointLocation::~SBBreakpointLocation ()
47{
48}
49
50bool
51SBBreakpointLocation::IsValid() const
52{
Greg Clayton63094e02010-06-23 01:19:29 +000053 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000054}
55
56addr_t
57SBBreakpointLocation::GetLoadAddress ()
58{
59 addr_t ret_addr = LLDB_INVALID_ADDRESS;
60
Greg Clayton63094e02010-06-23 01:19:29 +000061 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000062 {
Greg Clayton63094e02010-06-23 01:19:29 +000063 ret_addr = m_opaque_sp->GetLoadAddress();
Chris Lattner24943d22010-06-08 16:52:24 +000064 }
65
66 return ret_addr;
67}
68
69void
70SBBreakpointLocation::SetEnabled (bool enabled)
71{
Greg Clayton63094e02010-06-23 01:19:29 +000072 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000073 {
Greg Clayton63094e02010-06-23 01:19:29 +000074 m_opaque_sp->SetEnabled (enabled);
Chris Lattner24943d22010-06-08 16:52:24 +000075 }
76}
77
78bool
79SBBreakpointLocation::IsEnabled ()
80{
Greg Clayton63094e02010-06-23 01:19:29 +000081 if (m_opaque_sp)
82 return m_opaque_sp->IsEnabled();
Chris Lattner24943d22010-06-08 16:52:24 +000083 else
84 return false;
85}
86
Greg Clayton54e7afa2010-07-09 20:39:50 +000087uint32_t
Chris Lattner24943d22010-06-08 16:52:24 +000088SBBreakpointLocation::GetIgnoreCount ()
89{
Greg Clayton63094e02010-06-23 01:19:29 +000090 if (m_opaque_sp)
91 return m_opaque_sp->GetIgnoreCount();
Chris Lattner24943d22010-06-08 16:52:24 +000092 else
93 return 0;
94}
95
96void
Greg Clayton54e7afa2010-07-09 20:39:50 +000097SBBreakpointLocation::SetIgnoreCount (uint32_t n)
Chris Lattner24943d22010-06-08 16:52:24 +000098{
Greg Clayton63094e02010-06-23 01:19:29 +000099 if (m_opaque_sp)
100 m_opaque_sp->SetIgnoreCount (n);
Chris Lattner24943d22010-06-08 16:52:24 +0000101}
102
103void
Jim Inghame3740832010-10-22 01:15:49 +0000104SBBreakpointLocation::SetCondition (const char *condition)
105{
106 m_opaque_sp->SetCondition (condition);
107}
108
109const char *
110SBBreakpointLocation::GetCondition ()
111{
112 return m_opaque_sp->GetConditionText ();
113}
114
115void
Chris Lattner24943d22010-06-08 16:52:24 +0000116SBBreakpointLocation::SetThreadID (tid_t thread_id)
117{
Greg Clayton63094e02010-06-23 01:19:29 +0000118 if (m_opaque_sp)
119 m_opaque_sp->SetThreadID (thread_id);
Chris Lattner24943d22010-06-08 16:52:24 +0000120}
121
122tid_t
123SBBreakpointLocation::GetThreadID ()
124{
125 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
Greg Clayton63094e02010-06-23 01:19:29 +0000126 if (m_opaque_sp)
127 sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
Chris Lattner24943d22010-06-08 16:52:24 +0000128 return sb_thread_id;
129}
130
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000131void
132SBBreakpointLocation::SetThreadIndex (uint32_t index)
133{
Greg Clayton63094e02010-06-23 01:19:29 +0000134 if (m_opaque_sp)
135 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000136}
137
138uint32_t
139SBBreakpointLocation::GetThreadIndex() const
140{
Greg Clayton63094e02010-06-23 01:19:29 +0000141 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000142 {
Greg Clayton63094e02010-06-23 01:19:29 +0000143 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000144 if (thread_spec == NULL)
145 return 0;
146 else
147 return thread_spec->GetIndex();
148 }
149 return 0;
150}
151
152
153void
154SBBreakpointLocation::SetThreadName (const char *thread_name)
155{
Greg Clayton63094e02010-06-23 01:19:29 +0000156 if (m_opaque_sp)
157 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000158}
159
160const char *
161SBBreakpointLocation::GetThreadName () const
162{
Greg Clayton63094e02010-06-23 01:19:29 +0000163 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000164 {
Greg Clayton63094e02010-06-23 01:19:29 +0000165 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000166 if (thread_spec == NULL)
167 return NULL;
168 else
169 return thread_spec->GetName();
170 }
171 return NULL;
172}
173
174void
175SBBreakpointLocation::SetQueueName (const char *queue_name)
176{
Greg Clayton63094e02010-06-23 01:19:29 +0000177 if (m_opaque_sp)
178 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000179}
180
181const char *
182SBBreakpointLocation::GetQueueName () const
183{
Greg Clayton63094e02010-06-23 01:19:29 +0000184 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000185 {
Greg Clayton63094e02010-06-23 01:19:29 +0000186 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000187 if (thread_spec == NULL)
188 return NULL;
189 else
190 return thread_spec->GetQueueName();
191 }
192 return NULL;
193}
194
Chris Lattner24943d22010-06-08 16:52:24 +0000195bool
196SBBreakpointLocation::IsResolved ()
197{
Greg Clayton63094e02010-06-23 01:19:29 +0000198 if (m_opaque_sp)
199 return m_opaque_sp->IsResolved();
Chris Lattner24943d22010-06-08 16:52:24 +0000200 else
201 return false;
202}
203
204void
205SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
206{
Greg Clayton63094e02010-06-23 01:19:29 +0000207 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000208 {
209 // Uninstall the callbacks?
210 }
Greg Clayton63094e02010-06-23 01:19:29 +0000211 m_opaque_sp = break_loc_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000212}
213
Caroline Tice98f930f2010-09-20 05:20:02 +0000214bool
Caroline Tice7826c882010-10-26 03:11:13 +0000215SBBreakpointLocation::GetDescription (DescriptionLevel level, SBStream &description)
Chris Lattner24943d22010-06-08 16:52:24 +0000216{
Greg Clayton63094e02010-06-23 01:19:29 +0000217 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000218 {
Caroline Ticee49ec182010-09-22 23:01:29 +0000219 description.ref();
Caroline Tice98f930f2010-09-20 05:20:02 +0000220 m_opaque_sp->GetDescription (description.get(), level);
221 description.get()->EOL();
Chris Lattner24943d22010-06-08 16:52:24 +0000222 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000223 else
224 description.Printf ("No value");
225
226 return true;
227}
228
Chris Lattner24943d22010-06-08 16:52:24 +0000229SBBreakpoint
230SBBreakpointLocation::GetBreakpoint ()
231{
Caroline Tice7826c882010-10-26 03:11:13 +0000232 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
233
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000234 //if (log)
235 // log->Printf ("SBBreakpointLocation::GetBreakpoint ()");
Caroline Tice7826c882010-10-26 03:11:13 +0000236
Chris Lattner24943d22010-06-08 16:52:24 +0000237 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000238 if (m_opaque_sp)
239 *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
Caroline Tice7826c882010-10-26 03:11:13 +0000240
241 if (log)
242 {
243 SBStream sstr;
244 sb_bp.GetDescription (sstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000245 log->Printf ("SBBreakpointLocation(%p)::GetBreakpoint () => SBBreakpoint(%p) %s",
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000246 m_opaque_sp.get(), sb_bp.get(), sstr.GetData());
Caroline Tice7826c882010-10-26 03:11:13 +0000247 }
Chris Lattner24943d22010-06-08 16:52:24 +0000248 return sb_bp;
249}
250