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