blob: a7decda4895bee2132b726866d125fd0fe4d5c5a [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{
Caroline Tice7826c882010-10-26 03:11:13 +000035 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE);
36
37 if (log)
38 log->Printf ("SBBreakpointLocation::SBBreakpointLocation () ==> this = %p", this);
Chris Lattner24943d22010-06-08 16:52:24 +000039}
40
41SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000042 m_opaque_sp (break_loc_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000043{
Caroline Tice7826c882010-10-26 03:11:13 +000044 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE);
45
46 if (log)
47 {
48 SBStream sstr;
49 GetDescription (lldb::eDescriptionLevelBrief, sstr);
50 log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp) "
51 "break_loc_sp.get() = %p ==> this = %p (%s)", break_loc_sp.get(), this, sstr.GetData());
52 }
Chris Lattner24943d22010-06-08 16:52:24 +000053}
54
55SBBreakpointLocation::~SBBreakpointLocation ()
56{
57}
58
59bool
60SBBreakpointLocation::IsValid() const
61{
Greg Clayton63094e02010-06-23 01:19:29 +000062 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000063}
64
65addr_t
66SBBreakpointLocation::GetLoadAddress ()
67{
68 addr_t ret_addr = LLDB_INVALID_ADDRESS;
69
Greg Clayton63094e02010-06-23 01:19:29 +000070 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000071 {
Greg Clayton63094e02010-06-23 01:19:29 +000072 ret_addr = m_opaque_sp->GetLoadAddress();
Chris Lattner24943d22010-06-08 16:52:24 +000073 }
74
75 return ret_addr;
76}
77
78void
79SBBreakpointLocation::SetEnabled (bool enabled)
80{
Greg Clayton63094e02010-06-23 01:19:29 +000081 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000082 {
Greg Clayton63094e02010-06-23 01:19:29 +000083 m_opaque_sp->SetEnabled (enabled);
Chris Lattner24943d22010-06-08 16:52:24 +000084 }
85}
86
87bool
88SBBreakpointLocation::IsEnabled ()
89{
Greg Clayton63094e02010-06-23 01:19:29 +000090 if (m_opaque_sp)
91 return m_opaque_sp->IsEnabled();
Chris Lattner24943d22010-06-08 16:52:24 +000092 else
93 return false;
94}
95
Greg Clayton54e7afa2010-07-09 20:39:50 +000096uint32_t
Chris Lattner24943d22010-06-08 16:52:24 +000097SBBreakpointLocation::GetIgnoreCount ()
98{
Greg Clayton63094e02010-06-23 01:19:29 +000099 if (m_opaque_sp)
100 return m_opaque_sp->GetIgnoreCount();
Chris Lattner24943d22010-06-08 16:52:24 +0000101 else
102 return 0;
103}
104
105void
Greg Clayton54e7afa2010-07-09 20:39:50 +0000106SBBreakpointLocation::SetIgnoreCount (uint32_t n)
Chris Lattner24943d22010-06-08 16:52:24 +0000107{
Greg Clayton63094e02010-06-23 01:19:29 +0000108 if (m_opaque_sp)
109 m_opaque_sp->SetIgnoreCount (n);
Chris Lattner24943d22010-06-08 16:52:24 +0000110}
111
112void
Jim Inghame3740832010-10-22 01:15:49 +0000113SBBreakpointLocation::SetCondition (const char *condition)
114{
115 m_opaque_sp->SetCondition (condition);
116}
117
118const char *
119SBBreakpointLocation::GetCondition ()
120{
121 return m_opaque_sp->GetConditionText ();
122}
123
124void
Chris Lattner24943d22010-06-08 16:52:24 +0000125SBBreakpointLocation::SetThreadID (tid_t thread_id)
126{
Greg Clayton63094e02010-06-23 01:19:29 +0000127 if (m_opaque_sp)
128 m_opaque_sp->SetThreadID (thread_id);
Chris Lattner24943d22010-06-08 16:52:24 +0000129}
130
131tid_t
132SBBreakpointLocation::GetThreadID ()
133{
134 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
Greg Clayton63094e02010-06-23 01:19:29 +0000135 if (m_opaque_sp)
136 sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
Chris Lattner24943d22010-06-08 16:52:24 +0000137 return sb_thread_id;
138}
139
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000140void
141SBBreakpointLocation::SetThreadIndex (uint32_t index)
142{
Greg Clayton63094e02010-06-23 01:19:29 +0000143 if (m_opaque_sp)
144 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000145}
146
147uint32_t
148SBBreakpointLocation::GetThreadIndex() const
149{
Greg Clayton63094e02010-06-23 01:19:29 +0000150 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000151 {
Greg Clayton63094e02010-06-23 01:19:29 +0000152 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000153 if (thread_spec == NULL)
154 return 0;
155 else
156 return thread_spec->GetIndex();
157 }
158 return 0;
159}
160
161
162void
163SBBreakpointLocation::SetThreadName (const char *thread_name)
164{
Greg Clayton63094e02010-06-23 01:19:29 +0000165 if (m_opaque_sp)
166 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000167}
168
169const char *
170SBBreakpointLocation::GetThreadName () const
171{
Greg Clayton63094e02010-06-23 01:19:29 +0000172 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000173 {
Greg Clayton63094e02010-06-23 01:19:29 +0000174 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000175 if (thread_spec == NULL)
176 return NULL;
177 else
178 return thread_spec->GetName();
179 }
180 return NULL;
181}
182
183void
184SBBreakpointLocation::SetQueueName (const char *queue_name)
185{
Greg Clayton63094e02010-06-23 01:19:29 +0000186 if (m_opaque_sp)
187 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000188}
189
190const char *
191SBBreakpointLocation::GetQueueName () const
192{
Greg Clayton63094e02010-06-23 01:19:29 +0000193 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000194 {
Greg Clayton63094e02010-06-23 01:19:29 +0000195 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000196 if (thread_spec == NULL)
197 return NULL;
198 else
199 return thread_spec->GetQueueName();
200 }
201 return NULL;
202}
203
Chris Lattner24943d22010-06-08 16:52:24 +0000204bool
205SBBreakpointLocation::IsResolved ()
206{
Greg Clayton63094e02010-06-23 01:19:29 +0000207 if (m_opaque_sp)
208 return m_opaque_sp->IsResolved();
Chris Lattner24943d22010-06-08 16:52:24 +0000209 else
210 return false;
211}
212
213void
214SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
215{
Greg Clayton63094e02010-06-23 01:19:29 +0000216 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000217 {
218 // Uninstall the callbacks?
219 }
Greg Clayton63094e02010-06-23 01:19:29 +0000220 m_opaque_sp = break_loc_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000221}
222
Caroline Tice98f930f2010-09-20 05:20:02 +0000223bool
Caroline Tice7826c882010-10-26 03:11:13 +0000224SBBreakpointLocation::GetDescription (DescriptionLevel level, SBStream &description)
Chris Lattner24943d22010-06-08 16:52:24 +0000225{
Greg Clayton63094e02010-06-23 01:19:29 +0000226 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000227 {
Caroline Ticee49ec182010-09-22 23:01:29 +0000228 description.ref();
Caroline Tice98f930f2010-09-20 05:20:02 +0000229 m_opaque_sp->GetDescription (description.get(), level);
230 description.get()->EOL();
Chris Lattner24943d22010-06-08 16:52:24 +0000231 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000232 else
233 description.Printf ("No value");
234
235 return true;
236}
237
Chris Lattner24943d22010-06-08 16:52:24 +0000238SBBreakpoint
239SBBreakpointLocation::GetBreakpoint ()
240{
Caroline Tice7826c882010-10-26 03:11:13 +0000241 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
242
243 if (log)
244 log->Printf ("SBBreakpointLocation::GetBreakpoint ()");
245
Chris Lattner24943d22010-06-08 16:52:24 +0000246 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000247 if (m_opaque_sp)
248 *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
Caroline Tice7826c882010-10-26 03:11:13 +0000249
250 if (log)
251 {
252 SBStream sstr;
253 sb_bp.GetDescription (sstr);
254 log->Printf ("SBBreakpointLocation::GetBreakpoint ==> %s", sstr.GetData());
255 }
Chris Lattner24943d22010-06-08 16:52:24 +0000256 return sb_bp;
257}
258