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 | |
| 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 Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 17 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Stream.h" |
| 19 | #include "lldb/Core/StreamFile.h" |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame^] | 20 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace lldb; |
| 23 | using namespace lldb_private; |
| 24 | |
| 25 | |
| 26 | |
| 27 | //class SBBreakpointLocation |
| 28 | |
| 29 | SBBreakpointLocation::SBBreakpointLocation () |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) : |
| 34 | m_break_loc_sp (break_loc_sp) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | SBBreakpointLocation::~SBBreakpointLocation () |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | bool |
| 43 | SBBreakpointLocation::IsValid() const |
| 44 | { |
| 45 | return m_break_loc_sp.get() != NULL; |
| 46 | } |
| 47 | |
| 48 | addr_t |
| 49 | SBBreakpointLocation::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 | |
| 61 | void |
| 62 | SBBreakpointLocation::SetEnabled (bool enabled) |
| 63 | { |
| 64 | if (m_break_loc_sp) |
| 65 | { |
| 66 | m_break_loc_sp->SetEnabled (enabled); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | bool |
| 71 | SBBreakpointLocation::IsEnabled () |
| 72 | { |
| 73 | if (m_break_loc_sp) |
| 74 | return m_break_loc_sp->IsEnabled(); |
| 75 | else |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | int32_t |
| 80 | SBBreakpointLocation::GetIgnoreCount () |
| 81 | { |
| 82 | if (m_break_loc_sp) |
| 83 | return m_break_loc_sp->GetIgnoreCount(); |
| 84 | else |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | void |
| 89 | SBBreakpointLocation::SetIgnoreCount (int32_t n) |
| 90 | { |
| 91 | if (m_break_loc_sp) |
| 92 | m_break_loc_sp->SetIgnoreCount (n); |
| 93 | } |
| 94 | |
| 95 | void |
| 96 | SBBreakpointLocation::SetThreadID (tid_t thread_id) |
| 97 | { |
| 98 | if (m_break_loc_sp) |
| 99 | m_break_loc_sp->SetThreadID (thread_id); |
| 100 | } |
| 101 | |
| 102 | tid_t |
| 103 | SBBreakpointLocation::GetThreadID () |
| 104 | { |
| 105 | tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; |
| 106 | if (m_break_loc_sp) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 107 | sb_thread_id = m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->GetTID(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | |
| 109 | return sb_thread_id; |
| 110 | } |
| 111 | |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame^] | 112 | void |
| 113 | SBBreakpointLocation::SetThreadIndex (uint32_t index) |
| 114 | { |
| 115 | if (m_break_loc_sp) |
| 116 | m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index); |
| 117 | } |
| 118 | |
| 119 | uint32_t |
| 120 | SBBreakpointLocation::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 | |
| 134 | void |
| 135 | SBBreakpointLocation::SetThreadName (const char *thread_name) |
| 136 | { |
| 137 | if (m_break_loc_sp) |
| 138 | m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name); |
| 139 | } |
| 140 | |
| 141 | const char * |
| 142 | SBBreakpointLocation::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 | |
| 155 | void |
| 156 | SBBreakpointLocation::SetQueueName (const char *queue_name) |
| 157 | { |
| 158 | if (m_break_loc_sp) |
| 159 | m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name); |
| 160 | } |
| 161 | |
| 162 | const char * |
| 163 | SBBreakpointLocation::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 Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 176 | bool |
| 177 | SBBreakpointLocation::IsResolved () |
| 178 | { |
| 179 | if (m_break_loc_sp) |
| 180 | return m_break_loc_sp->IsResolved(); |
| 181 | else |
| 182 | return false; |
| 183 | } |
| 184 | |
| 185 | void |
| 186 | SBBreakpointLocation::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 | |
| 195 | void |
| 196 | SBBreakpointLocation::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 | |
| 220 | SBBreakpoint |
| 221 | SBBreakpointLocation::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 | |