blob: 45c153b62eac7edb2333cb00caed300931e07463 [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
Caroline Tice98f930f2010-09-20 05:20:02 +000010// In order to guarantee correct working with Python, Python.h *MUST* be
11// the *FIRST* header file included:
12
13#include <Python.h>
14
Chris Lattner24943d22010-06-08 16:52:24 +000015#include "lldb/API/SBBreakpointLocation.h"
16#include "lldb/API/SBDefines.h"
17#include "lldb/API/SBDebugger.h"
Caroline Tice98f930f2010-09-20 05:20:02 +000018#include "lldb/API/SBStream.h"
Chris Lattner24943d22010-06-08 16:52:24 +000019
20#include "lldb/lldb-types.h"
21#include "lldb/lldb-defines.h"
22#include "lldb/Breakpoint/BreakpointLocation.h"
Jim Ingham3c7b5b92010-06-16 02:00:15 +000023#include "lldb/Target/ThreadSpec.h"
Caroline Tice7826c882010-10-26 03:11:13 +000024#include "lldb/Core/Log.h"
Chris Lattner24943d22010-06-08 16:52:24 +000025#include "lldb/Core/Stream.h"
26#include "lldb/Core/StreamFile.h"
Jim Ingham8e5e38f2010-06-18 01:47:08 +000027#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000028
29using namespace lldb;
30using namespace lldb_private;
31
32
Chris Lattner24943d22010-06-08 16:52:24 +000033SBBreakpointLocation::SBBreakpointLocation ()
34{
35}
36
37SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000038 m_opaque_sp (break_loc_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000039{
Caroline Tice61ba7ec2010-10-26 23:49:36 +000040 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
Caroline Tice7826c882010-10-26 03:11:13 +000041
42 if (log)
43 {
44 SBStream sstr;
45 GetDescription (lldb::eDescriptionLevelBrief, sstr);
Caroline Tice61ba7ec2010-10-26 23:49:36 +000046 log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp"
47 "=%p) => this.sp = %p (%s)", break_loc_sp.get(), m_opaque_sp.get(), sstr.GetData());
Caroline Tice7826c882010-10-26 03:11:13 +000048 }
Chris Lattner24943d22010-06-08 16:52:24 +000049}
50
51SBBreakpointLocation::~SBBreakpointLocation ()
52{
53}
54
55bool
56SBBreakpointLocation::IsValid() const
57{
Greg Clayton63094e02010-06-23 01:19:29 +000058 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000059}
60
61addr_t
62SBBreakpointLocation::GetLoadAddress ()
63{
64 addr_t ret_addr = LLDB_INVALID_ADDRESS;
65
Greg Clayton63094e02010-06-23 01:19:29 +000066 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000067 {
Greg Clayton63094e02010-06-23 01:19:29 +000068 ret_addr = m_opaque_sp->GetLoadAddress();
Chris Lattner24943d22010-06-08 16:52:24 +000069 }
70
71 return ret_addr;
72}
73
74void
75SBBreakpointLocation::SetEnabled (bool enabled)
76{
Greg Clayton63094e02010-06-23 01:19:29 +000077 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000078 {
Greg Clayton63094e02010-06-23 01:19:29 +000079 m_opaque_sp->SetEnabled (enabled);
Chris Lattner24943d22010-06-08 16:52:24 +000080 }
81}
82
83bool
84SBBreakpointLocation::IsEnabled ()
85{
Greg Clayton63094e02010-06-23 01:19:29 +000086 if (m_opaque_sp)
87 return m_opaque_sp->IsEnabled();
Chris Lattner24943d22010-06-08 16:52:24 +000088 else
89 return false;
90}
91
Greg Clayton54e7afa2010-07-09 20:39:50 +000092uint32_t
Chris Lattner24943d22010-06-08 16:52:24 +000093SBBreakpointLocation::GetIgnoreCount ()
94{
Greg Clayton63094e02010-06-23 01:19:29 +000095 if (m_opaque_sp)
96 return m_opaque_sp->GetIgnoreCount();
Chris Lattner24943d22010-06-08 16:52:24 +000097 else
98 return 0;
99}
100
101void
Greg Clayton54e7afa2010-07-09 20:39:50 +0000102SBBreakpointLocation::SetIgnoreCount (uint32_t n)
Chris Lattner24943d22010-06-08 16:52:24 +0000103{
Greg Clayton63094e02010-06-23 01:19:29 +0000104 if (m_opaque_sp)
105 m_opaque_sp->SetIgnoreCount (n);
Chris Lattner24943d22010-06-08 16:52:24 +0000106}
107
108void
Jim Inghame3740832010-10-22 01:15:49 +0000109SBBreakpointLocation::SetCondition (const char *condition)
110{
111 m_opaque_sp->SetCondition (condition);
112}
113
114const char *
115SBBreakpointLocation::GetCondition ()
116{
117 return m_opaque_sp->GetConditionText ();
118}
119
120void
Chris Lattner24943d22010-06-08 16:52:24 +0000121SBBreakpointLocation::SetThreadID (tid_t thread_id)
122{
Greg Clayton63094e02010-06-23 01:19:29 +0000123 if (m_opaque_sp)
124 m_opaque_sp->SetThreadID (thread_id);
Chris Lattner24943d22010-06-08 16:52:24 +0000125}
126
127tid_t
128SBBreakpointLocation::GetThreadID ()
129{
130 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
Greg Clayton63094e02010-06-23 01:19:29 +0000131 if (m_opaque_sp)
132 sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
Chris Lattner24943d22010-06-08 16:52:24 +0000133 return sb_thread_id;
134}
135
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000136void
137SBBreakpointLocation::SetThreadIndex (uint32_t index)
138{
Greg Clayton63094e02010-06-23 01:19:29 +0000139 if (m_opaque_sp)
140 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000141}
142
143uint32_t
144SBBreakpointLocation::GetThreadIndex() const
145{
Greg Clayton63094e02010-06-23 01:19:29 +0000146 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000147 {
Greg Clayton63094e02010-06-23 01:19:29 +0000148 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000149 if (thread_spec == NULL)
150 return 0;
151 else
152 return thread_spec->GetIndex();
153 }
154 return 0;
155}
156
157
158void
159SBBreakpointLocation::SetThreadName (const char *thread_name)
160{
Greg Clayton63094e02010-06-23 01:19:29 +0000161 if (m_opaque_sp)
162 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000163}
164
165const char *
166SBBreakpointLocation::GetThreadName () const
167{
Greg Clayton63094e02010-06-23 01:19:29 +0000168 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000169 {
Greg Clayton63094e02010-06-23 01:19:29 +0000170 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000171 if (thread_spec == NULL)
172 return NULL;
173 else
174 return thread_spec->GetName();
175 }
176 return NULL;
177}
178
179void
180SBBreakpointLocation::SetQueueName (const char *queue_name)
181{
Greg Clayton63094e02010-06-23 01:19:29 +0000182 if (m_opaque_sp)
183 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000184}
185
186const char *
187SBBreakpointLocation::GetQueueName () const
188{
Greg Clayton63094e02010-06-23 01:19:29 +0000189 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000190 {
Greg Clayton63094e02010-06-23 01:19:29 +0000191 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000192 if (thread_spec == NULL)
193 return NULL;
194 else
195 return thread_spec->GetQueueName();
196 }
197 return NULL;
198}
199
Chris Lattner24943d22010-06-08 16:52:24 +0000200bool
201SBBreakpointLocation::IsResolved ()
202{
Greg Clayton63094e02010-06-23 01:19:29 +0000203 if (m_opaque_sp)
204 return m_opaque_sp->IsResolved();
Chris Lattner24943d22010-06-08 16:52:24 +0000205 else
206 return false;
207}
208
209void
210SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
211{
Greg Clayton63094e02010-06-23 01:19:29 +0000212 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000213 {
214 // Uninstall the callbacks?
215 }
Greg Clayton63094e02010-06-23 01:19:29 +0000216 m_opaque_sp = break_loc_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000217}
218
Caroline Tice98f930f2010-09-20 05:20:02 +0000219bool
Caroline Tice7826c882010-10-26 03:11:13 +0000220SBBreakpointLocation::GetDescription (DescriptionLevel level, SBStream &description)
Chris Lattner24943d22010-06-08 16:52:24 +0000221{
Greg Clayton63094e02010-06-23 01:19:29 +0000222 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000223 {
Caroline Ticee49ec182010-09-22 23:01:29 +0000224 description.ref();
Caroline Tice98f930f2010-09-20 05:20:02 +0000225 m_opaque_sp->GetDescription (description.get(), level);
226 description.get()->EOL();
Chris Lattner24943d22010-06-08 16:52:24 +0000227 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000228 else
229 description.Printf ("No value");
230
231 return true;
232}
233
Chris Lattner24943d22010-06-08 16:52:24 +0000234SBBreakpoint
235SBBreakpointLocation::GetBreakpoint ()
236{
Caroline Tice7826c882010-10-26 03:11:13 +0000237 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
238
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000239 //if (log)
240 // log->Printf ("SBBreakpointLocation::GetBreakpoint ()");
Caroline Tice7826c882010-10-26 03:11:13 +0000241
Chris Lattner24943d22010-06-08 16:52:24 +0000242 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000243 if (m_opaque_sp)
244 *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
Caroline Tice7826c882010-10-26 03:11:13 +0000245
246 if (log)
247 {
248 SBStream sstr;
249 sb_bp.GetDescription (sstr);
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000250 log->Printf ("SBBreakpointLocation::GetBreakpoint (this.sp=%p) => SBBreakpoint: m_opaque_sp=%p, '%s'",
251 m_opaque_sp.get(), sb_bp.get(), sstr.GetData());
Caroline Tice7826c882010-10-26 03:11:13 +0000252 }
Chris Lattner24943d22010-06-08 16:52:24 +0000253 return sb_bp;
254}
255