blob: 9ea28772978a387dfa7207cfd4537eb6eef1f572 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- SBThread.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
Eli Friedman7a62c8b2010-06-09 07:44:37 +000010#include "lldb/API/SBThread.h"
Chris Lattner24943d22010-06-08 16:52:24 +000011
12#include "lldb/API/SBSymbolContext.h"
13#include "lldb/API/SBFileSpec.h"
Caroline Tice98f930f2010-09-20 05:20:02 +000014#include "lldb/API/SBStream.h"
Greg Clayton640dc6b2010-11-18 18:52:36 +000015#include "lldb/Breakpoint/BreakpointLocation.h"
Greg Clayton63094e02010-06-23 01:19:29 +000016#include "lldb/Core/Debugger.h"
Chris Lattner24943d22010-06-08 16:52:24 +000017#include "lldb/Core/Stream.h"
18#include "lldb/Core/StreamFile.h"
Greg Clayton63094e02010-06-23 01:19:29 +000019#include "lldb/Interpreter/CommandInterpreter.h"
Chris Lattner24943d22010-06-08 16:52:24 +000020#include "lldb/Target/Thread.h"
21#include "lldb/Target/Process.h"
22#include "lldb/Symbol/SymbolContext.h"
23#include "lldb/Symbol/CompileUnit.h"
Greg Clayton643ee732010-08-04 01:40:35 +000024#include "lldb/Target/StopInfo.h"
Chris Lattner24943d22010-06-08 16:52:24 +000025#include "lldb/Target/Target.h"
26#include "lldb/Target/ThreadPlan.h"
Chris Lattner24943d22010-06-08 16:52:24 +000027#include "lldb/Target/ThreadPlanStepInstruction.h"
28#include "lldb/Target/ThreadPlanStepOut.h"
29#include "lldb/Target/ThreadPlanStepRange.h"
30#include "lldb/Target/ThreadPlanStepInRange.h"
31
32
Eli Friedman7a62c8b2010-06-09 07:44:37 +000033#include "lldb/API/SBAddress.h"
Eli Friedman7a62c8b2010-06-09 07:44:37 +000034#include "lldb/API/SBDebugger.h"
Jim Ingham1586d972011-12-17 01:35:57 +000035#include "lldb/API/SBFrame.h"
Eli Friedman7a62c8b2010-06-09 07:44:37 +000036#include "lldb/API/SBProcess.h"
Jim Ingham1586d972011-12-17 01:35:57 +000037#include "lldb/API/SBValue.h"
Chris Lattner24943d22010-06-08 16:52:24 +000038
39using namespace lldb;
40using namespace lldb_private;
41
Greg Clayton49ce6822010-10-31 03:01:06 +000042//----------------------------------------------------------------------
43// Constructors
44//----------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +000045SBThread::SBThread () :
Greg Clayton63094e02010-06-23 01:19:29 +000046 m_opaque_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +000047{
48}
49
Chris Lattner24943d22010-06-08 16:52:24 +000050SBThread::SBThread (const ThreadSP& lldb_object_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000051 m_opaque_sp (lldb_object_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000052{
53}
54
Greg Clayton1b284412010-10-30 18:26:59 +000055SBThread::SBThread (const SBThread &rhs) :
56 m_opaque_sp (rhs.m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000057{
Chris Lattner24943d22010-06-08 16:52:24 +000058}
59
60//----------------------------------------------------------------------
Greg Clayton49ce6822010-10-31 03:01:06 +000061// Assignment operator
62//----------------------------------------------------------------------
63
64const lldb::SBThread &
65SBThread::operator = (const SBThread &rhs)
66{
67 if (this != &rhs)
68 m_opaque_sp = rhs.m_opaque_sp;
69 return *this;
70}
71
72//----------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +000073// Destructor
74//----------------------------------------------------------------------
75SBThread::~SBThread()
76{
77}
78
79bool
80SBThread::IsValid() const
81{
Greg Claytone40b6422011-09-18 18:59:15 +000082 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +000083}
84
Greg Clayton43490d12010-07-30 20:12:55 +000085void
86SBThread::Clear ()
87{
88 m_opaque_sp.reset();
89}
90
91
Chris Lattner24943d22010-06-08 16:52:24 +000092StopReason
93SBThread::GetStopReason()
94{
Greg Claytone005f2c2010-11-06 01:53:30 +000095 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +000096
Caroline Tice7826c882010-10-26 03:11:13 +000097 StopReason reason = eStopReasonInvalid;
Greg Clayton63094e02010-06-23 01:19:29 +000098 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000099 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000100 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Jim Ingham6297a3a2010-10-20 00:39:53 +0000101 StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo ();
102 if (stop_info_sp)
Caroline Tice7826c882010-10-26 03:11:13 +0000103 reason = stop_info_sp->GetStopReason();
Chris Lattner24943d22010-06-08 16:52:24 +0000104 }
Caroline Tice7826c882010-10-26 03:11:13 +0000105
106 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000107 log->Printf ("SBThread(%p)::GetStopReason () => %s", m_opaque_sp.get(),
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000108 Thread::StopReasonAsCString (reason));
Caroline Tice7826c882010-10-26 03:11:13 +0000109
110 return reason;
Chris Lattner24943d22010-06-08 16:52:24 +0000111}
112
113size_t
Greg Clayton640dc6b2010-11-18 18:52:36 +0000114SBThread::GetStopReasonDataCount ()
115{
116 if (m_opaque_sp)
117 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000118 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Greg Clayton640dc6b2010-11-18 18:52:36 +0000119 StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo ();
120 if (stop_info_sp)
121 {
122 StopReason reason = stop_info_sp->GetStopReason();
123 switch (reason)
124 {
125 case eStopReasonInvalid:
126 case eStopReasonNone:
127 case eStopReasonTrace:
128 case eStopReasonPlanComplete:
129 // There is no data for these stop reasons.
130 return 0;
131
132 case eStopReasonBreakpoint:
133 {
134 break_id_t site_id = stop_info_sp->GetValue();
135 lldb::BreakpointSiteSP bp_site_sp (m_opaque_sp->GetProcess().GetBreakpointSiteList().FindByID (site_id));
136 if (bp_site_sp)
137 return bp_site_sp->GetNumberOfOwners () * 2;
138 else
139 return 0; // Breakpoint must have cleared itself...
140 }
141 break;
142
143 case eStopReasonWatchpoint:
144 assert (!"implement watchpoint support in SBThread::GetStopReasonDataCount ()");
145 return 0; // We don't have watchpoint support yet...
146
147 case eStopReasonSignal:
148 return 1;
149
150 case eStopReasonException:
151 return 1;
152 }
153 }
154 }
155 return 0;
156}
157
158uint64_t
159SBThread::GetStopReasonDataAtIndex (uint32_t idx)
160{
161 if (m_opaque_sp)
162 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000163 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Greg Clayton640dc6b2010-11-18 18:52:36 +0000164 StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo ();
165 if (stop_info_sp)
166 {
167 StopReason reason = stop_info_sp->GetStopReason();
168 switch (reason)
169 {
170 case eStopReasonInvalid:
171 case eStopReasonNone:
172 case eStopReasonTrace:
173 case eStopReasonPlanComplete:
174 // There is no data for these stop reasons.
175 return 0;
176
177 case eStopReasonBreakpoint:
178 {
179 break_id_t site_id = stop_info_sp->GetValue();
180 lldb::BreakpointSiteSP bp_site_sp (m_opaque_sp->GetProcess().GetBreakpointSiteList().FindByID (site_id));
181 if (bp_site_sp)
182 {
183 uint32_t bp_index = idx / 2;
184 BreakpointLocationSP bp_loc_sp (bp_site_sp->GetOwnerAtIndex (bp_index));
185 if (bp_loc_sp)
186 {
187 if (bp_index & 1)
188 {
189 // Odd idx, return the breakpoint location ID
190 return bp_loc_sp->GetID();
191 }
192 else
193 {
194 // Even idx, return the breakpoint ID
195 return bp_loc_sp->GetBreakpoint().GetID();
196 }
197 }
198 }
199 return LLDB_INVALID_BREAK_ID;
200 }
201 break;
202
203 case eStopReasonWatchpoint:
204 assert (!"implement watchpoint support in SBThread::GetStopReasonDataCount ()");
205 return 0; // We don't have watchpoint support yet...
206
207 case eStopReasonSignal:
208 return stop_info_sp->GetValue();
209
210 case eStopReasonException:
211 return stop_info_sp->GetValue();
212 }
213 }
214 }
215 return 0;
216}
217
218size_t
Chris Lattner24943d22010-06-08 16:52:24 +0000219SBThread::GetStopDescription (char *dst, size_t dst_len)
220{
Greg Claytone005f2c2010-11-06 01:53:30 +0000221 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000222
Greg Clayton63094e02010-06-23 01:19:29 +0000223 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000224 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000225 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Jim Ingham6297a3a2010-10-20 00:39:53 +0000226 StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo ();
227 if (stop_info_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000228 {
Jim Ingham6297a3a2010-10-20 00:39:53 +0000229 const char *stop_desc = stop_info_sp->GetDescription();
Chris Lattner24943d22010-06-08 16:52:24 +0000230 if (stop_desc)
231 {
Caroline Tice7826c882010-10-26 03:11:13 +0000232 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000233 log->Printf ("SBThread(%p)::GetStopDescription (dst, dst_len) => \"%s\"",
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000234 m_opaque_sp.get(), stop_desc);
Chris Lattner24943d22010-06-08 16:52:24 +0000235 if (dst)
236 return ::snprintf (dst, dst_len, "%s", stop_desc);
237 else
238 {
239 // NULL dst passed in, return the length needed to contain the description
240 return ::strlen (stop_desc) + 1; // Include the NULL byte for size
241 }
242 }
243 else
244 {
Chris Lattner24943d22010-06-08 16:52:24 +0000245 size_t stop_desc_len = 0;
Jim Ingham6297a3a2010-10-20 00:39:53 +0000246 switch (stop_info_sp->GetStopReason())
Chris Lattner24943d22010-06-08 16:52:24 +0000247 {
248 case eStopReasonTrace:
249 case eStopReasonPlanComplete:
250 {
251 static char trace_desc[] = "step";
252 stop_desc = trace_desc;
253 stop_desc_len = sizeof(trace_desc); // Include the NULL byte for size
254 }
255 break;
256
257 case eStopReasonBreakpoint:
258 {
259 static char bp_desc[] = "breakpoint hit";
260 stop_desc = bp_desc;
261 stop_desc_len = sizeof(bp_desc); // Include the NULL byte for size
262 }
263 break;
264
265 case eStopReasonWatchpoint:
266 {
267 static char wp_desc[] = "watchpoint hit";
268 stop_desc = wp_desc;
269 stop_desc_len = sizeof(wp_desc); // Include the NULL byte for size
270 }
271 break;
272
273 case eStopReasonSignal:
274 {
Jim Ingham6297a3a2010-10-20 00:39:53 +0000275 stop_desc = m_opaque_sp->GetProcess().GetUnixSignals ().GetSignalAsCString (stop_info_sp->GetValue());
Chris Lattner24943d22010-06-08 16:52:24 +0000276 if (stop_desc == NULL || stop_desc[0] == '\0')
277 {
278 static char signal_desc[] = "signal";
279 stop_desc = signal_desc;
280 stop_desc_len = sizeof(signal_desc); // Include the NULL byte for size
281 }
282 }
283 break;
284
285 case eStopReasonException:
286 {
287 char exc_desc[] = "exception";
288 stop_desc = exc_desc;
289 stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
290 }
Greg Clayton54e7afa2010-07-09 20:39:50 +0000291 break;
292
293 default:
294 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000295 }
296
297 if (stop_desc && stop_desc[0])
298 {
Caroline Tice7826c882010-10-26 03:11:13 +0000299 if (log)
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000300 log->Printf ("SBThread(%p)::GetStopDescription (dst, dst_len) => '%s'",
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000301 m_opaque_sp.get(), stop_desc);
Caroline Tice7826c882010-10-26 03:11:13 +0000302
Chris Lattner24943d22010-06-08 16:52:24 +0000303 if (dst)
304 return ::snprintf (dst, dst_len, "%s", stop_desc) + 1; // Include the NULL byte
305
306 if (stop_desc_len == 0)
307 stop_desc_len = ::strlen (stop_desc) + 1; // Include the NULL byte
308
309 return stop_desc_len;
310 }
311 }
312 }
313 }
314 if (dst)
315 *dst = 0;
316 return 0;
317}
318
Jim Ingham1586d972011-12-17 01:35:57 +0000319SBValue
320SBThread::GetStopReturnValue ()
321{
322 ValueObjectSP return_valobj_sp;
323 if (m_opaque_sp)
324 {
325 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
326 StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo ();
327 if (stop_info_sp)
328 {
329 return_valobj_sp = StopInfo::GetReturnValueObject (stop_info_sp);
330 }
331 }
332
333 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
334 if (log)
335 log->Printf ("SBThread(%p)::GetStopReturnValue () => %s", m_opaque_sp.get(),
336 return_valobj_sp.get()
337 ? return_valobj_sp->GetValueAsCString()
338 : "<no return value>");
339
340 return SBValue (return_valobj_sp);
341}
342
Chris Lattner24943d22010-06-08 16:52:24 +0000343void
344SBThread::SetThread (const ThreadSP& lldb_object_sp)
345{
Greg Clayton63094e02010-06-23 01:19:29 +0000346 m_opaque_sp = lldb_object_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000347}
348
349
350lldb::tid_t
351SBThread::GetThreadID () const
352{
Greg Claytone005f2c2010-11-06 01:53:30 +0000353 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000354
Greg Claytonbdcda462010-12-20 20:49:23 +0000355 lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
Greg Clayton63094e02010-06-23 01:19:29 +0000356 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000357 tid = m_opaque_sp->GetID();
Caroline Tice7826c882010-10-26 03:11:13 +0000358
359 if (log)
Greg Claytond9919d32011-12-01 23:28:38 +0000360 log->Printf ("SBThread(%p)::GetThreadID () => 0x%4.4llx", m_opaque_sp.get(), tid);
Caroline Tice7826c882010-10-26 03:11:13 +0000361
Greg Claytonbdcda462010-12-20 20:49:23 +0000362 return tid;
Chris Lattner24943d22010-06-08 16:52:24 +0000363}
364
365uint32_t
366SBThread::GetIndexID () const
367{
Greg Clayton63094e02010-06-23 01:19:29 +0000368 if (m_opaque_sp)
369 return m_opaque_sp->GetIndexID();
Chris Lattner24943d22010-06-08 16:52:24 +0000370 return LLDB_INVALID_INDEX32;
371}
372const char *
373SBThread::GetName () const
374{
Greg Claytona66ba462010-10-30 04:51:46 +0000375 const char *name = NULL;
Greg Clayton63094e02010-06-23 01:19:29 +0000376 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000377 {
378 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Greg Claytona66ba462010-10-30 04:51:46 +0000379 name = m_opaque_sp->GetName();
Greg Claytonbdcda462010-12-20 20:49:23 +0000380 }
Greg Claytona66ba462010-10-30 04:51:46 +0000381
Greg Claytone005f2c2010-11-06 01:53:30 +0000382 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000383 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000384 log->Printf ("SBThread(%p)::GetName () => %s", m_opaque_sp.get(), name ? name : "NULL");
Caroline Tice7826c882010-10-26 03:11:13 +0000385
Greg Claytona66ba462010-10-30 04:51:46 +0000386 return name;
Chris Lattner24943d22010-06-08 16:52:24 +0000387}
388
389const char *
390SBThread::GetQueueName () const
391{
Greg Claytona66ba462010-10-30 04:51:46 +0000392 const char *name = NULL;
Greg Clayton63094e02010-06-23 01:19:29 +0000393 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000394 {
395 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Greg Claytona66ba462010-10-30 04:51:46 +0000396 name = m_opaque_sp->GetQueueName();
Greg Claytonbdcda462010-12-20 20:49:23 +0000397 }
Greg Claytona66ba462010-10-30 04:51:46 +0000398
Greg Claytone005f2c2010-11-06 01:53:30 +0000399 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000400 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000401 log->Printf ("SBThread(%p)::GetQueueName () => %s", m_opaque_sp.get(), name ? name : "NULL");
Caroline Tice7826c882010-10-26 03:11:13 +0000402
Greg Claytona66ba462010-10-30 04:51:46 +0000403 return name;
Chris Lattner24943d22010-06-08 16:52:24 +0000404}
405
406
407void
Chris Lattner24943d22010-06-08 16:52:24 +0000408SBThread::StepOver (lldb::RunMode stop_other_threads)
409{
Greg Claytone005f2c2010-11-06 01:53:30 +0000410 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000411
412 if (log)
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000413 log->Printf ("SBThread(%p)::StepOver (stop_other_threads='%s')", m_opaque_sp.get(),
Caroline Tice7826c882010-10-26 03:11:13 +0000414 Thread::RunModeAsCString (stop_other_threads));
415
Greg Clayton63094e02010-06-23 01:19:29 +0000416 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000417 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000418 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Chris Lattner24943d22010-06-08 16:52:24 +0000419 bool abort_other_plans = true;
Greg Clayton63094e02010-06-23 01:19:29 +0000420 StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0));
Chris Lattner24943d22010-06-08 16:52:24 +0000421
422 if (frame_sp)
423 {
424 if (frame_sp->HasDebugInformation ())
425 {
426 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
Greg Clayton63094e02010-06-23 01:19:29 +0000427 m_opaque_sp->QueueThreadPlanForStepRange (abort_other_plans,
Greg Clayton1a3083a2010-10-06 03:53:16 +0000428 eStepTypeOver,
429 sc.line_entry.range,
430 sc,
431 stop_other_threads,
432 false);
Chris Lattner24943d22010-06-08 16:52:24 +0000433
434 }
435 else
436 {
Greg Clayton63094e02010-06-23 01:19:29 +0000437 m_opaque_sp->QueueThreadPlanForStepSingleInstruction (true,
Greg Clayton1a3083a2010-10-06 03:53:16 +0000438 abort_other_plans,
439 stop_other_threads);
Chris Lattner24943d22010-06-08 16:52:24 +0000440 }
441 }
442
Greg Clayton63094e02010-06-23 01:19:29 +0000443 Process &process = m_opaque_sp->GetProcess();
Chris Lattner24943d22010-06-08 16:52:24 +0000444 // Why do we need to set the current thread by ID here???
Jim Inghamc8332952010-08-26 21:32:51 +0000445 process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID());
Greg Clayton1a3083a2010-10-06 03:53:16 +0000446 Error error (process.Resume());
447 if (error.Success())
448 {
449 // If we are doing synchronous mode, then wait for the
450 // process to stop yet again!
451 if (process.GetTarget().GetDebugger().GetAsyncExecution () == false)
452 process.WaitForProcessToStop (NULL);
453 }
Chris Lattner24943d22010-06-08 16:52:24 +0000454 }
455}
456
457void
458SBThread::StepInto (lldb::RunMode stop_other_threads)
459{
Greg Claytone005f2c2010-11-06 01:53:30 +0000460 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000461
462 if (log)
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000463 log->Printf ("SBThread(%p)::StepInto (stop_other_threads='%s')", m_opaque_sp.get(),
Caroline Tice7826c882010-10-26 03:11:13 +0000464 Thread::RunModeAsCString (stop_other_threads));
465
Greg Clayton63094e02010-06-23 01:19:29 +0000466 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000467 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000468 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Chris Lattner24943d22010-06-08 16:52:24 +0000469 bool abort_other_plans = true;
470
Greg Clayton63094e02010-06-23 01:19:29 +0000471 StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0));
Chris Lattner24943d22010-06-08 16:52:24 +0000472
473 if (frame_sp && frame_sp->HasDebugInformation ())
474 {
Greg Clayton8f5fd6b2010-06-12 18:59:55 +0000475 bool avoid_code_without_debug_info = true;
Chris Lattner24943d22010-06-08 16:52:24 +0000476 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
Greg Clayton63094e02010-06-23 01:19:29 +0000477 m_opaque_sp->QueueThreadPlanForStepRange (abort_other_plans,
Greg Clayton1a3083a2010-10-06 03:53:16 +0000478 eStepTypeInto,
479 sc.line_entry.range,
480 sc,
481 stop_other_threads,
482 avoid_code_without_debug_info);
Chris Lattner24943d22010-06-08 16:52:24 +0000483 }
484 else
485 {
Greg Clayton63094e02010-06-23 01:19:29 +0000486 m_opaque_sp->QueueThreadPlanForStepSingleInstruction (false,
Greg Clayton1a3083a2010-10-06 03:53:16 +0000487 abort_other_plans,
488 stop_other_threads);
Chris Lattner24943d22010-06-08 16:52:24 +0000489 }
490
Greg Clayton63094e02010-06-23 01:19:29 +0000491 Process &process = m_opaque_sp->GetProcess();
Chris Lattner24943d22010-06-08 16:52:24 +0000492 // Why do we need to set the current thread by ID here???
Jim Inghamc8332952010-08-26 21:32:51 +0000493 process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID());
Greg Clayton1a3083a2010-10-06 03:53:16 +0000494 Error error (process.Resume());
495 if (error.Success())
496 {
497 // If we are doing synchronous mode, then wait for the
498 // process to stop yet again!
499 if (process.GetTarget().GetDebugger().GetAsyncExecution () == false)
500 process.WaitForProcessToStop (NULL);
501 }
Chris Lattner24943d22010-06-08 16:52:24 +0000502 }
503}
504
505void
506SBThread::StepOut ()
507{
Greg Claytone005f2c2010-11-06 01:53:30 +0000508 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000509
510 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000511 log->Printf ("SBThread(%p)::StepOut ()", m_opaque_sp.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000512
Greg Clayton63094e02010-06-23 01:19:29 +0000513 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000514 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000515 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Chris Lattner24943d22010-06-08 16:52:24 +0000516 bool abort_other_plans = true;
517 bool stop_other_threads = true;
518
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000519 m_opaque_sp->QueueThreadPlanForStepOut (abort_other_plans,
520 NULL,
521 false,
522 stop_other_threads,
523 eVoteYes,
524 eVoteNoOpinion,
525 0);
526
527 Process &process = m_opaque_sp->GetProcess();
528 process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID());
529 Error error (process.Resume());
530 if (error.Success())
531 {
532 // If we are doing synchronous mode, then wait for the
533 // process to stop yet again!
534 if (process.GetTarget().GetDebugger().GetAsyncExecution () == false)
535 process.WaitForProcessToStop (NULL);
536 }
537 }
538}
Chris Lattner24943d22010-06-08 16:52:24 +0000539
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000540void
541SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame)
542{
543 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
544
545 if (log)
546 {
547 SBStream frame_desc_strm;
548 sb_frame.GetDescription (frame_desc_strm);
549 log->Printf ("SBThread(%p)::StepOutOfFrame (frame = SBFrame(%p): %s)", m_opaque_sp.get(), sb_frame.get(), frame_desc_strm.GetData());
550 }
551
552 if (m_opaque_sp)
553 {
554 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
555 bool abort_other_plans = true;
556 bool stop_other_threads = true;
557
558 m_opaque_sp->QueueThreadPlanForStepOut (abort_other_plans,
559 NULL,
560 false,
561 stop_other_threads,
562 eVoteYes,
563 eVoteNoOpinion,
564 sb_frame->GetFrameIndex());
565
Greg Clayton63094e02010-06-23 01:19:29 +0000566 Process &process = m_opaque_sp->GetProcess();
Jim Inghamc8332952010-08-26 21:32:51 +0000567 process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID());
Greg Clayton1a3083a2010-10-06 03:53:16 +0000568 Error error (process.Resume());
569 if (error.Success())
570 {
571 // If we are doing synchronous mode, then wait for the
572 // process to stop yet again!
573 if (process.GetTarget().GetDebugger().GetAsyncExecution () == false)
574 process.WaitForProcessToStop (NULL);
575 }
Chris Lattner24943d22010-06-08 16:52:24 +0000576 }
577}
578
579void
580SBThread::StepInstruction (bool step_over)
581{
Greg Claytone005f2c2010-11-06 01:53:30 +0000582 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000583
584 if (log)
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000585 log->Printf ("SBThread(%p)::StepInstruction (step_over=%i)", m_opaque_sp.get(), step_over);
Caroline Tice7826c882010-10-26 03:11:13 +0000586
Greg Clayton63094e02010-06-23 01:19:29 +0000587 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000588 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000589 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000590 m_opaque_sp->QueueThreadPlanForStepSingleInstruction (step_over, true, true);
591 Process &process = m_opaque_sp->GetProcess();
Jim Inghamc8332952010-08-26 21:32:51 +0000592 process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID());
Greg Clayton1a3083a2010-10-06 03:53:16 +0000593 Error error (process.Resume());
594 if (error.Success())
595 {
596 // If we are doing synchronous mode, then wait for the
597 // process to stop yet again!
598 if (process.GetTarget().GetDebugger().GetAsyncExecution () == false)
599 process.WaitForProcessToStop (NULL);
600 }
Chris Lattner24943d22010-06-08 16:52:24 +0000601 }
602}
603
604void
605SBThread::RunToAddress (lldb::addr_t addr)
606{
Greg Claytone005f2c2010-11-06 01:53:30 +0000607 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000608
609 if (log)
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000610 log->Printf ("SBThread(%p)::RunToAddress (addr=0x%llx)", m_opaque_sp.get(), addr);
Caroline Tice7826c882010-10-26 03:11:13 +0000611
Greg Clayton63094e02010-06-23 01:19:29 +0000612 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000613 {
614 bool abort_other_plans = true;
615 bool stop_other_threads = true;
616
617 Address target_addr (NULL, addr);
618
Greg Clayton63094e02010-06-23 01:19:29 +0000619 m_opaque_sp->QueueThreadPlanForRunToAddress (abort_other_plans, target_addr, stop_other_threads);
620 Process &process = m_opaque_sp->GetProcess();
Jim Inghamc8332952010-08-26 21:32:51 +0000621 process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID());
Greg Clayton1a3083a2010-10-06 03:53:16 +0000622 Error error (process.Resume());
623 if (error.Success())
624 {
625 // If we are doing synchronous mode, then wait for the
626 // process to stop yet again!
627 if (process.GetTarget().GetDebugger().GetAsyncExecution () == false)
628 process.WaitForProcessToStop (NULL);
629 }
Chris Lattner24943d22010-06-08 16:52:24 +0000630 }
Chris Lattner24943d22010-06-08 16:52:24 +0000631}
632
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000633SBError
634SBThread::StepOverUntil (lldb::SBFrame &sb_frame,
635 lldb::SBFileSpec &sb_file_spec,
636 uint32_t line)
637{
638 SBError sb_error;
639 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
640 char path[PATH_MAX];
641
642 if (log)
643 {
644 SBStream frame_desc_strm;
645 sb_frame.GetDescription (frame_desc_strm);
646 sb_file_spec->GetPath (path, sizeof(path));
647 log->Printf ("SBThread(%p)::StepOverUntil (frame = SBFrame(%p): %s, file+line = %s:%u)",
648 m_opaque_sp.get(),
649 sb_frame.get(),
650 frame_desc_strm.GetData(),
651 path, line);
652 }
653
654 if (m_opaque_sp)
655 {
656 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
657
658 if (line == 0)
659 {
660 sb_error.SetErrorString("invalid line argument");
661 return sb_error;
662 }
663
664 StackFrameSP frame_sp;
665 if (sb_frame.IsValid())
666 frame_sp = sb_frame.get_sp();
667 else
668 {
669 frame_sp = m_opaque_sp->GetSelectedFrame ();
670 if (!frame_sp)
671 frame_sp = m_opaque_sp->GetStackFrameAtIndex (0);
672 }
673
674 SymbolContext frame_sc;
675 if (!frame_sp)
676 {
677 sb_error.SetErrorString("no valid frames in thread to step");
678 return sb_error;
679 }
680
681 // If we have a frame, get its line
682 frame_sc = frame_sp->GetSymbolContext (eSymbolContextCompUnit |
683 eSymbolContextFunction |
684 eSymbolContextLineEntry |
685 eSymbolContextSymbol );
686
687 if (frame_sc.comp_unit == NULL)
688 {
689 sb_error.SetErrorStringWithFormat("frame %u doesn't have debug information", frame_sp->GetFrameIndex());
690 return sb_error;
691 }
692
693 FileSpec step_file_spec;
694 if (sb_file_spec.IsValid())
695 {
696 // The file spec passed in was valid, so use it
697 step_file_spec = sb_file_spec.ref();
698 }
699 else
700 {
701 if (frame_sc.line_entry.IsValid())
702 step_file_spec = frame_sc.line_entry.file;
703 else
704 {
705 sb_error.SetErrorString("invalid file argument or no file for frame");
706 return sb_error;
707 }
708 }
709
Jim Inghamb07c62a2011-05-08 00:56:32 +0000710 // Grab the current function, then we will make sure the "until" address is
711 // within the function. We discard addresses that are out of the current
712 // function, and then if there are no addresses remaining, give an appropriate
713 // error message.
714
715 bool all_in_function = true;
716 AddressRange fun_range = frame_sc.function->GetAddressRange();
717
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000718 std::vector<addr_t> step_over_until_addrs;
719 const bool abort_other_plans = true;
720 const bool stop_other_threads = true;
721 const bool check_inlines = true;
722 const bool exact = false;
Jim Inghamb07c62a2011-05-08 00:56:32 +0000723 Target *target = &m_opaque_sp->GetProcess().GetTarget();
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000724
725 SymbolContextList sc_list;
Jim Inghamb07c62a2011-05-08 00:56:32 +0000726 const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext (step_file_spec,
727 line,
728 check_inlines,
729 exact,
730 eSymbolContextLineEntry,
731 sc_list);
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000732 if (num_matches > 0)
733 {
734 SymbolContext sc;
735 for (uint32_t i=0; i<num_matches; ++i)
736 {
737 if (sc_list.GetContextAtIndex(i, sc))
738 {
Jim Inghamb07c62a2011-05-08 00:56:32 +0000739 addr_t step_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000740 if (step_addr != LLDB_INVALID_ADDRESS)
741 {
Jim Inghamb07c62a2011-05-08 00:56:32 +0000742 if (fun_range.ContainsLoadAddress(step_addr, target))
743 step_over_until_addrs.push_back(step_addr);
744 else
745 all_in_function = false;
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000746 }
747 }
748 }
749 }
Jim Inghamb07c62a2011-05-08 00:56:32 +0000750
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000751 if (step_over_until_addrs.empty())
752 {
Jim Inghamb07c62a2011-05-08 00:56:32 +0000753 if (all_in_function)
754 {
755 step_file_spec.GetPath (path, sizeof(path));
Jason Molenda7e5fa7f2011-09-20 21:44:10 +0000756 sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path, line);
Jim Inghamb07c62a2011-05-08 00:56:32 +0000757 }
758 else
Greg Clayton9c236732011-10-26 00:56:27 +0000759 sb_error.SetErrorString ("step until target not in current function");
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000760 }
761 else
762 {
763 m_opaque_sp->QueueThreadPlanForStepUntil (abort_other_plans,
764 &step_over_until_addrs[0],
765 step_over_until_addrs.size(),
766 stop_other_threads,
767 frame_sp->GetFrameIndex());
768
769 m_opaque_sp->GetProcess().GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID());
770 sb_error.ref() = m_opaque_sp->GetProcess().Resume();
771 if (sb_error->Success())
772 {
773 // If we are doing synchronous mode, then wait for the
774 // process to stop yet again!
775 if (m_opaque_sp->GetProcess().GetTarget().GetDebugger().GetAsyncExecution () == false)
776 m_opaque_sp->GetProcess().WaitForProcessToStop (NULL);
777 }
778 }
779 }
780 else
781 {
782 sb_error.SetErrorString("this SBThread object is invalid");
783 }
784 return sb_error;
785}
786
787
Greg Clayton123db402011-01-12 02:25:42 +0000788bool
789SBThread::Suspend()
790{
791 if (m_opaque_sp)
792 {
793 m_opaque_sp->SetResumeState (eStateSuspended);
794 return true;
795 }
796 return false;
797}
798
799bool
800SBThread::Resume ()
801{
802 if (m_opaque_sp)
803 {
804 m_opaque_sp->SetResumeState (eStateRunning);
805 return true;
806 }
807 return false;
808}
809
810bool
811SBThread::IsSuspended()
812{
813 if (m_opaque_sp)
Greg Claytonf41d4ca2011-01-18 21:43:22 +0000814 return m_opaque_sp->GetResumeState () == eStateSuspended;
Greg Clayton123db402011-01-12 02:25:42 +0000815 return false;
816}
817
Chris Lattner24943d22010-06-08 16:52:24 +0000818SBProcess
819SBThread::GetProcess ()
820{
Caroline Tice7826c882010-10-26 03:11:13 +0000821
Chris Lattner24943d22010-06-08 16:52:24 +0000822 SBProcess process;
Greg Clayton63094e02010-06-23 01:19:29 +0000823 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000824 {
825 // Have to go up to the target so we can get a shared pointer to our process...
Greg Clayton63094e02010-06-23 01:19:29 +0000826 process.SetProcess(m_opaque_sp->GetProcess().GetTarget().GetProcessSP());
Chris Lattner24943d22010-06-08 16:52:24 +0000827 }
Caroline Tice7826c882010-10-26 03:11:13 +0000828
Greg Claytone005f2c2010-11-06 01:53:30 +0000829 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000830 if (log)
831 {
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000832 SBStream frame_desc_strm;
833 process.GetDescription (frame_desc_strm);
Greg Claytona66ba462010-10-30 04:51:46 +0000834 log->Printf ("SBThread(%p)::GetProcess () => SBProcess(%p): %s", m_opaque_sp.get(),
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000835 process.get(), frame_desc_strm.GetData());
Caroline Tice7826c882010-10-26 03:11:13 +0000836 }
837
Chris Lattner24943d22010-06-08 16:52:24 +0000838 return process;
839}
840
841uint32_t
842SBThread::GetNumFrames ()
843{
Greg Claytone005f2c2010-11-06 01:53:30 +0000844 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000845
Caroline Tice7826c882010-10-26 03:11:13 +0000846 uint32_t num_frames = 0;
Greg Clayton63094e02010-06-23 01:19:29 +0000847 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000848 {
849 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Caroline Tice7826c882010-10-26 03:11:13 +0000850 num_frames = m_opaque_sp->GetStackFrameCount();
Greg Claytonbdcda462010-12-20 20:49:23 +0000851 }
Caroline Tice7826c882010-10-26 03:11:13 +0000852
853 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000854 log->Printf ("SBThread(%p)::GetNumFrames () => %u", m_opaque_sp.get(), num_frames);
Caroline Tice7826c882010-10-26 03:11:13 +0000855
856 return num_frames;
Chris Lattner24943d22010-06-08 16:52:24 +0000857}
858
859SBFrame
860SBThread::GetFrameAtIndex (uint32_t idx)
861{
Greg Claytone005f2c2010-11-06 01:53:30 +0000862 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000863
Chris Lattner24943d22010-06-08 16:52:24 +0000864 SBFrame sb_frame;
Greg Clayton63094e02010-06-23 01:19:29 +0000865 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000866 {
867 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000868 sb_frame.SetFrame (m_opaque_sp->GetStackFrameAtIndex (idx));
Greg Claytonbdcda462010-12-20 20:49:23 +0000869 }
Caroline Tice7826c882010-10-26 03:11:13 +0000870
871 if (log)
872 {
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000873 SBStream frame_desc_strm;
874 sb_frame.GetDescription (frame_desc_strm);
Greg Claytona66ba462010-10-30 04:51:46 +0000875 log->Printf ("SBThread(%p)::GetFrameAtIndex (idx=%d) => SBFrame(%p): %s",
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000876 m_opaque_sp.get(), idx, sb_frame.get(), frame_desc_strm.GetData());
Caroline Tice7826c882010-10-26 03:11:13 +0000877 }
878
Chris Lattner24943d22010-06-08 16:52:24 +0000879 return sb_frame;
880}
881
Greg Claytonc5157ec2010-12-17 02:26:24 +0000882lldb::SBFrame
883SBThread::GetSelectedFrame ()
884{
885 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
886
887 SBFrame sb_frame;
888 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000889 {
890 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Greg Claytonc5157ec2010-12-17 02:26:24 +0000891 sb_frame.SetFrame (m_opaque_sp->GetSelectedFrame ());
Greg Claytonbdcda462010-12-20 20:49:23 +0000892 }
Greg Claytonc5157ec2010-12-17 02:26:24 +0000893
894 if (log)
895 {
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000896 SBStream frame_desc_strm;
897 sb_frame.GetDescription (frame_desc_strm);
Greg Claytonc5157ec2010-12-17 02:26:24 +0000898 log->Printf ("SBThread(%p)::GetSelectedFrame () => SBFrame(%p): %s",
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000899 m_opaque_sp.get(), sb_frame.get(), frame_desc_strm.GetData());
Greg Claytonc5157ec2010-12-17 02:26:24 +0000900 }
901
902 return sb_frame;
903}
904
905lldb::SBFrame
906SBThread::SetSelectedFrame (uint32_t idx)
907{
908 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
909
910 SBFrame sb_frame;
911 if (m_opaque_sp)
912 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000913 Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex());
Greg Claytonc5157ec2010-12-17 02:26:24 +0000914 lldb::StackFrameSP frame_sp (m_opaque_sp->GetStackFrameAtIndex (idx));
915 if (frame_sp)
916 {
917 m_opaque_sp->SetSelectedFrame (frame_sp.get());
918 sb_frame.SetFrame (frame_sp);
919 }
920 }
921
922 if (log)
923 {
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000924 SBStream frame_desc_strm;
925 sb_frame.GetDescription (frame_desc_strm);
Greg Claytonc5157ec2010-12-17 02:26:24 +0000926 log->Printf ("SBThread(%p)::SetSelectedFrame (idx=%u) => SBFrame(%p): %s",
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000927 m_opaque_sp.get(), idx, sb_frame.get(), frame_desc_strm.GetData());
Greg Claytonc5157ec2010-12-17 02:26:24 +0000928 }
929 return sb_frame;
930}
931
932
Chris Lattner24943d22010-06-08 16:52:24 +0000933bool
934SBThread::operator == (const SBThread &rhs) const
935{
Greg Clayton63094e02010-06-23 01:19:29 +0000936 return m_opaque_sp.get() == rhs.m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000937}
938
939bool
940SBThread::operator != (const SBThread &rhs) const
941{
Greg Clayton63094e02010-06-23 01:19:29 +0000942 return m_opaque_sp.get() != rhs.m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000943}
944
945lldb_private::Thread *
Greg Claytona66ba462010-10-30 04:51:46 +0000946SBThread::get ()
Chris Lattner24943d22010-06-08 16:52:24 +0000947{
Greg Clayton63094e02010-06-23 01:19:29 +0000948 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000949}
950
951const lldb_private::Thread *
952SBThread::operator->() const
953{
Greg Clayton63094e02010-06-23 01:19:29 +0000954 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000955}
956
957const lldb_private::Thread &
958SBThread::operator*() const
959{
Greg Clayton63094e02010-06-23 01:19:29 +0000960 return *m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000961}
962
963lldb_private::Thread *
964SBThread::operator->()
965{
Greg Clayton63094e02010-06-23 01:19:29 +0000966 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000967}
968
969lldb_private::Thread &
970SBThread::operator*()
971{
Greg Clayton63094e02010-06-23 01:19:29 +0000972 return *m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000973}
Caroline Tice98f930f2010-09-20 05:20:02 +0000974
975bool
Caroline Tice7826c882010-10-26 03:11:13 +0000976SBThread::GetDescription (SBStream &description) const
977{
Greg Clayton96154be2011-11-13 06:57:31 +0000978 Stream &strm = description.ref();
979
Caroline Tice7826c882010-10-26 03:11:13 +0000980 if (m_opaque_sp)
981 {
Greg Clayton96154be2011-11-13 06:57:31 +0000982 strm.Printf("SBThread: tid = 0x%4.4llx", m_opaque_sp->GetID());
Caroline Tice7826c882010-10-26 03:11:13 +0000983 }
984 else
Greg Clayton96154be2011-11-13 06:57:31 +0000985 strm.PutCString ("No value");
Caroline Tice7826c882010-10-26 03:11:13 +0000986
987 return true;
988}