blob: d917deab4f11a7c35bac5b4dac925e8b1a4f2aaa [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"
20
21using namespace lldb;
22using namespace lldb_private;
23
24
25
26//class SBBreakpointLocation
27
28SBBreakpointLocation::SBBreakpointLocation ()
29{
30}
31
32SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) :
33 m_break_loc_sp (break_loc_sp)
34{
35}
36
37SBBreakpointLocation::~SBBreakpointLocation ()
38{
39}
40
41bool
42SBBreakpointLocation::IsValid() const
43{
44 return m_break_loc_sp.get() != NULL;
45}
46
47addr_t
48SBBreakpointLocation::GetLoadAddress ()
49{
50 addr_t ret_addr = LLDB_INVALID_ADDRESS;
51
52 if (m_break_loc_sp)
53 {
54 ret_addr = m_break_loc_sp->GetLoadAddress();
55 }
56
57 return ret_addr;
58}
59
60void
61SBBreakpointLocation::SetEnabled (bool enabled)
62{
63 if (m_break_loc_sp)
64 {
65 m_break_loc_sp->SetEnabled (enabled);
66 }
67}
68
69bool
70SBBreakpointLocation::IsEnabled ()
71{
72 if (m_break_loc_sp)
73 return m_break_loc_sp->IsEnabled();
74 else
75 return false;
76}
77
78int32_t
79SBBreakpointLocation::GetIgnoreCount ()
80{
81 if (m_break_loc_sp)
82 return m_break_loc_sp->GetIgnoreCount();
83 else
84 return 0;
85}
86
87void
88SBBreakpointLocation::SetIgnoreCount (int32_t n)
89{
90 if (m_break_loc_sp)
91 m_break_loc_sp->SetIgnoreCount (n);
92}
93
94void
95SBBreakpointLocation::SetThreadID (tid_t thread_id)
96{
97 if (m_break_loc_sp)
98 m_break_loc_sp->SetThreadID (thread_id);
99}
100
101tid_t
102SBBreakpointLocation::GetThreadID ()
103{
104 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
105 if (m_break_loc_sp)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000106 sb_thread_id = m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->GetTID();
Chris Lattner24943d22010-06-08 16:52:24 +0000107
108 return sb_thread_id;
109}
110
111bool
112SBBreakpointLocation::IsResolved ()
113{
114 if (m_break_loc_sp)
115 return m_break_loc_sp->IsResolved();
116 else
117 return false;
118}
119
120void
121SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp)
122{
123 if (m_break_loc_sp)
124 {
125 // Uninstall the callbacks?
126 }
127 m_break_loc_sp = break_loc_sp;
128}
129
130void
131SBBreakpointLocation::GetDescription (FILE *f, const char *description_level)
132{
133 if (f == NULL)
134 return;
135
136 if (m_break_loc_sp)
137 {
138 DescriptionLevel level;
139 if (strcmp (description_level, "brief") == 0)
140 level = eDescriptionLevelBrief;
141 else if (strcmp (description_level, "full") == 0)
142 level = eDescriptionLevelFull;
143 else if (strcmp (description_level, "verbose") == 0)
144 level = eDescriptionLevelVerbose;
145 else
146 level = eDescriptionLevelBrief;
147
148 StreamFile str (f);
149
150 m_break_loc_sp->GetDescription (&str, level);
151 str.EOL();
152 }
153}
154
155SBBreakpoint
156SBBreakpointLocation::GetBreakpoint ()
157{
158 SBBreakpoint sb_bp;
159 if (m_break_loc_sp)
160 *sb_bp = m_break_loc_sp->GetBreakpoint ().GetSP();
161 return sb_bp;
162}
163