blob: f376f5368b5cbd12372dee5de36a0d429233c9be [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) :
Greg Clayton63094e02010-06-23 01:19:29 +000034 m_opaque_sp (break_loc_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000035{
36}
37
38SBBreakpointLocation::~SBBreakpointLocation ()
39{
40}
41
42bool
43SBBreakpointLocation::IsValid() const
44{
Greg Clayton63094e02010-06-23 01:19:29 +000045 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000046}
47
48addr_t
49SBBreakpointLocation::GetLoadAddress ()
50{
51 addr_t ret_addr = LLDB_INVALID_ADDRESS;
52
Greg Clayton63094e02010-06-23 01:19:29 +000053 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000054 {
Greg Clayton63094e02010-06-23 01:19:29 +000055 ret_addr = m_opaque_sp->GetLoadAddress();
Chris Lattner24943d22010-06-08 16:52:24 +000056 }
57
58 return ret_addr;
59}
60
61void
62SBBreakpointLocation::SetEnabled (bool enabled)
63{
Greg Clayton63094e02010-06-23 01:19:29 +000064 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000065 {
Greg Clayton63094e02010-06-23 01:19:29 +000066 m_opaque_sp->SetEnabled (enabled);
Chris Lattner24943d22010-06-08 16:52:24 +000067 }
68}
69
70bool
71SBBreakpointLocation::IsEnabled ()
72{
Greg Clayton63094e02010-06-23 01:19:29 +000073 if (m_opaque_sp)
74 return m_opaque_sp->IsEnabled();
Chris Lattner24943d22010-06-08 16:52:24 +000075 else
76 return false;
77}
78
79int32_t
80SBBreakpointLocation::GetIgnoreCount ()
81{
Greg Clayton63094e02010-06-23 01:19:29 +000082 if (m_opaque_sp)
83 return m_opaque_sp->GetIgnoreCount();
Chris Lattner24943d22010-06-08 16:52:24 +000084 else
85 return 0;
86}
87
88void
89SBBreakpointLocation::SetIgnoreCount (int32_t n)
90{
Greg Clayton63094e02010-06-23 01:19:29 +000091 if (m_opaque_sp)
92 m_opaque_sp->SetIgnoreCount (n);
Chris Lattner24943d22010-06-08 16:52:24 +000093}
94
95void
96SBBreakpointLocation::SetThreadID (tid_t thread_id)
97{
Greg Clayton63094e02010-06-23 01:19:29 +000098 if (m_opaque_sp)
99 m_opaque_sp->SetThreadID (thread_id);
Chris Lattner24943d22010-06-08 16:52:24 +0000100}
101
102tid_t
103SBBreakpointLocation::GetThreadID ()
104{
105 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
Greg Clayton63094e02010-06-23 01:19:29 +0000106 if (m_opaque_sp)
107 sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
Chris Lattner24943d22010-06-08 16:52:24 +0000108 return sb_thread_id;
109}
110
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000111void
112SBBreakpointLocation::SetThreadIndex (uint32_t index)
113{
Greg Clayton63094e02010-06-23 01:19:29 +0000114 if (m_opaque_sp)
115 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000116}
117
118uint32_t
119SBBreakpointLocation::GetThreadIndex() const
120{
Greg Clayton63094e02010-06-23 01:19:29 +0000121 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000122 {
Greg Clayton63094e02010-06-23 01:19:29 +0000123 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000124 if (thread_spec == NULL)
125 return 0;
126 else
127 return thread_spec->GetIndex();
128 }
129 return 0;
130}
131
132
133void
134SBBreakpointLocation::SetThreadName (const char *thread_name)
135{
Greg Clayton63094e02010-06-23 01:19:29 +0000136 if (m_opaque_sp)
137 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000138}
139
140const char *
141SBBreakpointLocation::GetThreadName () const
142{
Greg Clayton63094e02010-06-23 01:19:29 +0000143 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000144 {
Greg Clayton63094e02010-06-23 01:19:29 +0000145 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000146 if (thread_spec == NULL)
147 return NULL;
148 else
149 return thread_spec->GetName();
150 }
151 return NULL;
152}
153
154void
155SBBreakpointLocation::SetQueueName (const char *queue_name)
156{
Greg Clayton63094e02010-06-23 01:19:29 +0000157 if (m_opaque_sp)
158 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000159}
160
161const char *
162SBBreakpointLocation::GetQueueName () const
163{
Greg Clayton63094e02010-06-23 01:19:29 +0000164 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000165 {
Greg Clayton63094e02010-06-23 01:19:29 +0000166 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000167 if (thread_spec == NULL)
168 return NULL;
169 else
170 return thread_spec->GetQueueName();
171 }
172 return NULL;
173}
174
Chris Lattner24943d22010-06-08 16:52:24 +0000175bool
176SBBreakpointLocation::IsResolved ()
177{
Greg Clayton63094e02010-06-23 01:19:29 +0000178 if (m_opaque_sp)
179 return m_opaque_sp->IsResolved();
Chris Lattner24943d22010-06-08 16:52:24 +0000180 else
181 return false;
182}
183
184void
185SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
186{
Greg Clayton63094e02010-06-23 01:19:29 +0000187 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000188 {
189 // Uninstall the callbacks?
190 }
Greg Clayton63094e02010-06-23 01:19:29 +0000191 m_opaque_sp = break_loc_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000192}
193
194void
195SBBreakpointLocation::GetDescription (FILE *f, const char *description_level)
196{
197 if (f == NULL)
198 return;
199
Greg Clayton63094e02010-06-23 01:19:29 +0000200 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000201 {
202 DescriptionLevel level;
203 if (strcmp (description_level, "brief") == 0)
204 level = eDescriptionLevelBrief;
205 else if (strcmp (description_level, "full") == 0)
206 level = eDescriptionLevelFull;
207 else if (strcmp (description_level, "verbose") == 0)
208 level = eDescriptionLevelVerbose;
209 else
210 level = eDescriptionLevelBrief;
211
212 StreamFile str (f);
213
Greg Clayton63094e02010-06-23 01:19:29 +0000214 m_opaque_sp->GetDescription (&str, level);
Chris Lattner24943d22010-06-08 16:52:24 +0000215 str.EOL();
216 }
217}
218
219SBBreakpoint
220SBBreakpointLocation::GetBreakpoint ()
221{
222 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000223 if (m_opaque_sp)
224 *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP();
Chris Lattner24943d22010-06-08 16:52:24 +0000225 return sb_bp;
226}
227