LLDB  mainline
SBThread.cpp
Go to the documentation of this file.
1 //===-- SBThread.cpp --------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/API/SBThread.h"
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBAddress.h"
13 #include "lldb/API/SBDebugger.h"
14 #include "lldb/API/SBEvent.h"
15 #include "lldb/API/SBFileSpec.h"
16 #include "lldb/API/SBFrame.h"
17 #include "lldb/API/SBProcess.h"
18 #include "lldb/API/SBStream.h"
21 #include "lldb/API/SBThreadPlan.h"
22 #include "lldb/API/SBValue.h"
24 #include "lldb/Core/Debugger.h"
25 #include "lldb/Core/StreamFile.h"
26 #include "lldb/Core/ValueObject.h"
30 #include "lldb/Target/Process.h"
31 #include "lldb/Target/Queue.h"
32 #include "lldb/Target/StopInfo.h"
34 #include "lldb/Target/Target.h"
35 #include "lldb/Target/Thread.h"
36 #include "lldb/Target/ThreadPlan.h"
42 #include "lldb/Utility/State.h"
43 #include "lldb/Utility/Stream.h"
45 #include "lldb/lldb-enumerations.h"
46 
47 #include <memory>
48 
49 using namespace lldb;
50 using namespace lldb_private;
51 
54  GetBroadcasterClassName);
55 
56  return Thread::GetStaticBroadcasterClass().AsCString();
57 }
58 
59 // Constructors
60 SBThread::SBThread() : m_opaque_sp(new ExecutionContextRef()) {
62 }
63 
64 SBThread::SBThread(const ThreadSP &lldb_object_sp)
65  : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
66  LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &), lldb_object_sp);
67 }
68 
69 SBThread::SBThread(const SBThread &rhs) : m_opaque_sp() {
71 
72  m_opaque_sp = clone(rhs.m_opaque_sp);
73 }
74 
75 // Assignment operator
76 
79  SBThread, operator=,(const lldb::SBThread &), rhs);
80 
81  if (this != &rhs)
82  m_opaque_sp = clone(rhs.m_opaque_sp);
83  return LLDB_RECORD_RESULT(*this);
84 }
85 
86 // Destructor
88 
91 
92  SBQueue sb_queue;
93  QueueSP queue_sp;
94  std::unique_lock<std::recursive_mutex> lock;
95  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
96 
97  if (exe_ctx.HasThreadScope()) {
98  Process::StopLocker stop_locker;
99  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
100  queue_sp = exe_ctx.GetThreadPtr()->GetQueue();
101  if (queue_sp) {
102  sb_queue.SetQueue(queue_sp);
103  }
104  }
105  }
106 
107  return LLDB_RECORD_RESULT(sb_queue);
108 }
109 
110 bool SBThread::IsValid() const {
112  return this->operator bool();
113 }
114 SBThread::operator bool() const {
115  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, operator bool);
116 
117  std::unique_lock<std::recursive_mutex> lock;
118  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
119 
120  Target *target = exe_ctx.GetTargetPtr();
121  Process *process = exe_ctx.GetProcessPtr();
122  if (target && process) {
123  Process::StopLocker stop_locker;
124  if (stop_locker.TryLock(&process->GetRunLock()))
125  return m_opaque_sp->GetThreadSP().get() != NULL;
126  }
127  // Without a valid target & process, this thread can't be valid.
128  return false;
129 }
130 
133 
134  m_opaque_sp->Clear();
135 }
136 
139 
141  std::unique_lock<std::recursive_mutex> lock;
142  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
143 
144  if (exe_ctx.HasThreadScope()) {
145  Process::StopLocker stop_locker;
146  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
147  return exe_ctx.GetThreadPtr()->GetStopReason();
148  }
149  }
150 
151  return reason;
152 }
153 
156 
157  std::unique_lock<std::recursive_mutex> lock;
158  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
159 
160  if (exe_ctx.HasThreadScope()) {
161  Process::StopLocker stop_locker;
162  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
163  StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
164  if (stop_info_sp) {
165  StopReason reason = stop_info_sp->GetStopReason();
166  switch (reason) {
167  case eStopReasonInvalid:
168  case eStopReasonNone:
169  case eStopReasonTrace:
170  case eStopReasonExec:
174  // There is no data for these stop reasons.
175  return 0;
176 
177  case eStopReasonBreakpoint: {
178  break_id_t site_id = stop_info_sp->GetValue();
179  lldb::BreakpointSiteSP bp_site_sp(
180  exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID(
181  site_id));
182  if (bp_site_sp)
183  return bp_site_sp->GetNumberOfOwners() * 2;
184  else
185  return 0; // Breakpoint must have cleared itself...
186  } break;
187 
189  return 1;
190 
191  case eStopReasonSignal:
192  return 1;
193 
195  return 1;
196  }
197  }
198  }
199  }
200  return 0;
201 }
202 
205  idx);
206 
207  std::unique_lock<std::recursive_mutex> lock;
208  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
209 
210  if (exe_ctx.HasThreadScope()) {
211  Process::StopLocker stop_locker;
212  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
213  Thread *thread = exe_ctx.GetThreadPtr();
214  StopInfoSP stop_info_sp = thread->GetStopInfo();
215  if (stop_info_sp) {
216  StopReason reason = stop_info_sp->GetStopReason();
217  switch (reason) {
218  case eStopReasonInvalid:
219  case eStopReasonNone:
220  case eStopReasonTrace:
221  case eStopReasonExec:
225  // There is no data for these stop reasons.
226  return 0;
227 
228  case eStopReasonBreakpoint: {
229  break_id_t site_id = stop_info_sp->GetValue();
230  lldb::BreakpointSiteSP bp_site_sp(
231  exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID(
232  site_id));
233  if (bp_site_sp) {
234  uint32_t bp_index = idx / 2;
235  BreakpointLocationSP bp_loc_sp(
236  bp_site_sp->GetOwnerAtIndex(bp_index));
237  if (bp_loc_sp) {
238  if (idx & 1) {
239  // Odd idx, return the breakpoint location ID
240  return bp_loc_sp->GetID();
241  } else {
242  // Even idx, return the breakpoint ID
243  return bp_loc_sp->GetBreakpoint().GetID();
244  }
245  }
246  }
247  return LLDB_INVALID_BREAK_ID;
248  } break;
249 
251  return stop_info_sp->GetValue();
252 
253  case eStopReasonSignal:
254  return stop_info_sp->GetValue();
255 
257  return stop_info_sp->GetValue();
258  }
259  }
260  }
261  }
262  return 0;
263 }
264 
267  (lldb::SBStream &), stream);
268 
269  Stream &strm = stream.ref();
270 
271  std::unique_lock<std::recursive_mutex> lock;
272  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
273 
274  if (!exe_ctx.HasThreadScope())
275  return false;
276 
277  StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
278  StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
279  if (!info)
280  return false;
281 
282  info->Dump(strm);
283 
284  return true;
285 }
286 
292 
293  ThreadCollectionSP threads;
294  threads = std::make_shared<ThreadCollection>();
295 
296  std::unique_lock<std::recursive_mutex> lock;
297  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
298 
299  if (!exe_ctx.HasThreadScope())
300  return LLDB_RECORD_RESULT(threads);
301 
302  ProcessSP process_sp = exe_ctx.GetProcessSP();
303 
304  StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
305  StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
306  if (!info)
307  return LLDB_RECORD_RESULT(threads);
308 
309  return LLDB_RECORD_RESULT(process_sp->GetInstrumentationRuntime(type)
310  ->GetBacktracesFromExtendedStopInfo(info));
311 }
312 
313 size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
314  LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t),
315  dst, dst_len);
316 
317  std::unique_lock<std::recursive_mutex> lock;
318  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
319 
320  if (exe_ctx.HasThreadScope()) {
321  Process::StopLocker stop_locker;
322  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
323 
324  StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
325  if (stop_info_sp) {
326  const char *stop_desc = stop_info_sp->GetDescription();
327  if (stop_desc) {
328  if (dst)
329  return ::snprintf(dst, dst_len, "%s", stop_desc);
330  else {
331  // NULL dst passed in, return the length needed to contain the
332  // description
333  return ::strlen(stop_desc) + 1; // Include the NULL byte for size
334  }
335  } else {
336  size_t stop_desc_len = 0;
337  switch (stop_info_sp->GetStopReason()) {
338  case eStopReasonTrace:
340  static char trace_desc[] = "step";
341  stop_desc = trace_desc;
342  stop_desc_len =
343  sizeof(trace_desc); // Include the NULL byte for size
344  } break;
345 
346  case eStopReasonBreakpoint: {
347  static char bp_desc[] = "breakpoint hit";
348  stop_desc = bp_desc;
349  stop_desc_len = sizeof(bp_desc); // Include the NULL byte for size
350  } break;
351 
352  case eStopReasonWatchpoint: {
353  static char wp_desc[] = "watchpoint hit";
354  stop_desc = wp_desc;
355  stop_desc_len = sizeof(wp_desc); // Include the NULL byte for size
356  } break;
357 
358  case eStopReasonSignal: {
359  stop_desc =
360  exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
361  stop_info_sp->GetValue());
362  if (stop_desc == NULL || stop_desc[0] == '\0') {
363  static char signal_desc[] = "signal";
364  stop_desc = signal_desc;
365  stop_desc_len =
366  sizeof(signal_desc); // Include the NULL byte for size
367  }
368  } break;
369 
370  case eStopReasonException: {
371  char exc_desc[] = "exception";
372  stop_desc = exc_desc;
373  stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
374  } break;
375 
376  case eStopReasonExec: {
377  char exc_desc[] = "exec";
378  stop_desc = exc_desc;
379  stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
380  } break;
381 
383  char limbo_desc[] = "thread exiting";
384  stop_desc = limbo_desc;
385  stop_desc_len = sizeof(limbo_desc);
386  } break;
387  default:
388  break;
389  }
390 
391  if (stop_desc && stop_desc[0]) {
392  if (dst)
393  return ::snprintf(dst, dst_len, "%s", stop_desc) +
394  1; // Include the NULL byte
395 
396  if (stop_desc_len == 0)
397  stop_desc_len = ::strlen(stop_desc) + 1; // Include the NULL byte
398 
399  return stop_desc_len;
400  }
401  }
402  }
403  }
404  }
405  if (dst)
406  *dst = 0;
407  return 0;
408 }
409 
412 
413  ValueObjectSP return_valobj_sp;
414  std::unique_lock<std::recursive_mutex> lock;
415  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
416 
417  if (exe_ctx.HasThreadScope()) {
418  Process::StopLocker stop_locker;
419  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
420  StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
421  if (stop_info_sp) {
422  return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp);
423  }
424  }
425  }
426 
427  return LLDB_RECORD_RESULT(SBValue(return_valobj_sp));
428 }
429 
430 void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
431  m_opaque_sp->SetThreadSP(lldb_object_sp);
432 }
433 
436 
437  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
438  if (thread_sp)
439  return thread_sp->GetID();
440  return LLDB_INVALID_THREAD_ID;
441 }
442 
445 
446  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
447  if (thread_sp)
448  return thread_sp->GetIndexID();
449  return LLDB_INVALID_INDEX32;
450 }
451 
452 const char *SBThread::GetName() const {
454 
455  const char *name = NULL;
456  std::unique_lock<std::recursive_mutex> lock;
457  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
458 
459  if (exe_ctx.HasThreadScope()) {
460  Process::StopLocker stop_locker;
461  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
462  name = exe_ctx.GetThreadPtr()->GetName();
463  }
464  }
465 
466  return name;
467 }
468 
469 const char *SBThread::GetQueueName() const {
471 
472  const char *name = NULL;
473  std::unique_lock<std::recursive_mutex> lock;
474  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
475 
476  if (exe_ctx.HasThreadScope()) {
477  Process::StopLocker stop_locker;
478  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
479  name = exe_ctx.GetThreadPtr()->GetQueueName();
480  }
481  }
482 
483  return name;
484 }
485 
488 
490  std::unique_lock<std::recursive_mutex> lock;
491  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
492 
493  if (exe_ctx.HasThreadScope()) {
494  Process::StopLocker stop_locker;
495  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
496  id = exe_ctx.GetThreadPtr()->GetQueueID();
497  }
498  }
499 
500  return id;
501 }
502 
503 bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
505  (const char *, lldb::SBStream &), path, strm);
506 
507  bool success = false;
508  std::unique_lock<std::recursive_mutex> lock;
509  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
510 
511  if (exe_ctx.HasThreadScope()) {
512  Process::StopLocker stop_locker;
513  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
514  Thread *thread = exe_ctx.GetThreadPtr();
515  StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
516  if (info_root_sp) {
518  info_root_sp->GetObjectForDotSeparatedPath(path);
519  if (node) {
520  if (node->GetType() == eStructuredDataTypeString) {
521  strm.Printf("%s", node->GetAsString()->GetValue().str().c_str());
522  success = true;
523  }
524  if (node->GetType() == eStructuredDataTypeInteger) {
525  strm.Printf("0x%" PRIx64, node->GetAsInteger()->GetValue());
526  success = true;
527  }
528  if (node->GetType() == eStructuredDataTypeFloat) {
529  strm.Printf("0x%f", node->GetAsFloat()->GetValue());
530  success = true;
531  }
532  if (node->GetType() == eStructuredDataTypeBoolean) {
533  if (node->GetAsBoolean()->GetValue())
534  strm.Printf("true");
535  else
536  strm.Printf("false");
537  success = true;
538  }
539  if (node->GetType() == eStructuredDataTypeNull) {
540  strm.Printf("null");
541  success = true;
542  }
543  }
544  }
545  }
546  }
547 
548  return success;
549 }
550 
551 SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
552  ThreadPlan *new_plan) {
553  SBError sb_error;
554 
555  Process *process = exe_ctx.GetProcessPtr();
556  if (!process) {
557  sb_error.SetErrorString("No process in SBThread::ResumeNewPlan");
558  return sb_error;
559  }
560 
561  Thread *thread = exe_ctx.GetThreadPtr();
562  if (!thread) {
563  sb_error.SetErrorString("No thread in SBThread::ResumeNewPlan");
564  return sb_error;
565  }
566 
567  // User level plans should be Master Plans so they can be interrupted, other
568  // plans executed, and then a "continue" will resume the plan.
569  if (new_plan != NULL) {
570  new_plan->SetIsMasterPlan(true);
571  new_plan->SetOkayToDiscard(false);
572  }
573 
574  // Why do we need to set the current thread by ID here???
575  process->GetThreadList().SetSelectedThreadByID(thread->GetID());
576 
577  if (process->GetTarget().GetDebugger().GetAsyncExecution())
578  sb_error.ref() = process->Resume();
579  else
580  sb_error.ref() = process->ResumeSynchronous(NULL);
581 
582  return sb_error;
583 }
584 
585 void SBThread::StepOver(lldb::RunMode stop_other_threads) {
587  stop_other_threads);
588 
589  SBError error; // Ignored
590  StepOver(stop_other_threads, error);
591 }
592 
593 void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
595  stop_other_threads, error);
596 
597  std::unique_lock<std::recursive_mutex> lock;
598  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
599 
600  if (!exe_ctx.HasThreadScope()) {
601  error.SetErrorString("this SBThread object is invalid");
602  return;
603  }
604 
605  Thread *thread = exe_ctx.GetThreadPtr();
606  bool abort_other_plans = false;
607  StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
608 
609  Status new_plan_status;
610  ThreadPlanSP new_plan_sp;
611  if (frame_sp) {
612  if (frame_sp->HasDebugInformation()) {
613  const LazyBool avoid_no_debug = eLazyBoolCalculate;
614  SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
615  new_plan_sp = thread->QueueThreadPlanForStepOverRange(
616  abort_other_plans, sc.line_entry, sc, stop_other_threads,
617  new_plan_status, avoid_no_debug);
618  } else {
619  new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
620  true, abort_other_plans, stop_other_threads, new_plan_status);
621  }
622  }
623  error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
624 }
625 
626 void SBThread::StepInto(lldb::RunMode stop_other_threads) {
628  stop_other_threads);
629 
630  StepInto(NULL, stop_other_threads);
631 }
632 
633 void SBThread::StepInto(const char *target_name,
634  lldb::RunMode stop_other_threads) {
635  LLDB_RECORD_METHOD(void, SBThread, StepInto, (const char *, lldb::RunMode),
636  target_name, stop_other_threads);
637 
638  SBError error; // Ignored
639  StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
640 }
641 
642 void SBThread::StepInto(const char *target_name, uint32_t end_line,
643  SBError &error, lldb::RunMode stop_other_threads) {
645  (const char *, uint32_t, lldb::SBError &, lldb::RunMode),
646  target_name, end_line, error, stop_other_threads);
647 
648 
649  std::unique_lock<std::recursive_mutex> lock;
650  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
651 
652  if (!exe_ctx.HasThreadScope()) {
653  error.SetErrorString("this SBThread object is invalid");
654  return;
655  }
656 
657  bool abort_other_plans = false;
658 
659  Thread *thread = exe_ctx.GetThreadPtr();
660  StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
661  ThreadPlanSP new_plan_sp;
662  Status new_plan_status;
663 
664  if (frame_sp && frame_sp->HasDebugInformation()) {
665  SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
666  AddressRange range;
667  if (end_line == LLDB_INVALID_LINE_NUMBER)
668  range = sc.line_entry.range;
669  else {
670  if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
671  return;
672  }
673 
674  const LazyBool step_out_avoids_code_without_debug_info =
676  const LazyBool step_in_avoids_code_without_debug_info =
678  new_plan_sp = thread->QueueThreadPlanForStepInRange(
679  abort_other_plans, range, sc, target_name, stop_other_threads,
680  new_plan_status, step_in_avoids_code_without_debug_info,
681  step_out_avoids_code_without_debug_info);
682  } else {
683  new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
684  false, abort_other_plans, stop_other_threads, new_plan_status);
685  }
686 
687  if (new_plan_status.Success())
688  error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
689  else
690  error.SetErrorString(new_plan_status.AsCString());
691 }
692 
695 
696  SBError error; // Ignored
697  StepOut(error);
698 }
699 
701  LLDB_RECORD_METHOD(void, SBThread, StepOut, (lldb::SBError &), error);
702 
703  std::unique_lock<std::recursive_mutex> lock;
704  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
705 
706  if (!exe_ctx.HasThreadScope()) {
707  error.SetErrorString("this SBThread object is invalid");
708  return;
709  }
710 
711  bool abort_other_plans = false;
712  bool stop_other_threads = false;
713 
714  Thread *thread = exe_ctx.GetThreadPtr();
715 
716  const LazyBool avoid_no_debug = eLazyBoolCalculate;
717  Status new_plan_status;
718  ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
719  abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
720  eVoteNoOpinion, 0, new_plan_status, avoid_no_debug));
721 
722  if (new_plan_status.Success())
723  error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
724  else
725  error.SetErrorString(new_plan_status.AsCString());
726 }
727 
730  sb_frame);
731 
732  SBError error; // Ignored
733  StepOutOfFrame(sb_frame, error);
734 }
735 
736 void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) {
738  (lldb::SBFrame &, lldb::SBError &), sb_frame, error);
739 
740 
741  std::unique_lock<std::recursive_mutex> lock;
742  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
743 
744  if (!sb_frame.IsValid()) {
745  error.SetErrorString("passed invalid SBFrame object");
746  return;
747  }
748 
749  StackFrameSP frame_sp(sb_frame.GetFrameSP());
750 
751  if (!exe_ctx.HasThreadScope()) {
752  error.SetErrorString("this SBThread object is invalid");
753  return;
754  }
755 
756  bool abort_other_plans = false;
757  bool stop_other_threads = false;
758  Thread *thread = exe_ctx.GetThreadPtr();
759  if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
760  error.SetErrorString("passed a frame from another thread");
761  return;
762  }
763 
764  Status new_plan_status;
765  ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
766  abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
767  eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status));
768 
769  if (new_plan_status.Success())
770  error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
771  else
772  error.SetErrorString(new_plan_status.AsCString());
773 }
774 
775 void SBThread::StepInstruction(bool step_over) {
776  LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool), step_over);
777 
778  SBError error; // Ignored
779  StepInstruction(step_over, error);
780 }
781 
782 void SBThread::StepInstruction(bool step_over, SBError &error) {
784  step_over, error);
785 
786  std::unique_lock<std::recursive_mutex> lock;
787  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
788 
789  if (!exe_ctx.HasThreadScope()) {
790  error.SetErrorString("this SBThread object is invalid");
791  return;
792  }
793 
794  Thread *thread = exe_ctx.GetThreadPtr();
795  Status new_plan_status;
796  ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepSingleInstruction(
797  step_over, true, true, new_plan_status));
798 
799  if (new_plan_status.Success())
800  error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
801  else
802  error.SetErrorString(new_plan_status.AsCString());
803 }
804 
807 
808  SBError error; // Ignored
809  RunToAddress(addr, error);
810 }
811 
814  (lldb::addr_t, lldb::SBError &), addr, error);
815 
816  std::unique_lock<std::recursive_mutex> lock;
817  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
818 
819  if (!exe_ctx.HasThreadScope()) {
820  error.SetErrorString("this SBThread object is invalid");
821  return;
822  }
823 
824  bool abort_other_plans = false;
825  bool stop_other_threads = true;
826 
827  Address target_addr(addr);
828 
829  Thread *thread = exe_ctx.GetThreadPtr();
830 
831  Status new_plan_status;
832  ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress(
833  abort_other_plans, target_addr, stop_other_threads, new_plan_status));
834 
835  if (new_plan_status.Success())
836  error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
837  else
838  error.SetErrorString(new_plan_status.AsCString());
839 }
840 
842  lldb::SBFileSpec &sb_file_spec, uint32_t line) {
844  (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t), sb_frame,
845  sb_file_spec, line);
846 
847  SBError sb_error;
848  char path[PATH_MAX];
849 
850  std::unique_lock<std::recursive_mutex> lock;
851  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
852 
853  StackFrameSP frame_sp(sb_frame.GetFrameSP());
854 
855  if (exe_ctx.HasThreadScope()) {
856  Target *target = exe_ctx.GetTargetPtr();
857  Thread *thread = exe_ctx.GetThreadPtr();
858 
859  if (line == 0) {
860  sb_error.SetErrorString("invalid line argument");
861  return LLDB_RECORD_RESULT(sb_error);
862  }
863 
864  if (!frame_sp) {
865  frame_sp = thread->GetSelectedFrame();
866  if (!frame_sp)
867  frame_sp = thread->GetStackFrameAtIndex(0);
868  }
869 
870  SymbolContext frame_sc;
871  if (!frame_sp) {
872  sb_error.SetErrorString("no valid frames in thread to step");
873  return LLDB_RECORD_RESULT(sb_error);
874  }
875 
876  // If we have a frame, get its line
877  frame_sc = frame_sp->GetSymbolContext(
878  eSymbolContextCompUnit | eSymbolContextFunction |
879  eSymbolContextLineEntry | eSymbolContextSymbol);
880 
881  if (frame_sc.comp_unit == NULL) {
882  sb_error.SetErrorStringWithFormat(
883  "frame %u doesn't have debug information", frame_sp->GetFrameIndex());
884  return LLDB_RECORD_RESULT(sb_error);
885  }
886 
887  FileSpec step_file_spec;
888  if (sb_file_spec.IsValid()) {
889  // The file spec passed in was valid, so use it
890  step_file_spec = sb_file_spec.ref();
891  } else {
892  if (frame_sc.line_entry.IsValid())
893  step_file_spec = frame_sc.line_entry.file;
894  else {
895  sb_error.SetErrorString("invalid file argument or no file for frame");
896  return LLDB_RECORD_RESULT(sb_error);
897  }
898  }
899 
900  // Grab the current function, then we will make sure the "until" address is
901  // within the function. We discard addresses that are out of the current
902  // function, and then if there are no addresses remaining, give an
903  // appropriate error message.
904 
905  bool all_in_function = true;
906  AddressRange fun_range = frame_sc.function->GetAddressRange();
907 
908  std::vector<addr_t> step_over_until_addrs;
909  const bool abort_other_plans = false;
910  const bool stop_other_threads = false;
911  const bool check_inlines = true;
912  const bool exact = false;
913 
914  SymbolContextList sc_list;
915  const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext(
916  step_file_spec, line, check_inlines, exact, eSymbolContextLineEntry,
917  sc_list);
918  if (num_matches > 0) {
919  SymbolContext sc;
920  for (uint32_t i = 0; i < num_matches; ++i) {
921  if (sc_list.GetContextAtIndex(i, sc)) {
922  addr_t step_addr =
924  if (step_addr != LLDB_INVALID_ADDRESS) {
925  if (fun_range.ContainsLoadAddress(step_addr, target))
926  step_over_until_addrs.push_back(step_addr);
927  else
928  all_in_function = false;
929  }
930  }
931  }
932  }
933 
934  if (step_over_until_addrs.empty()) {
935  if (all_in_function) {
936  step_file_spec.GetPath(path, sizeof(path));
937  sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path,
938  line);
939  } else
940  sb_error.SetErrorString("step until target not in current function");
941  } else {
942  Status new_plan_status;
943  ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil(
944  abort_other_plans, &step_over_until_addrs[0],
945  step_over_until_addrs.size(), stop_other_threads,
946  frame_sp->GetFrameIndex(), new_plan_status));
947 
948  if (new_plan_status.Success())
949  sb_error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
950  else
951  sb_error.SetErrorString(new_plan_status.AsCString());
952  }
953  } else {
954  sb_error.SetErrorString("this SBThread object is invalid");
955  }
956  return LLDB_RECORD_RESULT(sb_error);
957 }
958 
959 SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
961  (const char *), script_class_name);
962 
963  return LLDB_RECORD_RESULT(
964  StepUsingScriptedThreadPlan(script_class_name, true));
965 }
966 
967 SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
968  bool resume_immediately) {
970  (const char *, bool), script_class_name,
971  resume_immediately);
972 
973  SBError error;
974 
975  std::unique_lock<std::recursive_mutex> lock;
976  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
977 
978  if (!exe_ctx.HasThreadScope()) {
979  error.SetErrorString("this SBThread object is invalid");
980  return LLDB_RECORD_RESULT(error);
981  }
982 
983  Thread *thread = exe_ctx.GetThreadPtr();
984  Status new_plan_status;
985  ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
986  false, script_class_name, false, new_plan_status);
987 
988  if (new_plan_status.Fail()) {
989  error.SetErrorString(new_plan_status.AsCString());
990  return LLDB_RECORD_RESULT(error);
991  }
992 
993  if (!resume_immediately)
994  return LLDB_RECORD_RESULT(error);
995 
996  if (new_plan_status.Success())
997  error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
998  else
999  error.SetErrorString(new_plan_status.AsCString());
1000 
1001  return LLDB_RECORD_RESULT(error);
1002 }
1003 
1006  (lldb::SBFileSpec &, uint32_t), file_spec, line);
1007 
1008  SBError sb_error;
1009 
1010  std::unique_lock<std::recursive_mutex> lock;
1011  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1012 
1013  if (!exe_ctx.HasThreadScope()) {
1014  sb_error.SetErrorString("this SBThread object is invalid");
1015  return LLDB_RECORD_RESULT(sb_error);
1016  }
1017 
1018  Thread *thread = exe_ctx.GetThreadPtr();
1019 
1020  Status err = thread->JumpToLine(file_spec.get(), line, true);
1021  sb_error.SetError(err);
1022  return LLDB_RECORD_RESULT(sb_error);
1023 }
1024 
1027  (lldb::SBFrame &, lldb::SBValue &), frame, return_value);
1028 
1029  SBError sb_error;
1030 
1031  std::unique_lock<std::recursive_mutex> lock;
1032  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1033 
1034  if (exe_ctx.HasThreadScope()) {
1035  Thread *thread = exe_ctx.GetThreadPtr();
1036  sb_error.SetError(
1037  thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
1038  }
1039 
1040  return LLDB_RECORD_RESULT(sb_error);
1041 }
1042 
1046 
1047  SBError sb_error;
1048 
1049  std::unique_lock<std::recursive_mutex> lock;
1050  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1051 
1052  if (exe_ctx.HasThreadScope()) {
1053  Thread *thread = exe_ctx.GetThreadPtr();
1054  sb_error.SetError(thread->UnwindInnermostExpression());
1055  if (sb_error.Success())
1056  thread->SetSelectedFrameByIndex(0, false);
1057  }
1058 
1059  return LLDB_RECORD_RESULT(sb_error);
1060 }
1061 
1064 
1065  SBError error; // Ignored
1066  return Suspend(error);
1067 }
1068 
1070  LLDB_RECORD_METHOD(bool, SBThread, Suspend, (lldb::SBError &), error);
1071 
1072  std::unique_lock<std::recursive_mutex> lock;
1073  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1074 
1075  bool result = false;
1076  if (exe_ctx.HasThreadScope()) {
1077  Process::StopLocker stop_locker;
1078  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1080  result = true;
1081  } else {
1082  error.SetErrorString("process is running");
1083  }
1084  } else
1085  error.SetErrorString("this SBThread object is invalid");
1086  return result;
1087 }
1088 
1091 
1092  SBError error; // Ignored
1093  return Resume(error);
1094 }
1095 
1097  LLDB_RECORD_METHOD(bool, SBThread, Resume, (lldb::SBError &), error);
1098 
1099  std::unique_lock<std::recursive_mutex> lock;
1100  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1101 
1102  bool result = false;
1103  if (exe_ctx.HasThreadScope()) {
1104  Process::StopLocker stop_locker;
1105  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1106  const bool override_suspend = true;
1107  exe_ctx.GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
1108  result = true;
1109  } else {
1110  error.SetErrorString("process is running");
1111  }
1112  } else
1113  error.SetErrorString("this SBThread object is invalid");
1114  return result;
1115 }
1116 
1119 
1120  std::unique_lock<std::recursive_mutex> lock;
1121  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1122 
1123  if (exe_ctx.HasThreadScope())
1124  return exe_ctx.GetThreadPtr()->GetResumeState() == eStateSuspended;
1125  return false;
1126 }
1127 
1130 
1131  std::unique_lock<std::recursive_mutex> lock;
1132  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1133 
1134  if (exe_ctx.HasThreadScope())
1135  return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
1136  return false;
1137 }
1138 
1141 
1142  SBProcess sb_process;
1143  std::unique_lock<std::recursive_mutex> lock;
1144  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1145 
1146  if (exe_ctx.HasThreadScope()) {
1147  // Have to go up to the target so we can get a shared pointer to our
1148  // process...
1149  sb_process.SetSP(exe_ctx.GetProcessSP());
1150  }
1151 
1152  return LLDB_RECORD_RESULT(sb_process);
1153 }
1154 
1157 
1158  uint32_t num_frames = 0;
1159  std::unique_lock<std::recursive_mutex> lock;
1160  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1161 
1162  if (exe_ctx.HasThreadScope()) {
1163  Process::StopLocker stop_locker;
1164  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1165  num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
1166  }
1167  }
1168 
1169  return num_frames;
1170 }
1171 
1174 
1175  SBFrame sb_frame;
1176  StackFrameSP frame_sp;
1177  std::unique_lock<std::recursive_mutex> lock;
1178  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1179 
1180  if (exe_ctx.HasThreadScope()) {
1181  Process::StopLocker stop_locker;
1182  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1183  frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(idx);
1184  sb_frame.SetFrameSP(frame_sp);
1185  }
1186  }
1187 
1188  return LLDB_RECORD_RESULT(sb_frame);
1189 }
1190 
1193 
1194  SBFrame sb_frame;
1195  StackFrameSP frame_sp;
1196  std::unique_lock<std::recursive_mutex> lock;
1197  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1198 
1199  if (exe_ctx.HasThreadScope()) {
1200  Process::StopLocker stop_locker;
1201  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1202  frame_sp = exe_ctx.GetThreadPtr()->GetSelectedFrame();
1203  sb_frame.SetFrameSP(frame_sp);
1204  }
1205  }
1206 
1207  return LLDB_RECORD_RESULT(sb_frame);
1208 }
1209 
1212  idx);
1213 
1214  SBFrame sb_frame;
1215  StackFrameSP frame_sp;
1216  std::unique_lock<std::recursive_mutex> lock;
1217  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1218 
1219  if (exe_ctx.HasThreadScope()) {
1220  Process::StopLocker stop_locker;
1221  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1222  Thread *thread = exe_ctx.GetThreadPtr();
1223  frame_sp = thread->GetStackFrameAtIndex(idx);
1224  if (frame_sp) {
1225  thread->SetSelectedFrame(frame_sp.get());
1226  sb_frame.SetFrameSP(frame_sp);
1227  }
1228  }
1229  }
1230 
1231  return LLDB_RECORD_RESULT(sb_frame);
1232 }
1233 
1236  (const lldb::SBEvent &), event);
1237 
1238  return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != NULL;
1239 }
1240 
1243  (const lldb::SBEvent &), event);
1244 
1245  return LLDB_RECORD_RESULT(
1246  Thread::ThreadEventData::GetStackFrameFromEvent(event.get()));
1247 }
1248 
1251  (const lldb::SBEvent &), event);
1252 
1253  return LLDB_RECORD_RESULT(
1254  Thread::ThreadEventData::GetThreadFromEvent(event.get()));
1255 }
1256 
1257 bool SBThread::operator==(const SBThread &rhs) const {
1258  LLDB_RECORD_METHOD_CONST(bool, SBThread, operator==,(const lldb::SBThread &),
1259  rhs);
1260 
1261  return m_opaque_sp->GetThreadSP().get() ==
1262  rhs.m_opaque_sp->GetThreadSP().get();
1263 }
1264 
1265 bool SBThread::operator!=(const SBThread &rhs) const {
1266  LLDB_RECORD_METHOD_CONST(bool, SBThread, operator!=,(const lldb::SBThread &),
1267  rhs);
1268 
1269  return m_opaque_sp->GetThreadSP().get() !=
1270  rhs.m_opaque_sp->GetThreadSP().get();
1271 }
1272 
1273 bool SBThread::GetStatus(SBStream &status) const {
1275  status);
1276 
1277  Stream &strm = status.ref();
1278 
1279  std::unique_lock<std::recursive_mutex> lock;
1280  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1281 
1282  if (exe_ctx.HasThreadScope()) {
1283  exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true);
1284  } else
1285  strm.PutCString("No status");
1286 
1287  return true;
1288 }
1289 
1290 bool SBThread::GetDescription(SBStream &description) const {
1292  description);
1293 
1294  return GetDescription(description, false);
1295 }
1296 
1297 bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
1299  (lldb::SBStream &, bool), description, stop_format);
1300 
1301  Stream &strm = description.ref();
1302 
1303  std::unique_lock<std::recursive_mutex> lock;
1304  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1305 
1306  if (exe_ctx.HasThreadScope()) {
1307  exe_ctx.GetThreadPtr()->DumpUsingSettingsFormat(strm,
1309  stop_format);
1310  // strm.Printf("SBThread: tid = 0x%4.4" PRIx64,
1311  // exe_ctx.GetThreadPtr()->GetID());
1312  } else
1313  strm.PutCString("No value");
1314 
1315  return true;
1316 }
1317 
1320  (const char *), type);
1321 
1322  std::unique_lock<std::recursive_mutex> lock;
1323  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1324  SBThread sb_origin_thread;
1325 
1326  Process::StopLocker stop_locker;
1327  if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1328  if (exe_ctx.HasThreadScope()) {
1329  ThreadSP real_thread(exe_ctx.GetThreadSP());
1330  if (real_thread) {
1331  ConstString type_const(type);
1332  Process *process = exe_ctx.GetProcessPtr();
1333  if (process) {
1334  SystemRuntime *runtime = process->GetSystemRuntime();
1335  if (runtime) {
1336  ThreadSP new_thread_sp(
1337  runtime->GetExtendedBacktraceThread(real_thread, type_const));
1338  if (new_thread_sp) {
1339  // Save this in the Process' ExtendedThreadList so a strong
1340  // pointer retains the object.
1341  process->GetExtendedThreadList().AddThread(new_thread_sp);
1342  sb_origin_thread.SetThread(new_thread_sp);
1343  }
1344  }
1345  }
1346  }
1347  }
1348  }
1349 
1350  return LLDB_RECORD_RESULT(sb_origin_thread);
1351 }
1352 
1356 
1357  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1358  if (thread_sp)
1359  return thread_sp->GetExtendedBacktraceOriginatingIndexID();
1360  return LLDB_INVALID_INDEX32;
1361 }
1362 
1365 
1366  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1367  if (!thread_sp)
1368  return LLDB_RECORD_RESULT(SBValue());
1369 
1370  return LLDB_RECORD_RESULT(SBValue(thread_sp->GetCurrentException()));
1371 }
1372 
1376 
1377  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1378  if (!thread_sp)
1379  return LLDB_RECORD_RESULT(SBThread());
1380 
1381  return LLDB_RECORD_RESULT(
1382  SBThread(thread_sp->GetCurrentExceptionBacktrace()));
1383 }
1384 
1387 
1388  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1389  if (thread_sp)
1390  return thread_sp->SafeToCallFunctions();
1391  return true;
1392 }
1393 
1394 lldb_private::Thread *SBThread::operator->() {
1395  return get();
1396 }
1397 
1398 lldb_private::Thread *SBThread::get() {
1399  return m_opaque_sp->GetThreadSP().get();
1400 }
1401 
1402 namespace lldb_private {
1403 namespace repro {
1404 
1405 template <>
1408  ());
1410  LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &));
1413  SBThread, operator=,(const lldb::SBThread &));
1416  LLDB_REGISTER_METHOD_CONST(bool, SBThread, operator bool, ());
1417  LLDB_REGISTER_METHOD(void, SBThread, Clear, ());
1421  (uint32_t));
1423  (lldb::SBStream &));
1428  (char *, size_t));
1432  LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetName, ());
1433  LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetQueueName, ());
1436  (const char *, lldb::SBStream &));
1442  (const char *, lldb::RunMode));
1444  void, SBThread, StepInto,
1445  (const char *, uint32_t, lldb::SBError &, lldb::RunMode));
1450  (lldb::SBFrame &, lldb::SBError &));
1453  (bool, lldb::SBError &));
1460  (const char *));
1462  (const char *, bool));
1464  (lldb::SBFileSpec &, uint32_t));
1466  (lldb::SBFrame &, lldb::SBValue &));
1468  ());
1471  LLDB_REGISTER_METHOD(bool, SBThread, Resume, ());
1481  (const lldb::SBEvent &));
1483  (const lldb::SBEvent &));
1485  (const lldb::SBEvent &));
1487  SBThread, operator==,(const lldb::SBThread &));
1489  SBThread, operator!=,(const lldb::SBThread &));
1492  (lldb::SBStream &));
1494  (lldb::SBStream &, bool));
1496  (const char *));
1501  ());
1503 }
1504 
1505 }
1506 }
void SetOkayToDiscard(bool value)
Definition: ThreadPlan.h:444
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
void StepOut()
Definition: SBThread.cpp:693
bool Suspend()
LLDB currently supports process centric debugging which means when any thread in a process stops...
Definition: SBThread.cpp:1062
StructuredData::ObjectSP GetExtendedInfo()
Retrieve a dictionary of information about this thread.
Definition: Thread.h:269
The registry contains a unique mapping between functions and their ID.
static const char * GetBroadcasterClassName()
Definition: SBThread.cpp:52
lldb::StackFrameSP GetSelectedFrame()
Definition: Thread.cpp:317
ThreadList & GetExtendedThreadList()
Definition: Process.h:2051
bool HasThreadScope() const
Returns true the ExecutionContext object contains a valid target, process, and thread.
Defines a list of symbol context objects.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
lldb::SBProcess GetProcess()
Definition: SBThread.cpp:1139
int32_t break_id_t
Definition: lldb-types.h:88
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
lldb::StateType GetResumeState() const
Gets the USER resume state for this thread.
Definition: Thread.h:200
bool IsStopped()
Definition: SBThread.cpp:1128
Status UnwindInnermostExpression()
Unwinds the thread stack for the innermost expression plan currently on the thread plan stack...
Definition: Thread.cpp:1347
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition: SBFrame.cpp:88
void SetSP(const lldb::ProcessSP &process_sp)
Definition: SBProcess.cpp:108
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:292
bool Success() const
Definition: SBError.cpp:65
bool IsValid() const
Check if a line entry object is valid.
Definition: LineEntry.cpp:47
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition: SBError.cpp:131
#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature,...)
void SetResumeState(lldb::StateType state, bool override_suspend=false)
Sets the USER resume state for this thread.
Definition: Thread.h:186
friend class SBValue
Definition: SBThread.h:212
#define LLDB_RECORD_STATIC_METHOD_NO_ARGS(Result, Class, Method)
uint32_t GetExtendedBacktraceOriginatingIndexID()
Definition: SBThread.cpp:1353
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:49
A file utility class.
Definition: FileSpec.h:55
void RunToAddress(lldb::addr_t addr)
Definition: SBThread.cpp:805
ThreadList & GetThreadList()
Definition: Process.h:2045
bool GetStatus(lldb::SBStream &status) const
Definition: SBThread.cpp:1273
virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange(bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, const char *step_in_target, lldb::RunMode stop_other_threads, Status &status, LazyBool step_in_avoids_code_without_debug_info=eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queues the plan used to step through an address range, stepping into functions.
Definition: Thread.cpp:1406
#define LLDB_INVALID_QUEUE_ID
Definition: lldb-defines.h:98
Status ResumeSynchronous(Stream *stream)
Definition: Process.cpp:1406
CompileUnit * comp_unit
The CompileUnit for a given query.
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:97
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool operator!=(const lldb::SBThread &rhs) const
Definition: SBThread.cpp:1265
void StepInto(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition: SBThread.cpp:626
bool IsSuspended()
Definition: SBThread.cpp:1117
const char * GetQueueName() const
Definition: SBThread.cpp:469
lldb::StateType GetState() const
Definition: Thread.cpp:581
lldb_private::Event * get() const
Definition: SBEvent.cpp:141
lldb::SBFrame GetFrameAtIndex(uint32_t idx)
Definition: SBThread.cpp:1172
virtual lldb::ThreadPlanSP QueueThreadPlanForStepSingleInstruction(bool step_over, bool abort_other_plans, bool stop_other_threads, Status &status)
Queues the plan used to step one instruction from the current PC of thread.
Definition: Thread.cpp:1370
static SBFrame GetStackFrameFromEvent(const SBEvent &event)
Definition: SBThread.cpp:1241
uint64_t GetStopReasonDataAtIndex(uint32_t idx)
Get information associated with a stop reason.
Definition: SBThread.cpp:203
#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature)
SBError UnwindInnermostExpression()
Definition: SBThread.cpp:1043
bool GetInfoItemByPathAsString(const char *path, SBStream &strm)
Definition: SBThread.cpp:503
void SetErrorString(const char *err_str)
Definition: SBError.cpp:124
const lldb::SBThread & operator=(const lldb::SBThread &rhs)
Definition: SBThread.cpp:77
lldb::ValueObjectSP GetSP() const
Same as the protected version of GetSP that takes a locker, except that we make the locker locally in...
Definition: SBValue.cpp:1108
SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec, uint32_t line)
Definition: SBThread.cpp:841
bool IsValid() const
Definition: SBFileSpec.cpp:79
void SetQueue(const lldb::QueueSP &queue_sp)
Definition: SBQueue.cpp:264
SBValue GetStopReturnValue()
Definition: SBThread.cpp:410
bool ContainsLoadAddress(const Address &so_addr, Target *target) const
Check if a section offset so_addr when represented as a load address is contained within this object&#39;...
Target * GetTargetPtr() const
Returns a pointer to the target object.
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
bool GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream)
Definition: SBThread.cpp:265
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
bool IsValid() const
Definition: SBThread.cpp:110
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:86
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
Definition: State.cpp:89
size_t GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format, bool only_stacks=false)
Definition: Thread.cpp:1908
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
Definition: Thread.cpp:1740
lldb_private::Status & ref()
Definition: SBError.cpp:159
lldb::queue_id_t GetQueueID() const
Definition: SBThread.cpp:486
lldb::SBFrame SetSelectedFrame(uint32_t frame_idx)
Definition: SBThread.cpp:1210
InstrumentationRuntimeType
lldb::tid_t GetThreadID() const
Definition: SBThread.cpp:434
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
void RegisterMethods< SBThread >(Registry &R)
Definition: SBThread.cpp:1406
void Printf(const char *format,...) __attribute__((format(printf
Definition: SBStream.cpp:62
bool IsValid() const
Definition: SBFrame.cpp:92
const char * GetName() const
Definition: SBThread.cpp:452
uint64_t tid_t
Definition: lldb-types.h:86
uint32_t GetNumFrames()
Definition: SBThread.cpp:1155
SBThread GetExtendedBacktraceThread(const char *type)
Definition: SBThread.cpp:1318
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
virtual lldb::ThreadSP GetExtendedBacktraceThread(lldb::ThreadSP thread, ConstString type)
Return a Thread which shows the origin of this thread&#39;s creation.
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:151
SBValue GetCurrentException()
Definition: SBThread.cpp:1363
uint32_t GetIndexID() const
Definition: SBThread.cpp:443
size_t GetStopReasonDataCount()
Get the number of words associated with the stop reason.
Definition: SBThread.cpp:154
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
Process * GetProcessPtr() const
Returns a pointer to the process object.
void StepOutOfFrame(SBFrame &frame)
Definition: SBThread.cpp:728
lldb::SBQueue GetQueue() const
Definition: SBThread.cpp:89
SBError StepUsingScriptedThreadPlan(const char *script_class_name)
Definition: SBThread.cpp:959
Status Resume()
Resumes all of a process&#39;s threads as configured using the Thread run control functions.
Definition: Process.cpp:1385
static SBThread GetThreadFromEvent(const SBEvent &event)
Definition: SBThread.cpp:1249
bool Success() const
Test for success condition.
Definition: Status.cpp:287
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
Execution context objects refer to objects in the execution of the program that is being debugged...
bool operator==(const lldb::SBThread &rhs) const
Definition: SBThread.cpp:1257
SBThread GetCurrentExceptionBacktrace()
Definition: SBThread.cpp:1373
bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast=false)
Definition: Thread.cpp:334
A section + offset based address class.
Definition: Address.h:80
void StepInstruction(bool step_over)
Definition: SBThread.cpp:775
lldb_private::Stream & ref()
Definition: SBStream.cpp:162
uint64_t queue_id_t
Definition: lldb-types.h:91
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
bool SafeToCallFunctions()
Definition: SBThread.cpp:1385
bool GetDescription(lldb::SBStream &description) const
Definition: SBThread.cpp:1290
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1194
virtual lldb::ThreadPlanSP QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name, bool stop_other_threads, Status &status)
Definition: Thread.cpp:1506
lldb::SBFrame GetSelectedFrame()
Definition: SBThread.cpp:1191
#define LLDB_INVALID_THREAD_ID
Definition: lldb-defines.h:93
uint64_t addr_t
Definition: lldb-types.h:83
lldb::StackFrameSP GetFrameSP() const
Definition: SBFrame.cpp:84
lldb::StopReason GetStopReason()
Definition: SBThread.cpp:137
virtual lldb::ThreadPlanSP QueueThreadPlanForRunToAddress(bool abort_other_plans, Address &target_addr, bool stop_other_threads, Status &status)
Gets the plan used to continue from the current PC.
Definition: Thread.cpp:1485
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
A uniqued constant string class.
Definition: ConstString.h:38
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange(bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, Status &status, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queues the plan used to step through an address range, stepping over function calls.
Definition: Thread.cpp:1379
SBThreadCollection GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type)
Definition: SBThread.cpp:288
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
ProcessRunLock & GetRunLock()
Definition: Process.cpp:5576
uint32_t SetSelectedFrame(lldb_private::StackFrame *frame, bool broadcast=false)
Definition: Thread.cpp:325
LineEntry line_entry
The LineEntry for a given query.
SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value)
Definition: SBThread.cpp:1025
Definition: SBAddress.h:15
SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line)
Definition: SBThread.cpp:1004
lldb::SBThread GetThread() const
Definition: SBFrame.cpp:716
std::shared_ptr< Object > ObjectSP
#define PATH_MAX
static bool EventIsThreadEvent(const SBEvent &event)
Definition: SBThread.cpp:1234
bool SetIsMasterPlan(bool value)
Definition: ThreadPlan.h:436
void AddThread(const lldb::ThreadSP &thread_sp)
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:220
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:49
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
void StepOver(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition: SBThread.cpp:585
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
#define LLDB_INVALID_LINE_NUMBER
Definition: lldb-defines.h:97
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Definition: Thread.h:395
virtual uint32_t GetStackFrameCount()
Definition: Thread.h:391
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
Definition: Process.cpp:2703
A section + offset based address range class.
Definition: AddressRange.h:32
lldb::StopInfoSP GetStopInfo()
Definition: Thread.cpp:381
#define LLDB_RECORD_RESULT(Result)
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut(bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote stop_vote, Vote run_vote, uint32_t frame_idx, Status &status, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queue the plan used to step out of the function at the current PC of thread.
Definition: Thread.cpp:1442
Debugger & GetDebugger()
Definition: Target.h:974
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:150
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format)
Definition: Thread.cpp:1797
An error handling class.
Definition: Status.h:44
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
Definition: ThreadList.cpp:661
Status ReturnFromFrame(lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition: Thread.cpp:1651
A plug-in interface definition class for system runtimes.
Definition: SystemRuntime.h:42
Process or thread is running and can&#39;t be examined.
size_t GetStopDescription(char *dst, size_t dst_len)
Definition: SBThread.cpp:313