blob: b284f6a2341a44836b6d2af917276682130ba64a [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"
Chris Lattner24943d22010-06-08 16:52:24 +000024#include "lldb/Core/Stream.h"
25#include "lldb/Core/StreamFile.h"
Jim Ingham8e5e38f2010-06-18 01:47:08 +000026#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000027
28using namespace lldb;
29using namespace lldb_private;
30
31
32
33//class SBBreakpointLocation
34
35SBBreakpointLocation::SBBreakpointLocation ()
36{
37}
38
39SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000040 m_opaque_sp (break_loc_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000041{
42}
43
44SBBreakpointLocation::~SBBreakpointLocation ()
45{
46}
47
48bool
49SBBreakpointLocation::IsValid() const
50{
Greg Clayton63094e02010-06-23 01:19:29 +000051 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000052}
53
54addr_t
55SBBreakpointLocation::GetLoadAddress ()
56{
57 addr_t ret_addr = LLDB_INVALID_ADDRESS;
58
Greg Clayton63094e02010-06-23 01:19:29 +000059 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000060 {
Greg Clayton63094e02010-06-23 01:19:29 +000061 ret_addr = m_opaque_sp->GetLoadAddress();
Chris Lattner24943d22010-06-08 16:52:24 +000062 }
63
64 return ret_addr;
65}
66
67void
68SBBreakpointLocation::SetEnabled (bool enabled)
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 m_opaque_sp->SetEnabled (enabled);
Chris Lattner24943d22010-06-08 16:52:24 +000073 }
74}
75
76bool
77SBBreakpointLocation::IsEnabled ()
78{
Greg Clayton63094e02010-06-23 01:19:29 +000079 if (m_opaque_sp)
80 return m_opaque_sp->IsEnabled();
Chris Lattner24943d22010-06-08 16:52:24 +000081 else
82 return false;
83}
84
Greg Clayton54e7afa2010-07-09 20:39:50 +000085uint32_t
Chris Lattner24943d22010-06-08 16:52:24 +000086SBBreakpointLocation::GetIgnoreCount ()
87{
Greg Clayton63094e02010-06-23 01:19:29 +000088 if (m_opaque_sp)
89 return m_opaque_sp->GetIgnoreCount();
Chris Lattner24943d22010-06-08 16:52:24 +000090 else
91 return 0;
92}
93
94void
Greg Clayton54e7afa2010-07-09 20:39:50 +000095SBBreakpointLocation::SetIgnoreCount (uint32_t n)
Chris Lattner24943d22010-06-08 16:52:24 +000096{
Greg Clayton63094e02010-06-23 01:19:29 +000097 if (m_opaque_sp)
98 m_opaque_sp->SetIgnoreCount (n);
Chris Lattner24943d22010-06-08 16:52:24 +000099}
100
101void
Jim Inghame3740832010-10-22 01:15:49 +0000102SBBreakpointLocation::SetCondition (const char *condition)
103{
104 m_opaque_sp->SetCondition (condition);
105}
106
107const char *
108SBBreakpointLocation::GetCondition ()
109{
110 return m_opaque_sp->GetConditionText ();
111}
112
113void
Chris Lattner24943d22010-06-08 16:52:24 +0000114SBBreakpointLocation::SetThreadID (tid_t thread_id)
115{
Greg Clayton63094e02010-06-23 01:19:29 +0000116 if (m_opaque_sp)
117 m_opaque_sp->SetThreadID (thread_id);
Chris Lattner24943d22010-06-08 16:52:24 +0000118}
119
120tid_t
121SBBreakpointLocation::GetThreadID ()
122{
123 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
Greg Clayton63094e02010-06-23 01:19:29 +0000124 if (m_opaque_sp)
125 sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
Chris Lattner24943d22010-06-08 16:52:24 +0000126 return sb_thread_id;
127}
128
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000129void
130SBBreakpointLocation::SetThreadIndex (uint32_t index)
131{
Greg Clayton63094e02010-06-23 01:19:29 +0000132 if (m_opaque_sp)
133 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000134}
135
136uint32_t
137SBBreakpointLocation::GetThreadIndex() const
138{
Greg Clayton63094e02010-06-23 01:19:29 +0000139 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000140 {
Greg Clayton63094e02010-06-23 01:19:29 +0000141 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000142 if (thread_spec == NULL)
143 return 0;
144 else
145 return thread_spec->GetIndex();
146 }
147 return 0;
148}
149
150
151void
152SBBreakpointLocation::SetThreadName (const char *thread_name)
153{
Greg Clayton63094e02010-06-23 01:19:29 +0000154 if (m_opaque_sp)
155 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000156}
157
158const char *
159SBBreakpointLocation::GetThreadName () const
160{
Greg Clayton63094e02010-06-23 01:19:29 +0000161 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000162 {
Greg Clayton63094e02010-06-23 01:19:29 +0000163 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000164 if (thread_spec == NULL)
165 return NULL;
166 else
167 return thread_spec->GetName();
168 }
169 return NULL;
170}
171
172void
173SBBreakpointLocation::SetQueueName (const char *queue_name)
174{
Greg Clayton63094e02010-06-23 01:19:29 +0000175 if (m_opaque_sp)
176 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000177}
178
179const char *
180SBBreakpointLocation::GetQueueName () const
181{
Greg Clayton63094e02010-06-23 01:19:29 +0000182 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000183 {
Greg Clayton63094e02010-06-23 01:19:29 +0000184 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000185 if (thread_spec == NULL)
186 return NULL;
187 else
188 return thread_spec->GetQueueName();
189 }
190 return NULL;
191}
192
Chris Lattner24943d22010-06-08 16:52:24 +0000193bool
194SBBreakpointLocation::IsResolved ()
195{
Greg Clayton63094e02010-06-23 01:19:29 +0000196 if (m_opaque_sp)
197 return m_opaque_sp->IsResolved();
Chris Lattner24943d22010-06-08 16:52:24 +0000198 else
199 return false;
200}
201
202void
203SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
204{
Greg Clayton63094e02010-06-23 01:19:29 +0000205 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000206 {
207 // Uninstall the callbacks?
208 }
Greg Clayton63094e02010-06-23 01:19:29 +0000209 m_opaque_sp = break_loc_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000210}
211
Caroline Tice98f930f2010-09-20 05:20:02 +0000212bool
213SBBreakpointLocation::GetDescription (const char *description_level, SBStream &description)
Chris Lattner24943d22010-06-08 16:52:24 +0000214{
Greg Clayton63094e02010-06-23 01:19:29 +0000215 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000216 {
217 DescriptionLevel level;
218 if (strcmp (description_level, "brief") == 0)
219 level = eDescriptionLevelBrief;
220 else if (strcmp (description_level, "full") == 0)
221 level = eDescriptionLevelFull;
222 else if (strcmp (description_level, "verbose") == 0)
223 level = eDescriptionLevelVerbose;
224 else
225 level = eDescriptionLevelBrief;
226
Caroline Ticee49ec182010-09-22 23:01:29 +0000227 description.ref();
Caroline Tice98f930f2010-09-20 05:20:02 +0000228 m_opaque_sp->GetDescription (description.get(), level);
229 description.get()->EOL();
Chris Lattner24943d22010-06-08 16:52:24 +0000230 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000231 else
232 description.Printf ("No value");
233
234 return true;
235}
236
Chris Lattner24943d22010-06-08 16:52:24 +0000237SBBreakpoint
238SBBreakpointLocation::GetBreakpoint ()
239{
240 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000241 if (m_opaque_sp)
242 *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
Chris Lattner24943d22010-06-08 16:52:24 +0000243 return sb_bp;
244}
245