blob: f7e059ba9677e83cebaf5330459a2dcfd0b98052 [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
102SBBreakpointLocation::SetThreadID (tid_t thread_id)
103{
Greg Clayton63094e02010-06-23 01:19:29 +0000104 if (m_opaque_sp)
105 m_opaque_sp->SetThreadID (thread_id);
Chris Lattner24943d22010-06-08 16:52:24 +0000106}
107
108tid_t
109SBBreakpointLocation::GetThreadID ()
110{
111 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
Greg Clayton63094e02010-06-23 01:19:29 +0000112 if (m_opaque_sp)
113 sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
Chris Lattner24943d22010-06-08 16:52:24 +0000114 return sb_thread_id;
115}
116
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000117void
118SBBreakpointLocation::SetThreadIndex (uint32_t index)
119{
Greg Clayton63094e02010-06-23 01:19:29 +0000120 if (m_opaque_sp)
121 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000122}
123
124uint32_t
125SBBreakpointLocation::GetThreadIndex() const
126{
Greg Clayton63094e02010-06-23 01:19:29 +0000127 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000128 {
Greg Clayton63094e02010-06-23 01:19:29 +0000129 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000130 if (thread_spec == NULL)
131 return 0;
132 else
133 return thread_spec->GetIndex();
134 }
135 return 0;
136}
137
138
139void
140SBBreakpointLocation::SetThreadName (const char *thread_name)
141{
Greg Clayton63094e02010-06-23 01:19:29 +0000142 if (m_opaque_sp)
143 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000144}
145
146const char *
147SBBreakpointLocation::GetThreadName () const
148{
Greg Clayton63094e02010-06-23 01:19:29 +0000149 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000150 {
Greg Clayton63094e02010-06-23 01:19:29 +0000151 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000152 if (thread_spec == NULL)
153 return NULL;
154 else
155 return thread_spec->GetName();
156 }
157 return NULL;
158}
159
160void
161SBBreakpointLocation::SetQueueName (const char *queue_name)
162{
Greg Clayton63094e02010-06-23 01:19:29 +0000163 if (m_opaque_sp)
164 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000165}
166
167const char *
168SBBreakpointLocation::GetQueueName () const
169{
Greg Clayton63094e02010-06-23 01:19:29 +0000170 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000171 {
Greg Clayton63094e02010-06-23 01:19:29 +0000172 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000173 if (thread_spec == NULL)
174 return NULL;
175 else
176 return thread_spec->GetQueueName();
177 }
178 return NULL;
179}
180
Chris Lattner24943d22010-06-08 16:52:24 +0000181bool
182SBBreakpointLocation::IsResolved ()
183{
Greg Clayton63094e02010-06-23 01:19:29 +0000184 if (m_opaque_sp)
185 return m_opaque_sp->IsResolved();
Chris Lattner24943d22010-06-08 16:52:24 +0000186 else
187 return false;
188}
189
190void
191SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
192{
Greg Clayton63094e02010-06-23 01:19:29 +0000193 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000194 {
195 // Uninstall the callbacks?
196 }
Greg Clayton63094e02010-06-23 01:19:29 +0000197 m_opaque_sp = break_loc_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000198}
199
Caroline Tice98f930f2010-09-20 05:20:02 +0000200bool
201SBBreakpointLocation::GetDescription (const char *description_level, SBStream &description)
Chris Lattner24943d22010-06-08 16:52:24 +0000202{
Greg Clayton63094e02010-06-23 01:19:29 +0000203 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000204 {
205 DescriptionLevel level;
206 if (strcmp (description_level, "brief") == 0)
207 level = eDescriptionLevelBrief;
208 else if (strcmp (description_level, "full") == 0)
209 level = eDescriptionLevelFull;
210 else if (strcmp (description_level, "verbose") == 0)
211 level = eDescriptionLevelVerbose;
212 else
213 level = eDescriptionLevelBrief;
214
Caroline Tice98f930f2010-09-20 05:20:02 +0000215 m_opaque_sp->GetDescription (description.get(), level);
216 description.get()->EOL();
Chris Lattner24943d22010-06-08 16:52:24 +0000217 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000218 else
219 description.Printf ("No value");
220
221 return true;
222}
223
224PyObject *
225SBBreakpointLocation::__repr__ ()
226{
227 SBStream description;
228 description.ref();
229 GetDescription ("full", description);
230 return PyString_FromString (description.GetData());
Chris Lattner24943d22010-06-08 16:52:24 +0000231}
232
233SBBreakpoint
234SBBreakpointLocation::GetBreakpoint ()
235{
236 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000237 if (m_opaque_sp)
238 *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
Chris Lattner24943d22010-06-08 16:52:24 +0000239 return sb_bp;
240}
241