blob: f7e059ba9677e83cebaf5330459a2dcfd0b98052 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:241//===-- 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 Ticedde9cff2010-09-20 05:20:0210// 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 Lattner30fdc8d2010-06-08 16:52:2415#include "lldb/API/SBBreakpointLocation.h"
16#include "lldb/API/SBDefines.h"
17#include "lldb/API/SBDebugger.h"
Caroline Ticedde9cff2010-09-20 05:20:0218#include "lldb/API/SBStream.h"
Chris Lattner30fdc8d2010-06-08 16:52:2419
20#include "lldb/lldb-types.h"
21#include "lldb/lldb-defines.h"
22#include "lldb/Breakpoint/BreakpointLocation.h"
Jim Ingham1b54c882010-06-16 02:00:1523#include "lldb/Target/ThreadSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:2424#include "lldb/Core/Stream.h"
25#include "lldb/Core/StreamFile.h"
Jim Ingham62b02c62010-06-18 01:47:0826#include "lldb/Target/ThreadSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:2427
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 Clayton66111032010-06-23 01:19:2940 m_opaque_sp (break_loc_sp)
Chris Lattner30fdc8d2010-06-08 16:52:2441{
42}
43
44SBBreakpointLocation::~SBBreakpointLocation ()
45{
46}
47
48bool
49SBBreakpointLocation::IsValid() const
50{
Greg Clayton66111032010-06-23 01:19:2951 return m_opaque_sp.get() != NULL;
Chris Lattner30fdc8d2010-06-08 16:52:2452}
53
54addr_t
55SBBreakpointLocation::GetLoadAddress ()
56{
57 addr_t ret_addr = LLDB_INVALID_ADDRESS;
58
Greg Clayton66111032010-06-23 01:19:2959 if (m_opaque_sp)
Chris Lattner30fdc8d2010-06-08 16:52:2460 {
Greg Clayton66111032010-06-23 01:19:2961 ret_addr = m_opaque_sp->GetLoadAddress();
Chris Lattner30fdc8d2010-06-08 16:52:2462 }
63
64 return ret_addr;
65}
66
67void
68SBBreakpointLocation::SetEnabled (bool enabled)
69{
Greg Clayton66111032010-06-23 01:19:2970 if (m_opaque_sp)
Chris Lattner30fdc8d2010-06-08 16:52:2471 {
Greg Clayton66111032010-06-23 01:19:2972 m_opaque_sp->SetEnabled (enabled);
Chris Lattner30fdc8d2010-06-08 16:52:2473 }
74}
75
76bool
77SBBreakpointLocation::IsEnabled ()
78{
Greg Clayton66111032010-06-23 01:19:2979 if (m_opaque_sp)
80 return m_opaque_sp->IsEnabled();
Chris Lattner30fdc8d2010-06-08 16:52:2481 else
82 return false;
83}
84
Greg Claytonc982c762010-07-09 20:39:5085uint32_t
Chris Lattner30fdc8d2010-06-08 16:52:2486SBBreakpointLocation::GetIgnoreCount ()
87{
Greg Clayton66111032010-06-23 01:19:2988 if (m_opaque_sp)
89 return m_opaque_sp->GetIgnoreCount();
Chris Lattner30fdc8d2010-06-08 16:52:2490 else
91 return 0;
92}
93
94void
Greg Claytonc982c762010-07-09 20:39:5095SBBreakpointLocation::SetIgnoreCount (uint32_t n)
Chris Lattner30fdc8d2010-06-08 16:52:2496{
Greg Clayton66111032010-06-23 01:19:2997 if (m_opaque_sp)
98 m_opaque_sp->SetIgnoreCount (n);
Chris Lattner30fdc8d2010-06-08 16:52:2499}
100
101void
102SBBreakpointLocation::SetThreadID (tid_t thread_id)
103{
Greg Clayton66111032010-06-23 01:19:29104 if (m_opaque_sp)
105 m_opaque_sp->SetThreadID (thread_id);
Chris Lattner30fdc8d2010-06-08 16:52:24106}
107
108tid_t
109SBBreakpointLocation::GetThreadID ()
110{
111 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
Greg Clayton66111032010-06-23 01:19:29112 if (m_opaque_sp)
113 sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
Chris Lattner30fdc8d2010-06-08 16:52:24114 return sb_thread_id;
115}
116
Jim Ingham62b02c62010-06-18 01:47:08117void
118SBBreakpointLocation::SetThreadIndex (uint32_t index)
119{
Greg Clayton66111032010-06-23 01:19:29120 if (m_opaque_sp)
121 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
Jim Ingham62b02c62010-06-18 01:47:08122}
123
124uint32_t
125SBBreakpointLocation::GetThreadIndex() const
126{
Greg Clayton66111032010-06-23 01:19:29127 if (m_opaque_sp)
Jim Ingham62b02c62010-06-18 01:47:08128 {
Greg Clayton66111032010-06-23 01:19:29129 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham62b02c62010-06-18 01:47:08130 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 Clayton66111032010-06-23 01:19:29142 if (m_opaque_sp)
143 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
Jim Ingham62b02c62010-06-18 01:47:08144}
145
146const char *
147SBBreakpointLocation::GetThreadName () const
148{
Greg Clayton66111032010-06-23 01:19:29149 if (m_opaque_sp)
Jim Ingham62b02c62010-06-18 01:47:08150 {
Greg Clayton66111032010-06-23 01:19:29151 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham62b02c62010-06-18 01:47:08152 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 Clayton66111032010-06-23 01:19:29163 if (m_opaque_sp)
164 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
Jim Ingham62b02c62010-06-18 01:47:08165}
166
167const char *
168SBBreakpointLocation::GetQueueName () const
169{
Greg Clayton66111032010-06-23 01:19:29170 if (m_opaque_sp)
Jim Ingham62b02c62010-06-18 01:47:08171 {
Greg Clayton66111032010-06-23 01:19:29172 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham62b02c62010-06-18 01:47:08173 if (thread_spec == NULL)
174 return NULL;
175 else
176 return thread_spec->GetQueueName();
177 }
178 return NULL;
179}
180
Chris Lattner30fdc8d2010-06-08 16:52:24181bool
182SBBreakpointLocation::IsResolved ()
183{
Greg Clayton66111032010-06-23 01:19:29184 if (m_opaque_sp)
185 return m_opaque_sp->IsResolved();
Chris Lattner30fdc8d2010-06-08 16:52:24186 else
187 return false;
188}
189
190void
191SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
192{
Greg Clayton66111032010-06-23 01:19:29193 if (m_opaque_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24194 {
195 // Uninstall the callbacks?
196 }
Greg Clayton66111032010-06-23 01:19:29197 m_opaque_sp = break_loc_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24198}
199
Caroline Ticedde9cff2010-09-20 05:20:02200bool
201SBBreakpointLocation::GetDescription (const char *description_level, SBStream &description)
Chris Lattner30fdc8d2010-06-08 16:52:24202{
Greg Clayton66111032010-06-23 01:19:29203 if (m_opaque_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24204 {
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 Ticedde9cff2010-09-20 05:20:02215 m_opaque_sp->GetDescription (description.get(), level);
216 description.get()->EOL();
Chris Lattner30fdc8d2010-06-08 16:52:24217 }
Caroline Ticedde9cff2010-09-20 05:20:02218 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 Lattner30fdc8d2010-06-08 16:52:24231}
232
233SBBreakpoint
234SBBreakpointLocation::GetBreakpoint ()
235{
236 SBBreakpoint sb_bp;
Greg Clayton66111032010-06-23 01:19:29237 if (m_opaque_sp)
238 *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
Chris Lattner30fdc8d2010-06-08 16:52:24239 return sb_bp;
240}
241