Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- 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 Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 10 | // 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 Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | #include "lldb/API/SBBreakpointLocation.h" |
| 16 | #include "lldb/API/SBDefines.h" |
| 17 | #include "lldb/API/SBDebugger.h" |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 18 | #include "lldb/API/SBStream.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 19 | |
| 20 | #include "lldb/lldb-types.h" |
| 21 | #include "lldb/lldb-defines.h" |
| 22 | #include "lldb/Breakpoint/BreakpointLocation.h" |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 23 | #include "lldb/Target/ThreadSpec.h" |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 24 | #include "lldb/Core/Log.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 25 | #include "lldb/Core/Stream.h" |
| 26 | #include "lldb/Core/StreamFile.h" |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 27 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | |
| 29 | using namespace lldb; |
| 30 | using namespace lldb_private; |
| 31 | |
| 32 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 33 | SBBreakpointLocation::SBBreakpointLocation () |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 38 | m_opaque_sp (break_loc_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 39 | { |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame^] | 40 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 41 | |
| 42 | if (log) |
| 43 | { |
| 44 | SBStream sstr; |
| 45 | GetDescription (lldb::eDescriptionLevelBrief, sstr); |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame^] | 46 | log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp" |
| 47 | "=%p) => this.sp = %p (%s)", break_loc_sp.get(), m_opaque_sp.get(), sstr.GetData()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 48 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | SBBreakpointLocation::~SBBreakpointLocation () |
| 52 | { |
| 53 | } |
| 54 | |
| 55 | bool |
| 56 | SBBreakpointLocation::IsValid() const |
| 57 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 58 | return m_opaque_sp.get() != NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | addr_t |
| 62 | SBBreakpointLocation::GetLoadAddress () |
| 63 | { |
| 64 | addr_t ret_addr = LLDB_INVALID_ADDRESS; |
| 65 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 66 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 67 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 68 | ret_addr = m_opaque_sp->GetLoadAddress(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | return ret_addr; |
| 72 | } |
| 73 | |
| 74 | void |
| 75 | SBBreakpointLocation::SetEnabled (bool enabled) |
| 76 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 77 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 78 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 79 | m_opaque_sp->SetEnabled (enabled); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | |
| 83 | bool |
| 84 | SBBreakpointLocation::IsEnabled () |
| 85 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 86 | if (m_opaque_sp) |
| 87 | return m_opaque_sp->IsEnabled(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 88 | else |
| 89 | return false; |
| 90 | } |
| 91 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 92 | uint32_t |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 93 | SBBreakpointLocation::GetIgnoreCount () |
| 94 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 95 | if (m_opaque_sp) |
| 96 | return m_opaque_sp->GetIgnoreCount(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 97 | else |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | void |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 102 | SBBreakpointLocation::SetIgnoreCount (uint32_t n) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 103 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 104 | if (m_opaque_sp) |
| 105 | m_opaque_sp->SetIgnoreCount (n); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | void |
Jim Ingham | e374083 | 2010-10-22 01:15:49 +0000 | [diff] [blame] | 109 | SBBreakpointLocation::SetCondition (const char *condition) |
| 110 | { |
| 111 | m_opaque_sp->SetCondition (condition); |
| 112 | } |
| 113 | |
| 114 | const char * |
| 115 | SBBreakpointLocation::GetCondition () |
| 116 | { |
| 117 | return m_opaque_sp->GetConditionText (); |
| 118 | } |
| 119 | |
| 120 | void |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 121 | SBBreakpointLocation::SetThreadID (tid_t thread_id) |
| 122 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 123 | if (m_opaque_sp) |
| 124 | m_opaque_sp->SetThreadID (thread_id); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | tid_t |
| 128 | SBBreakpointLocation::GetThreadID () |
| 129 | { |
| 130 | tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 131 | if (m_opaque_sp) |
| 132 | sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 133 | return sb_thread_id; |
| 134 | } |
| 135 | |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 136 | void |
| 137 | SBBreakpointLocation::SetThreadIndex (uint32_t index) |
| 138 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 139 | if (m_opaque_sp) |
| 140 | m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | uint32_t |
| 144 | SBBreakpointLocation::GetThreadIndex() const |
| 145 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 146 | if (m_opaque_sp) |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 147 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 148 | const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 149 | if (thread_spec == NULL) |
| 150 | return 0; |
| 151 | else |
| 152 | return thread_spec->GetIndex(); |
| 153 | } |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | |
| 158 | void |
| 159 | SBBreakpointLocation::SetThreadName (const char *thread_name) |
| 160 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 161 | if (m_opaque_sp) |
| 162 | m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | const char * |
| 166 | SBBreakpointLocation::GetThreadName () const |
| 167 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 168 | if (m_opaque_sp) |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 169 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 170 | const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 171 | if (thread_spec == NULL) |
| 172 | return NULL; |
| 173 | else |
| 174 | return thread_spec->GetName(); |
| 175 | } |
| 176 | return NULL; |
| 177 | } |
| 178 | |
| 179 | void |
| 180 | SBBreakpointLocation::SetQueueName (const char *queue_name) |
| 181 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 182 | if (m_opaque_sp) |
| 183 | m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | const char * |
| 187 | SBBreakpointLocation::GetQueueName () const |
| 188 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 189 | if (m_opaque_sp) |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 190 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 191 | const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 192 | if (thread_spec == NULL) |
| 193 | return NULL; |
| 194 | else |
| 195 | return thread_spec->GetQueueName(); |
| 196 | } |
| 197 | return NULL; |
| 198 | } |
| 199 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 200 | bool |
| 201 | SBBreakpointLocation::IsResolved () |
| 202 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 203 | if (m_opaque_sp) |
| 204 | return m_opaque_sp->IsResolved(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 205 | else |
| 206 | return false; |
| 207 | } |
| 208 | |
| 209 | void |
| 210 | SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp) |
| 211 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 212 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 213 | { |
| 214 | // Uninstall the callbacks? |
| 215 | } |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 216 | m_opaque_sp = break_loc_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 217 | } |
| 218 | |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 219 | bool |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 220 | SBBreakpointLocation::GetDescription (DescriptionLevel level, SBStream &description) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 221 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 222 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 223 | { |
Caroline Tice | e49ec18 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 224 | description.ref(); |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 225 | m_opaque_sp->GetDescription (description.get(), level); |
| 226 | description.get()->EOL(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 227 | } |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 228 | else |
| 229 | description.Printf ("No value"); |
| 230 | |
| 231 | return true; |
| 232 | } |
| 233 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 234 | SBBreakpoint |
| 235 | SBBreakpointLocation::GetBreakpoint () |
| 236 | { |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 237 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); |
| 238 | |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame^] | 239 | //if (log) |
| 240 | // log->Printf ("SBBreakpointLocation::GetBreakpoint ()"); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 241 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 242 | SBBreakpoint sb_bp; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 243 | if (m_opaque_sp) |
| 244 | *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP(); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 245 | |
| 246 | if (log) |
| 247 | { |
| 248 | SBStream sstr; |
| 249 | sb_bp.GetDescription (sstr); |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame^] | 250 | log->Printf ("SBBreakpointLocation::GetBreakpoint (this.sp=%p) => SBBreakpoint: m_opaque_sp=%p, '%s'", |
| 251 | m_opaque_sp.get(), sb_bp.get(), sstr.GetData()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 252 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 253 | return sb_bp; |
| 254 | } |
| 255 | |