blob: 206d5fdddf0cb535f6c84cb050c31088edf192b3 [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
10#include "lldb/API/SBBreakpointLocation.h"
11#include "lldb/API/SBDefines.h"
12#include "lldb/API/SBDebugger.h"
13
14#include "lldb/lldb-types.h"
15#include "lldb/lldb-defines.h"
16#include "lldb/Breakpoint/BreakpointLocation.h"
Jim Ingham3c7b5b92010-06-16 02:00:15 +000017#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000018#include "lldb/Core/Stream.h"
19#include "lldb/Core/StreamFile.h"
Jim Ingham8e5e38f2010-06-18 01:47:08 +000020#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000021
22using namespace lldb;
23using namespace lldb_private;
24
25
26
27//class SBBreakpointLocation
28
29SBBreakpointLocation::SBBreakpointLocation ()
30{
31}
32
33SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) :
34 m_break_loc_sp (break_loc_sp)
35{
36}
37
38SBBreakpointLocation::~SBBreakpointLocation ()
39{
40}
41
42bool
43SBBreakpointLocation::IsValid() const
44{
45 return m_break_loc_sp.get() != NULL;
46}
47
48addr_t
49SBBreakpointLocation::GetLoadAddress ()
50{
51 addr_t ret_addr = LLDB_INVALID_ADDRESS;
52
53 if (m_break_loc_sp)
54 {
55 ret_addr = m_break_loc_sp->GetLoadAddress();
56 }
57
58 return ret_addr;
59}
60
61void
62SBBreakpointLocation::SetEnabled (bool enabled)
63{
64 if (m_break_loc_sp)
65 {
66 m_break_loc_sp->SetEnabled (enabled);
67 }
68}
69
70bool
71SBBreakpointLocation::IsEnabled ()
72{
73 if (m_break_loc_sp)
74 return m_break_loc_sp->IsEnabled();
75 else
76 return false;
77}
78
79int32_t
80SBBreakpointLocation::GetIgnoreCount ()
81{
82 if (m_break_loc_sp)
83 return m_break_loc_sp->GetIgnoreCount();
84 else
85 return 0;
86}
87
88void
89SBBreakpointLocation::SetIgnoreCount (int32_t n)
90{
91 if (m_break_loc_sp)
92 m_break_loc_sp->SetIgnoreCount (n);
93}
94
95void
96SBBreakpointLocation::SetThreadID (tid_t thread_id)
97{
98 if (m_break_loc_sp)
99 m_break_loc_sp->SetThreadID (thread_id);
100}
101
102tid_t
103SBBreakpointLocation::GetThreadID ()
104{
105 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
106 if (m_break_loc_sp)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000107 sb_thread_id = m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->GetTID();
Chris Lattner24943d22010-06-08 16:52:24 +0000108
109 return sb_thread_id;
110}
111
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000112void
113SBBreakpointLocation::SetThreadIndex (uint32_t index)
114{
115 if (m_break_loc_sp)
116 m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
117}
118
119uint32_t
120SBBreakpointLocation::GetThreadIndex() const
121{
122 if (m_break_loc_sp)
123 {
124 const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCopy()->GetThreadSpec();
125 if (thread_spec == NULL)
126 return 0;
127 else
128 return thread_spec->GetIndex();
129 }
130 return 0;
131}
132
133
134void
135SBBreakpointLocation::SetThreadName (const char *thread_name)
136{
137 if (m_break_loc_sp)
138 m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
139}
140
141const char *
142SBBreakpointLocation::GetThreadName () const
143{
144 if (m_break_loc_sp)
145 {
146 const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCopy()->GetThreadSpec();
147 if (thread_spec == NULL)
148 return NULL;
149 else
150 return thread_spec->GetName();
151 }
152 return NULL;
153}
154
155void
156SBBreakpointLocation::SetQueueName (const char *queue_name)
157{
158 if (m_break_loc_sp)
159 m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
160}
161
162const char *
163SBBreakpointLocation::GetQueueName () const
164{
165 if (m_break_loc_sp)
166 {
167 const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCopy()->GetThreadSpec();
168 if (thread_spec == NULL)
169 return NULL;
170 else
171 return thread_spec->GetQueueName();
172 }
173 return NULL;
174}
175
Chris Lattner24943d22010-06-08 16:52:24 +0000176bool
177SBBreakpointLocation::IsResolved ()
178{
179 if (m_break_loc_sp)
180 return m_break_loc_sp->IsResolved();
181 else
182 return false;
183}
184
185void
186SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
187{
188 if (m_break_loc_sp)
189 {
190 // Uninstall the callbacks?
191 }
192 m_break_loc_sp = break_loc_sp;
193}
194
195void
196SBBreakpointLocation::GetDescription (FILE *f, const char *description_level)
197{
198 if (f == NULL)
199 return;
200
201 if (m_break_loc_sp)
202 {
203 DescriptionLevel level;
204 if (strcmp (description_level, "brief") == 0)
205 level = eDescriptionLevelBrief;
206 else if (strcmp (description_level, "full") == 0)
207 level = eDescriptionLevelFull;
208 else if (strcmp (description_level, "verbose") == 0)
209 level = eDescriptionLevelVerbose;
210 else
211 level = eDescriptionLevelBrief;
212
213 StreamFile str (f);
214
215 m_break_loc_sp->GetDescription (&str, level);
216 str.EOL();
217 }
218}
219
220SBBreakpoint
221SBBreakpointLocation::GetBreakpoint ()
222{
223 SBBreakpoint sb_bp;
224 if (m_break_loc_sp)
225 *sb_bp = m_break_loc_sp->GetBreakpoint ().GetSP();
226 return sb_bp;
227}
228