LLDB  mainline
CommandObjectThread.cpp
Go to the documentation of this file.
1 //===-- CommandObjectThread.cpp -------------------------------------------===//
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 "CommandObjectThread.h"
10 
11 #include <memory>
12 #include <sstream>
13 
15 #include "CommandObjectTrace.h"
17 #include "lldb/Core/ValueObject.h"
18 #include "lldb/Host/OptionParser.h"
25 #include "lldb/Symbol/Function.h"
26 #include "lldb/Symbol/LineEntry.h"
27 #include "lldb/Symbol/LineTable.h"
28 #include "lldb/Target/Process.h"
31 #include "lldb/Target/Target.h"
32 #include "lldb/Target/Thread.h"
33 #include "lldb/Target/ThreadPlan.h"
35 #include "lldb/Target/Trace.h"
37 #include "lldb/Utility/State.h"
38 
39 using namespace lldb;
40 using namespace lldb_private;
41 
42 // CommandObjectThreadBacktrace
43 #define LLDB_OPTIONS_thread_backtrace
44 #include "CommandOptions.inc"
45 
47 public:
48  class CommandOptions : public Options {
49  public:
51  // Keep default values of all options in one place: OptionParsingStarting
52  // ()
53  OptionParsingStarting(nullptr);
54  }
55 
56  ~CommandOptions() override = default;
57 
58  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
59  ExecutionContext *execution_context) override {
60  Status error;
61  const int short_option = m_getopt_table[option_idx].val;
62 
63  switch (short_option) {
64  case 'c': {
65  int32_t input_count = 0;
66  if (option_arg.getAsInteger(0, m_count)) {
67  m_count = UINT32_MAX;
68  error.SetErrorStringWithFormat(
69  "invalid integer value for option '%c'", short_option);
70  } else if (input_count < 0)
71  m_count = UINT32_MAX;
72  } break;
73  case 's':
74  if (option_arg.getAsInteger(0, m_start))
75  error.SetErrorStringWithFormat(
76  "invalid integer value for option '%c'", short_option);
77  break;
78  case 'e': {
79  bool success;
80  m_extended_backtrace =
81  OptionArgParser::ToBoolean(option_arg, false, &success);
82  if (!success)
83  error.SetErrorStringWithFormat(
84  "invalid boolean value for option '%c'", short_option);
85  } break;
86  default:
87  llvm_unreachable("Unimplemented option");
88  }
89  return error;
90  }
91 
92  void OptionParsingStarting(ExecutionContext *execution_context) override {
93  m_count = UINT32_MAX;
94  m_start = 0;
95  m_extended_backtrace = false;
96  }
97 
98  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
99  return llvm::makeArrayRef(g_thread_backtrace_options);
100  }
101 
102  // Instance variables to hold the values for command options.
106  };
107 
110  interpreter, "thread backtrace",
111  "Show thread call stacks. Defaults to the current thread, thread "
112  "indexes can be specified as arguments.\n"
113  "Use the thread-index \"all\" to see all threads.\n"
114  "Use the thread-index \"unique\" to see threads grouped by unique "
115  "call stacks.\n"
116  "Use 'settings set frame-format' to customize the printing of "
117  "frames in the backtrace and 'settings set thread-format' to "
118  "customize the thread header.",
119  nullptr,
120  eCommandRequiresProcess | eCommandRequiresThread |
121  eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
122  eCommandProcessMustBePaused),
123  m_options() {}
124 
125  ~CommandObjectThreadBacktrace() override = default;
126 
127  Options *GetOptions() override { return &m_options; }
128 
129 protected:
131  SystemRuntime *runtime = thread->GetProcess()->GetSystemRuntime();
132  if (runtime) {
133  Stream &strm = result.GetOutputStream();
134  const std::vector<ConstString> &types =
135  runtime->GetExtendedBacktraceTypes();
136  for (auto type : types) {
137  ThreadSP ext_thread_sp = runtime->GetExtendedBacktraceThread(
138  thread->shared_from_this(), type);
139  if (ext_thread_sp && ext_thread_sp->IsValid()) {
140  const uint32_t num_frames_with_source = 0;
141  const bool stop_format = false;
142  if (ext_thread_sp->GetStatus(strm, m_options.m_start,
143  m_options.m_count,
144  num_frames_with_source, stop_format)) {
145  DoExtendedBacktrace(ext_thread_sp.get(), result);
146  }
147  }
148  }
149  }
150  }
151 
152  bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
153  ThreadSP thread_sp =
154  m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
155  if (!thread_sp) {
156  result.AppendErrorWithFormat(
157  "thread disappeared while computing backtraces: 0x%" PRIx64 "\n",
158  tid);
159  return false;
160  }
161 
162  Thread *thread = thread_sp.get();
163 
164  Stream &strm = result.GetOutputStream();
165 
166  // Only dump stack info if we processing unique stacks.
167  const bool only_stacks = m_unique_stacks;
168 
169  // Don't show source context when doing backtraces.
170  const uint32_t num_frames_with_source = 0;
171  const bool stop_format = true;
172  if (!thread->GetStatus(strm, m_options.m_start, m_options.m_count,
173  num_frames_with_source, stop_format, only_stacks)) {
174  result.AppendErrorWithFormat(
175  "error displaying backtrace for thread: \"0x%4.4x\"\n",
176  thread->GetIndexID());
177  return false;
178  }
179  if (m_options.m_extended_backtrace) {
180  DoExtendedBacktrace(thread, result);
181  }
182 
183  return true;
184  }
185 
187 };
188 
190 
191 static constexpr OptionEnumValueElement g_tri_running_mode[] = {
192  {eOnlyThisThread, "this-thread", "Run only this thread"},
193  {eAllThreads, "all-threads", "Run all threads"},
194  {eOnlyDuringStepping, "while-stepping",
195  "Run only this thread while stepping"}};
196 
197 static constexpr OptionEnumValues TriRunningModes() {
198  return OptionEnumValues(g_tri_running_mode);
199 }
200 
201 #define LLDB_OPTIONS_thread_step_scope
202 #include "CommandOptions.inc"
203 
205 public:
207  // Keep default values of all options in one place: OptionParsingStarting
208  // ()
209  OptionParsingStarting(nullptr);
210  }
211 
212  ~ThreadStepScopeOptionGroup() override = default;
213 
214  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
215  return llvm::makeArrayRef(g_thread_step_scope_options);
216  }
217 
218  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
219  ExecutionContext *execution_context) override {
220  Status error;
221  const int short_option =
222  g_thread_step_scope_options[option_idx].short_option;
223 
224  switch (short_option) {
225  case 'a': {
226  bool success;
227  bool avoid_no_debug =
228  OptionArgParser::ToBoolean(option_arg, true, &success);
229  if (!success)
230  error.SetErrorStringWithFormat("invalid boolean value for option '%c'",
231  short_option);
232  else {
233  m_step_in_avoid_no_debug = avoid_no_debug ? eLazyBoolYes : eLazyBoolNo;
234  }
235  } break;
236 
237  case 'A': {
238  bool success;
239  bool avoid_no_debug =
240  OptionArgParser::ToBoolean(option_arg, true, &success);
241  if (!success)
242  error.SetErrorStringWithFormat("invalid boolean value for option '%c'",
243  short_option);
244  else {
245  m_step_out_avoid_no_debug = avoid_no_debug ? eLazyBoolYes : eLazyBoolNo;
246  }
247  } break;
248 
249  case 'c':
250  if (option_arg.getAsInteger(0, m_step_count))
251  error.SetErrorStringWithFormat("invalid step count '%s'",
252  option_arg.str().c_str());
253  break;
254 
255  case 'm': {
256  auto enum_values = GetDefinitions()[option_idx].enum_values;
257  m_run_mode = (lldb::RunMode)OptionArgParser::ToOptionEnum(
258  option_arg, enum_values, eOnlyDuringStepping, error);
259  } break;
260 
261  case 'e':
262  if (option_arg == "block") {
263  m_end_line_is_block_end = true;
264  break;
265  }
266  if (option_arg.getAsInteger(0, m_end_line))
267  error.SetErrorStringWithFormat("invalid end line number '%s'",
268  option_arg.str().c_str());
269  break;
270 
271  case 'r':
272  m_avoid_regexp.clear();
273  m_avoid_regexp.assign(std::string(option_arg));
274  break;
275 
276  case 't':
277  m_step_in_target.clear();
278  m_step_in_target.assign(std::string(option_arg));
279  break;
280 
281  default:
282  llvm_unreachable("Unimplemented option");
283  }
284  return error;
285  }
286 
287  void OptionParsingStarting(ExecutionContext *execution_context) override {
288  m_step_in_avoid_no_debug = eLazyBoolCalculate;
289  m_step_out_avoid_no_debug = eLazyBoolCalculate;
290  m_run_mode = eOnlyDuringStepping;
291 
292  // Check if we are in Non-Stop mode
293  TargetSP target_sp =
294  execution_context ? execution_context->GetTargetSP() : TargetSP();
295  ProcessSP process_sp =
296  execution_context ? execution_context->GetProcessSP() : ProcessSP();
297  if (process_sp && process_sp->GetSteppingRunsAllThreads())
298  m_run_mode = eAllThreads;
299 
300  m_avoid_regexp.clear();
301  m_step_in_target.clear();
302  m_step_count = 1;
303  m_end_line = LLDB_INVALID_LINE_NUMBER;
304  m_end_line_is_block_end = false;
305  }
306 
307  // Instance variables to hold the values for command options.
316 };
317 
319 public:
321  const char *name, const char *help,
322  const char *syntax,
323  StepType step_type,
324  StepScope step_scope)
325  : CommandObjectParsed(interpreter, name, help, syntax,
326  eCommandRequiresProcess | eCommandRequiresThread |
327  eCommandTryTargetAPILock |
328  eCommandProcessMustBeLaunched |
329  eCommandProcessMustBePaused),
330  m_step_type(step_type), m_step_scope(step_scope), m_options(),
331  m_class_options("scripted step") {
333  CommandArgumentData thread_id_arg;
334 
335  // Define the first (and only) variant of this arg.
336  thread_id_arg.arg_type = eArgTypeThreadID;
337  thread_id_arg.arg_repetition = eArgRepeatOptional;
338 
339  // There is only one variant this argument could be; put it into the
340  // argument entry.
341  arg.push_back(thread_id_arg);
342 
343  // Push the data for the first argument into the m_arguments vector.
344  m_arguments.push_back(arg);
345 
346  if (step_type == eStepTypeScripted) {
347  m_all_options.Append(&m_class_options, LLDB_OPT_SET_1 | LLDB_OPT_SET_2,
349  }
350  m_all_options.Append(&m_options);
351  m_all_options.Finalize();
352  }
353 
354  ~CommandObjectThreadStepWithTypeAndScope() override = default;
355 
356  void
358  OptionElementVector &opt_element_vector) override {
359  if (request.GetCursorIndex())
360  return;
361 
362  CommandCompletions::InvokeCommonCompletionCallbacks(
363  GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
364  request, nullptr);
365  }
366 
367  Options *GetOptions() override { return &m_all_options; }
368 
369 protected:
370  bool DoExecute(Args &command, CommandReturnObject &result) override {
371  Process *process = m_exe_ctx.GetProcessPtr();
372  bool synchronous_execution = m_interpreter.GetSynchronous();
373 
374  const uint32_t num_threads = process->GetThreadList().GetSize();
375  Thread *thread = nullptr;
376 
377  if (command.GetArgumentCount() == 0) {
378  thread = GetDefaultThread();
379 
380  if (thread == nullptr) {
381  result.AppendError("no selected thread in process");
382  return false;
383  }
384  } else {
385  const char *thread_idx_cstr = command.GetArgumentAtIndex(0);
386  uint32_t step_thread_idx;
387 
388  if (!llvm::to_integer(thread_idx_cstr, step_thread_idx)) {
389  result.AppendErrorWithFormat("invalid thread index '%s'.\n",
390  thread_idx_cstr);
391  return false;
392  }
393  thread =
394  process->GetThreadList().FindThreadByIndexID(step_thread_idx).get();
395  if (thread == nullptr) {
396  result.AppendErrorWithFormat(
397  "Thread index %u is out of range (valid values are 0 - %u).\n",
398  step_thread_idx, num_threads);
399  return false;
400  }
401  }
402 
403  if (m_step_type == eStepTypeScripted) {
404  if (m_class_options.GetName().empty()) {
405  result.AppendErrorWithFormat("empty class name for scripted step.");
406  return false;
407  } else if (!GetDebugger().GetScriptInterpreter()->CheckObjectExists(
408  m_class_options.GetName().c_str())) {
409  result.AppendErrorWithFormat(
410  "class for scripted step: \"%s\" does not exist.",
411  m_class_options.GetName().c_str());
412  return false;
413  }
414  }
415 
416  if (m_options.m_end_line != LLDB_INVALID_LINE_NUMBER &&
417  m_step_type != eStepTypeInto) {
418  result.AppendErrorWithFormat(
419  "end line option is only valid for step into");
420  return false;
421  }
422 
423  const bool abort_other_plans = false;
424  const lldb::RunMode stop_other_threads = m_options.m_run_mode;
425 
426  // This is a bit unfortunate, but not all the commands in this command
427  // object support only while stepping, so I use the bool for them.
428  bool bool_stop_other_threads;
429  if (m_options.m_run_mode == eAllThreads)
430  bool_stop_other_threads = false;
431  else if (m_options.m_run_mode == eOnlyDuringStepping)
432  bool_stop_other_threads = (m_step_type != eStepTypeOut);
433  else
434  bool_stop_other_threads = true;
435 
436  ThreadPlanSP new_plan_sp;
437  Status new_plan_status;
438 
439  if (m_step_type == eStepTypeInto) {
440  StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
441  assert(frame != nullptr);
442 
443  if (frame->HasDebugInformation()) {
444  AddressRange range;
445  SymbolContext sc = frame->GetSymbolContext(eSymbolContextEverything);
446  if (m_options.m_end_line != LLDB_INVALID_LINE_NUMBER) {
447  Status error;
448  if (!sc.GetAddressRangeFromHereToEndLine(m_options.m_end_line, range,
449  error)) {
450  result.AppendErrorWithFormat("invalid end-line option: %s.",
451  error.AsCString());
452  return false;
453  }
454  } else if (m_options.m_end_line_is_block_end) {
455  Status error;
456  Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
457  if (!block) {
458  result.AppendErrorWithFormat("Could not find the current block.");
459  return false;
460  }
461 
462  AddressRange block_range;
463  Address pc_address = frame->GetFrameCodeAddress();
464  block->GetRangeContainingAddress(pc_address, block_range);
465  if (!block_range.GetBaseAddress().IsValid()) {
466  result.AppendErrorWithFormat(
467  "Could not find the current block address.");
468  return false;
469  }
470  lldb::addr_t pc_offset_in_block =
471  pc_address.GetFileAddress() -
472  block_range.GetBaseAddress().GetFileAddress();
473  lldb::addr_t range_length =
474  block_range.GetByteSize() - pc_offset_in_block;
475  range = AddressRange(pc_address, range_length);
476  } else {
477  range = sc.line_entry.range;
478  }
479 
480  new_plan_sp = thread->QueueThreadPlanForStepInRange(
481  abort_other_plans, range,
482  frame->GetSymbolContext(eSymbolContextEverything),
483  m_options.m_step_in_target.c_str(), stop_other_threads,
484  new_plan_status, m_options.m_step_in_avoid_no_debug,
485  m_options.m_step_out_avoid_no_debug);
486 
487  if (new_plan_sp && !m_options.m_avoid_regexp.empty()) {
488  ThreadPlanStepInRange *step_in_range_plan =
489  static_cast<ThreadPlanStepInRange *>(new_plan_sp.get());
490  step_in_range_plan->SetAvoidRegexp(m_options.m_avoid_regexp.c_str());
491  }
492  } else
493  new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
494  false, abort_other_plans, bool_stop_other_threads, new_plan_status);
495  } else if (m_step_type == eStepTypeOver) {
496  StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
497 
498  if (frame->HasDebugInformation())
499  new_plan_sp = thread->QueueThreadPlanForStepOverRange(
500  abort_other_plans,
501  frame->GetSymbolContext(eSymbolContextEverything).line_entry,
502  frame->GetSymbolContext(eSymbolContextEverything),
503  stop_other_threads, new_plan_status,
504  m_options.m_step_out_avoid_no_debug);
505  else
506  new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
507  true, abort_other_plans, bool_stop_other_threads, new_plan_status);
508  } else if (m_step_type == eStepTypeTrace) {
509  new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
510  false, abort_other_plans, bool_stop_other_threads, new_plan_status);
511  } else if (m_step_type == eStepTypeTraceOver) {
512  new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
513  true, abort_other_plans, bool_stop_other_threads, new_plan_status);
514  } else if (m_step_type == eStepTypeOut) {
515  new_plan_sp = thread->QueueThreadPlanForStepOut(
516  abort_other_plans, nullptr, false, bool_stop_other_threads, eVoteYes,
517  eVoteNoOpinion, thread->GetSelectedFrameIndex(), new_plan_status,
518  m_options.m_step_out_avoid_no_debug);
519  } else if (m_step_type == eStepTypeScripted) {
520  new_plan_sp = thread->QueueThreadPlanForStepScripted(
521  abort_other_plans, m_class_options.GetName().c_str(),
522  m_class_options.GetStructuredData(), bool_stop_other_threads,
523  new_plan_status);
524  } else {
525  result.AppendError("step type is not supported");
526  return false;
527  }
528 
529  // If we got a new plan, then set it to be a master plan (User level Plans
530  // should be master plans so that they can be interruptible). Then resume
531  // the process.
532 
533  if (new_plan_sp) {
534  new_plan_sp->SetIsMasterPlan(true);
535  new_plan_sp->SetOkayToDiscard(false);
536 
537  if (m_options.m_step_count > 1) {
538  if (!new_plan_sp->SetIterationCount(m_options.m_step_count)) {
539  result.AppendWarning(
540  "step operation does not support iteration count.");
541  }
542  }
543 
544  process->GetThreadList().SetSelectedThreadByID(thread->GetID());
545 
546  const uint32_t iohandler_id = process->GetIOHandlerID();
547 
548  StreamString stream;
549  Status error;
550  if (synchronous_execution)
551  error = process->ResumeSynchronous(&stream);
552  else
553  error = process->Resume();
554 
555  if (!error.Success()) {
556  result.AppendMessage(error.AsCString());
557  return false;
558  }
559 
560  // There is a race condition where this thread will return up the call
561  // stack to the main command handler and show an (lldb) prompt before
562  // HandlePrivateEvent (from PrivateStateThread) has a chance to call
563  // PushProcessIOHandler().
564  process->SyncIOHandler(iohandler_id, std::chrono::seconds(2));
565 
566  if (synchronous_execution) {
567  // If any state changed events had anything to say, add that to the
568  // result
569  if (stream.GetSize() > 0)
570  result.AppendMessage(stream.GetString());
571 
572  process->GetThreadList().SetSelectedThreadByID(thread->GetID());
573  result.SetDidChangeProcessState(true);
575  } else {
577  }
578  } else {
579  result.SetError(new_plan_status);
580  }
581  return result.Succeeded();
582  }
583 
589 };
590 
591 // CommandObjectThreadContinue
592 
594 public:
597  interpreter, "thread continue",
598  "Continue execution of the current target process. One "
599  "or more threads may be specified, by default all "
600  "threads continue.",
601  nullptr,
602  eCommandRequiresThread | eCommandTryTargetAPILock |
603  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {
605  CommandArgumentData thread_idx_arg;
606 
607  // Define the first (and only) variant of this arg.
608  thread_idx_arg.arg_type = eArgTypeThreadIndex;
609  thread_idx_arg.arg_repetition = eArgRepeatPlus;
610 
611  // There is only one variant this argument could be; put it into the
612  // argument entry.
613  arg.push_back(thread_idx_arg);
614 
615  // Push the data for the first argument into the m_arguments vector.
616  m_arguments.push_back(arg);
617  }
618 
619  ~CommandObjectThreadContinue() override = default;
620 
621  void
623  OptionElementVector &opt_element_vector) override {
624  CommandCompletions::InvokeCommonCompletionCallbacks(
625  GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
626  request, nullptr);
627  }
628 
629  bool DoExecute(Args &command, CommandReturnObject &result) override {
630  bool synchronous_execution = m_interpreter.GetSynchronous();
631 
632  Process *process = m_exe_ctx.GetProcessPtr();
633  if (process == nullptr) {
634  result.AppendError("no process exists. Cannot continue");
635  return false;
636  }
637 
638  StateType state = process->GetState();
639  if ((state == eStateCrashed) || (state == eStateStopped) ||
640  (state == eStateSuspended)) {
641  const size_t argc = command.GetArgumentCount();
642  if (argc > 0) {
643  // These two lines appear at the beginning of both blocks in this
644  // if..else, but that is because we need to release the lock before
645  // calling process->Resume below.
646  std::lock_guard<std::recursive_mutex> guard(
647  process->GetThreadList().GetMutex());
648  const uint32_t num_threads = process->GetThreadList().GetSize();
649  std::vector<Thread *> resume_threads;
650  for (auto &entry : command.entries()) {
651  uint32_t thread_idx;
652  if (entry.ref().getAsInteger(0, thread_idx)) {
653  result.AppendErrorWithFormat(
654  "invalid thread index argument: \"%s\".\n", entry.c_str());
655  return false;
656  }
657  Thread *thread =
658  process->GetThreadList().FindThreadByIndexID(thread_idx).get();
659 
660  if (thread) {
661  resume_threads.push_back(thread);
662  } else {
663  result.AppendErrorWithFormat("invalid thread index %u.\n",
664  thread_idx);
665  return false;
666  }
667  }
668 
669  if (resume_threads.empty()) {
670  result.AppendError("no valid thread indexes were specified");
671  return false;
672  } else {
673  if (resume_threads.size() == 1)
674  result.AppendMessageWithFormat("Resuming thread: ");
675  else
676  result.AppendMessageWithFormat("Resuming threads: ");
677 
678  for (uint32_t idx = 0; idx < num_threads; ++idx) {
679  Thread *thread =
680  process->GetThreadList().GetThreadAtIndex(idx).get();
681  std::vector<Thread *>::iterator this_thread_pos =
682  find(resume_threads.begin(), resume_threads.end(), thread);
683 
684  if (this_thread_pos != resume_threads.end()) {
685  resume_threads.erase(this_thread_pos);
686  if (!resume_threads.empty())
687  result.AppendMessageWithFormat("%u, ", thread->GetIndexID());
688  else
689  result.AppendMessageWithFormat("%u ", thread->GetIndexID());
690 
691  const bool override_suspend = true;
692  thread->SetResumeState(eStateRunning, override_suspend);
693  } else {
695  }
696  }
697  result.AppendMessageWithFormat("in process %" PRIu64 "\n",
698  process->GetID());
699  }
700  } else {
701  // These two lines appear at the beginning of both blocks in this
702  // if..else, but that is because we need to release the lock before
703  // calling process->Resume below.
704  std::lock_guard<std::recursive_mutex> guard(
705  process->GetThreadList().GetMutex());
706  const uint32_t num_threads = process->GetThreadList().GetSize();
707  Thread *current_thread = GetDefaultThread();
708  if (current_thread == nullptr) {
709  result.AppendError("the process doesn't have a current thread");
710  return false;
711  }
712  // Set the actions that the threads should each take when resuming
713  for (uint32_t idx = 0; idx < num_threads; ++idx) {
714  Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get();
715  if (thread == current_thread) {
716  result.AppendMessageWithFormat("Resuming thread 0x%4.4" PRIx64
717  " in process %" PRIu64 "\n",
718  thread->GetID(), process->GetID());
719  const bool override_suspend = true;
720  thread->SetResumeState(eStateRunning, override_suspend);
721  } else {
723  }
724  }
725  }
726 
727  StreamString stream;
728  Status error;
729  if (synchronous_execution)
730  error = process->ResumeSynchronous(&stream);
731  else
732  error = process->Resume();
733 
734  // We should not be holding the thread list lock when we do this.
735  if (error.Success()) {
736  result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n",
737  process->GetID());
738  if (synchronous_execution) {
739  // If any state changed events had anything to say, add that to the
740  // result
741  if (stream.GetSize() > 0)
742  result.AppendMessage(stream.GetString());
743 
744  result.SetDidChangeProcessState(true);
746  } else {
748  }
749  } else {
750  result.AppendErrorWithFormat("Failed to resume process: %s\n",
751  error.AsCString());
752  }
753  } else {
754  result.AppendErrorWithFormat(
755  "Process cannot be continued from its current state (%s).\n",
756  StateAsCString(state));
757  }
758 
759  return result.Succeeded();
760  }
761 };
762 
763 // CommandObjectThreadUntil
764 
765 static constexpr OptionEnumValueElement g_duo_running_mode[] = {
766  {eOnlyThisThread, "this-thread", "Run only this thread"},
767  {eAllThreads, "all-threads", "Run all threads"}};
768 
769 static constexpr OptionEnumValues DuoRunningModes() {
770  return OptionEnumValues(g_duo_running_mode);
771 }
772 
773 #define LLDB_OPTIONS_thread_until
774 #include "CommandOptions.inc"
775 
777 public:
778  class CommandOptions : public Options {
779  public:
782 
784  // Keep default values of all options in one place: OptionParsingStarting
785  // ()
786  OptionParsingStarting(nullptr);
787  }
788 
789  ~CommandOptions() override = default;
790 
791  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
792  ExecutionContext *execution_context) override {
793  Status error;
794  const int short_option = m_getopt_table[option_idx].val;
795 
796  switch (short_option) {
797  case 'a': {
798  lldb::addr_t tmp_addr = OptionArgParser::ToAddress(
799  execution_context, option_arg, LLDB_INVALID_ADDRESS, &error);
800  if (error.Success())
801  m_until_addrs.push_back(tmp_addr);
802  } break;
803  case 't':
804  if (option_arg.getAsInteger(0, m_thread_idx)) {
805  m_thread_idx = LLDB_INVALID_INDEX32;
806  error.SetErrorStringWithFormat("invalid thread index '%s'",
807  option_arg.str().c_str());
808  }
809  break;
810  case 'f':
811  if (option_arg.getAsInteger(0, m_frame_idx)) {
812  m_frame_idx = LLDB_INVALID_FRAME_ID;
813  error.SetErrorStringWithFormat("invalid frame index '%s'",
814  option_arg.str().c_str());
815  }
816  break;
817  case 'm': {
818  auto enum_values = GetDefinitions()[option_idx].enum_values;
819  lldb::RunMode run_mode = (lldb::RunMode)OptionArgParser::ToOptionEnum(
820  option_arg, enum_values, eOnlyDuringStepping, error);
821 
822  if (error.Success()) {
823  if (run_mode == eAllThreads)
824  m_stop_others = false;
825  else
826  m_stop_others = true;
827  }
828  } break;
829  default:
830  llvm_unreachable("Unimplemented option");
831  }
832  return error;
833  }
834 
835  void OptionParsingStarting(ExecutionContext *execution_context) override {
836  m_thread_idx = LLDB_INVALID_THREAD_ID;
837  m_frame_idx = 0;
838  m_stop_others = false;
839  m_until_addrs.clear();
840  }
841 
842  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
843  return llvm::makeArrayRef(g_thread_until_options);
844  }
845 
848  std::vector<lldb::addr_t> m_until_addrs;
849 
850  // Instance variables to hold the values for command options.
851  };
852 
855  interpreter, "thread until",
856  "Continue until a line number or address is reached by the "
857  "current or specified thread. Stops when returning from "
858  "the current function as a safety measure. "
859  "The target line number(s) are given as arguments, and if more "
860  "than one"
861  " is provided, stepping will stop when the first one is hit.",
862  nullptr,
863  eCommandRequiresThread | eCommandTryTargetAPILock |
864  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
865  m_options() {
867  CommandArgumentData line_num_arg;
868 
869  // Define the first (and only) variant of this arg.
870  line_num_arg.arg_type = eArgTypeLineNum;
871  line_num_arg.arg_repetition = eArgRepeatPlain;
872 
873  // There is only one variant this argument could be; put it into the
874  // argument entry.
875  arg.push_back(line_num_arg);
876 
877  // Push the data for the first argument into the m_arguments vector.
878  m_arguments.push_back(arg);
879  }
880 
881  ~CommandObjectThreadUntil() override = default;
882 
883  Options *GetOptions() override { return &m_options; }
884 
885 protected:
886  bool DoExecute(Args &command, CommandReturnObject &result) override {
887  bool synchronous_execution = m_interpreter.GetSynchronous();
888 
889  Target *target = &GetSelectedTarget();
890 
891  Process *process = m_exe_ctx.GetProcessPtr();
892  if (process == nullptr) {
893  result.AppendError("need a valid process to step");
894  } else {
895  Thread *thread = nullptr;
896  std::vector<uint32_t> line_numbers;
897 
898  if (command.GetArgumentCount() >= 1) {
899  size_t num_args = command.GetArgumentCount();
900  for (size_t i = 0; i < num_args; i++) {
901  uint32_t line_number;
902  if (!llvm::to_integer(command.GetArgumentAtIndex(i), line_number)) {
903  result.AppendErrorWithFormat("invalid line number: '%s'.\n",
904  command.GetArgumentAtIndex(i));
905  return false;
906  } else
907  line_numbers.push_back(line_number);
908  }
909  } else if (m_options.m_until_addrs.empty()) {
910  result.AppendErrorWithFormat("No line number or address provided:\n%s",
911  GetSyntax().str().c_str());
912  return false;
913  }
914 
915  if (m_options.m_thread_idx == LLDB_INVALID_THREAD_ID) {
916  thread = GetDefaultThread();
917  } else {
918  thread = process->GetThreadList()
919  .FindThreadByIndexID(m_options.m_thread_idx)
920  .get();
921  }
922 
923  if (thread == nullptr) {
924  const uint32_t num_threads = process->GetThreadList().GetSize();
925  result.AppendErrorWithFormat(
926  "Thread index %u is out of range (valid values are 0 - %u).\n",
927  m_options.m_thread_idx, num_threads);
928  return false;
929  }
930 
931  const bool abort_other_plans = false;
932 
933  StackFrame *frame =
934  thread->GetStackFrameAtIndex(m_options.m_frame_idx).get();
935  if (frame == nullptr) {
936  result.AppendErrorWithFormat(
937  "Frame index %u is out of range for thread %u.\n",
938  m_options.m_frame_idx, m_options.m_thread_idx);
939  return false;
940  }
941 
942  ThreadPlanSP new_plan_sp;
943  Status new_plan_status;
944 
945  if (frame->HasDebugInformation()) {
946  // Finally we got here... Translate the given line number to a bunch
947  // of addresses:
948  SymbolContext sc(frame->GetSymbolContext(eSymbolContextCompUnit));
949  LineTable *line_table = nullptr;
950  if (sc.comp_unit)
951  line_table = sc.comp_unit->GetLineTable();
952 
953  if (line_table == nullptr) {
954  result.AppendErrorWithFormat("Failed to resolve the line table for "
955  "frame %u of thread index %u.\n",
956  m_options.m_frame_idx,
957  m_options.m_thread_idx);
958  return false;
959  }
960 
961  LineEntry function_start;
962  uint32_t index_ptr = 0, end_ptr;
963  std::vector<addr_t> address_list;
964 
965  // Find the beginning & end index of the
966  AddressRange fun_addr_range = sc.function->GetAddressRange();
967  Address fun_start_addr = fun_addr_range.GetBaseAddress();
968  line_table->FindLineEntryByAddress(fun_start_addr, function_start,
969  &index_ptr);
970 
971  Address fun_end_addr(fun_start_addr.GetSection(),
972  fun_start_addr.GetOffset() +
973  fun_addr_range.GetByteSize());
974 
975  bool all_in_function = true;
976 
977  line_table->FindLineEntryByAddress(fun_end_addr, function_start,
978  &end_ptr);
979 
980  for (uint32_t line_number : line_numbers) {
981  uint32_t start_idx_ptr = index_ptr;
982  while (start_idx_ptr <= end_ptr) {
983  LineEntry line_entry;
984  const bool exact = false;
985  start_idx_ptr = sc.comp_unit->FindLineEntry(
986  start_idx_ptr, line_number, nullptr, exact, &line_entry);
987  if (start_idx_ptr == UINT32_MAX)
988  break;
989 
990  addr_t address =
991  line_entry.range.GetBaseAddress().GetLoadAddress(target);
992  if (address != LLDB_INVALID_ADDRESS) {
993  if (fun_addr_range.ContainsLoadAddress(address, target))
994  address_list.push_back(address);
995  else
996  all_in_function = false;
997  }
998  start_idx_ptr++;
999  }
1000  }
1001 
1002  for (lldb::addr_t address : m_options.m_until_addrs) {
1003  if (fun_addr_range.ContainsLoadAddress(address, target))
1004  address_list.push_back(address);
1005  else
1006  all_in_function = false;
1007  }
1008 
1009  if (address_list.empty()) {
1010  if (all_in_function)
1011  result.AppendErrorWithFormat(
1012  "No line entries matching until target.\n");
1013  else
1014  result.AppendErrorWithFormat(
1015  "Until target outside of the current function.\n");
1016 
1017  return false;
1018  }
1019 
1020  new_plan_sp = thread->QueueThreadPlanForStepUntil(
1021  abort_other_plans, &address_list.front(), address_list.size(),
1022  m_options.m_stop_others, m_options.m_frame_idx, new_plan_status);
1023  if (new_plan_sp) {
1024  // User level plans should be master plans so they can be interrupted
1025  // (e.g. by hitting a breakpoint) and other plans executed by the
1026  // user (stepping around the breakpoint) and then a "continue" will
1027  // resume the original plan.
1028  new_plan_sp->SetIsMasterPlan(true);
1029  new_plan_sp->SetOkayToDiscard(false);
1030  } else {
1031  result.SetError(new_plan_status);
1032  return false;
1033  }
1034  } else {
1035  result.AppendErrorWithFormat(
1036  "Frame index %u of thread %u has no debug information.\n",
1037  m_options.m_frame_idx, m_options.m_thread_idx);
1038  return false;
1039  }
1040 
1041  process->GetThreadList().SetSelectedThreadByID(m_options.m_thread_idx);
1042 
1043  StreamString stream;
1044  Status error;
1045  if (synchronous_execution)
1046  error = process->ResumeSynchronous(&stream);
1047  else
1048  error = process->Resume();
1049 
1050  if (error.Success()) {
1051  result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n",
1052  process->GetID());
1053  if (synchronous_execution) {
1054  // If any state changed events had anything to say, add that to the
1055  // result
1056  if (stream.GetSize() > 0)
1057  result.AppendMessage(stream.GetString());
1058 
1059  result.SetDidChangeProcessState(true);
1061  } else {
1063  }
1064  } else {
1065  result.AppendErrorWithFormat("Failed to resume process: %s.\n",
1066  error.AsCString());
1067  }
1068  }
1069  return result.Succeeded();
1070  }
1071 
1073 };
1074 
1075 // CommandObjectThreadSelect
1076 
1078 public:
1080  : CommandObjectParsed(interpreter, "thread select",
1081  "Change the currently selected thread.", nullptr,
1082  eCommandRequiresProcess | eCommandTryTargetAPILock |
1083  eCommandProcessMustBeLaunched |
1084  eCommandProcessMustBePaused) {
1086  CommandArgumentData thread_idx_arg;
1087 
1088  // Define the first (and only) variant of this arg.
1089  thread_idx_arg.arg_type = eArgTypeThreadIndex;
1090  thread_idx_arg.arg_repetition = eArgRepeatPlain;
1091 
1092  // There is only one variant this argument could be; put it into the
1093  // argument entry.
1094  arg.push_back(thread_idx_arg);
1095 
1096  // Push the data for the first argument into the m_arguments vector.
1097  m_arguments.push_back(arg);
1098  }
1099 
1100  ~CommandObjectThreadSelect() override = default;
1101 
1102  void
1104  OptionElementVector &opt_element_vector) override {
1105  if (request.GetCursorIndex())
1106  return;
1107 
1108  CommandCompletions::InvokeCommonCompletionCallbacks(
1109  GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
1110  request, nullptr);
1111  }
1112 
1113 protected:
1114  bool DoExecute(Args &command, CommandReturnObject &result) override {
1115  Process *process = m_exe_ctx.GetProcessPtr();
1116  if (process == nullptr) {
1117  result.AppendError("no process");
1118  return false;
1119  } else if (command.GetArgumentCount() != 1) {
1120  result.AppendErrorWithFormat(
1121  "'%s' takes exactly one thread index argument:\nUsage: %s\n",
1122  m_cmd_name.c_str(), m_cmd_syntax.c_str());
1123  return false;
1124  }
1125 
1126  uint32_t index_id;
1127  if (!llvm::to_integer(command.GetArgumentAtIndex(0), index_id)) {
1128  result.AppendErrorWithFormat("Invalid thread index '%s'",
1129  command.GetArgumentAtIndex(0));
1130  return false;
1131  }
1132 
1133  Thread *new_thread =
1134  process->GetThreadList().FindThreadByIndexID(index_id).get();
1135  if (new_thread == nullptr) {
1136  result.AppendErrorWithFormat("invalid thread #%s.\n",
1137  command.GetArgumentAtIndex(0));
1138  return false;
1139  }
1140 
1141  process->GetThreadList().SetSelectedThreadByID(new_thread->GetID(), true);
1143 
1144  return result.Succeeded();
1145  }
1146 };
1147 
1148 // CommandObjectThreadList
1149 
1151 public:
1154  interpreter, "thread list",
1155  "Show a summary of each thread in the current target process. "
1156  "Use 'settings set thread-format' to customize the individual "
1157  "thread listings.",
1158  "thread list",
1159  eCommandRequiresProcess | eCommandTryTargetAPILock |
1160  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
1161 
1162  ~CommandObjectThreadList() override = default;
1163 
1164 protected:
1165  bool DoExecute(Args &command, CommandReturnObject &result) override {
1166  Stream &strm = result.GetOutputStream();
1168  Process *process = m_exe_ctx.GetProcessPtr();
1169  const bool only_threads_with_stop_reason = false;
1170  const uint32_t start_frame = 0;
1171  const uint32_t num_frames = 0;
1172  const uint32_t num_frames_with_source = 0;
1173  process->GetStatus(strm);
1174  process->GetThreadStatus(strm, only_threads_with_stop_reason, start_frame,
1175  num_frames, num_frames_with_source, false);
1176  return result.Succeeded();
1177  }
1178 };
1179 
1180 // CommandObjectThreadInfo
1181 #define LLDB_OPTIONS_thread_info
1182 #include "CommandOptions.inc"
1183 
1185 public:
1186  class CommandOptions : public Options {
1187  public:
1188  CommandOptions() : Options() { OptionParsingStarting(nullptr); }
1189 
1190  ~CommandOptions() override = default;
1191 
1192  void OptionParsingStarting(ExecutionContext *execution_context) override {
1193  m_json_thread = false;
1194  m_json_stopinfo = false;
1195  }
1196 
1197  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1198  ExecutionContext *execution_context) override {
1199  const int short_option = m_getopt_table[option_idx].val;
1200  Status error;
1201 
1202  switch (short_option) {
1203  case 'j':
1204  m_json_thread = true;
1205  break;
1206 
1207  case 's':
1208  m_json_stopinfo = true;
1209  break;
1210 
1211  default:
1212  llvm_unreachable("Unimplemented option");
1213  }
1214  return error;
1215  }
1216 
1217  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1218  return llvm::makeArrayRef(g_thread_info_options);
1219  }
1220 
1223  };
1224 
1227  interpreter, "thread info",
1228  "Show an extended summary of one or "
1229  "more threads. Defaults to the "
1230  "current thread.",
1231  "thread info",
1232  eCommandRequiresProcess | eCommandTryTargetAPILock |
1233  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
1234  m_options() {
1235  m_add_return = false;
1236  }
1237 
1238  ~CommandObjectThreadInfo() override = default;
1239 
1240  void
1242  OptionElementVector &opt_element_vector) override {
1243  CommandCompletions::InvokeCommonCompletionCallbacks(
1244  GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
1245  request, nullptr);
1246  }
1247 
1248  Options *GetOptions() override { return &m_options; }
1249 
1250  bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
1251  ThreadSP thread_sp =
1252  m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
1253  if (!thread_sp) {
1254  result.AppendErrorWithFormat("thread no longer exists: 0x%" PRIx64 "\n",
1255  tid);
1256  return false;
1257  }
1258 
1259  Thread *thread = thread_sp.get();
1260 
1261  Stream &strm = result.GetOutputStream();
1262  if (!thread->GetDescription(strm, eDescriptionLevelFull,
1263  m_options.m_json_thread,
1264  m_options.m_json_stopinfo)) {
1265  result.AppendErrorWithFormat("error displaying info for thread: \"%d\"\n",
1266  thread->GetIndexID());
1267  return false;
1268  }
1269  return true;
1270  }
1271 
1273 };
1274 
1275 // CommandObjectThreadException
1276 
1278 public:
1281  interpreter, "thread exception",
1282  "Display the current exception object for a thread. Defaults to "
1283  "the current thread.",
1284  "thread exception",
1285  eCommandRequiresProcess | eCommandTryTargetAPILock |
1286  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
1287 
1288  ~CommandObjectThreadException() override = default;
1289 
1290  void
1292  OptionElementVector &opt_element_vector) override {
1293  CommandCompletions::InvokeCommonCompletionCallbacks(
1294  GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
1295  request, nullptr);
1296  }
1297 
1298  bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
1299  ThreadSP thread_sp =
1300  m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
1301  if (!thread_sp) {
1302  result.AppendErrorWithFormat("thread no longer exists: 0x%" PRIx64 "\n",
1303  tid);
1304  return false;
1305  }
1306 
1307  Stream &strm = result.GetOutputStream();
1308  ValueObjectSP exception_object_sp = thread_sp->GetCurrentException();
1309  if (exception_object_sp) {
1310  exception_object_sp->Dump(strm);
1311  }
1312 
1313  ThreadSP exception_thread_sp = thread_sp->GetCurrentExceptionBacktrace();
1314  if (exception_thread_sp && exception_thread_sp->IsValid()) {
1315  const uint32_t num_frames_with_source = 0;
1316  const bool stop_format = false;
1317  exception_thread_sp->GetStatus(strm, 0, UINT32_MAX,
1318  num_frames_with_source, stop_format);
1319  }
1320 
1321  return true;
1322  }
1323 };
1324 
1325 // CommandObjectThreadReturn
1326 #define LLDB_OPTIONS_thread_return
1327 #include "CommandOptions.inc"
1328 
1330 public:
1331  class CommandOptions : public Options {
1332  public:
1334  // Keep default values of all options in one place: OptionParsingStarting
1335  // ()
1336  OptionParsingStarting(nullptr);
1337  }
1338 
1339  ~CommandOptions() override = default;
1340 
1341  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1342  ExecutionContext *execution_context) override {
1343  Status error;
1344  const int short_option = m_getopt_table[option_idx].val;
1345 
1346  switch (short_option) {
1347  case 'x': {
1348  bool success;
1349  bool tmp_value =
1350  OptionArgParser::ToBoolean(option_arg, false, &success);
1351  if (success)
1352  m_from_expression = tmp_value;
1353  else {
1354  error.SetErrorStringWithFormat(
1355  "invalid boolean value '%s' for 'x' option",
1356  option_arg.str().c_str());
1357  }
1358  } break;
1359  default:
1360  llvm_unreachable("Unimplemented option");
1361  }
1362  return error;
1363  }
1364 
1365  void OptionParsingStarting(ExecutionContext *execution_context) override {
1366  m_from_expression = false;
1367  }
1368 
1369  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1370  return llvm::makeArrayRef(g_thread_return_options);
1371  }
1372 
1373  bool m_from_expression = false;
1374 
1375  // Instance variables to hold the values for command options.
1376  };
1377 
1379  : CommandObjectRaw(interpreter, "thread return",
1380  "Prematurely return from a stack frame, "
1381  "short-circuiting execution of newer frames "
1382  "and optionally yielding a specified value. Defaults "
1383  "to the exiting the current stack "
1384  "frame.",
1385  "thread return",
1386  eCommandRequiresFrame | eCommandTryTargetAPILock |
1387  eCommandProcessMustBeLaunched |
1388  eCommandProcessMustBePaused),
1389  m_options() {
1391  CommandArgumentData expression_arg;
1392 
1393  // Define the first (and only) variant of this arg.
1394  expression_arg.arg_type = eArgTypeExpression;
1395  expression_arg.arg_repetition = eArgRepeatOptional;
1396 
1397  // There is only one variant this argument could be; put it into the
1398  // argument entry.
1399  arg.push_back(expression_arg);
1400 
1401  // Push the data for the first argument into the m_arguments vector.
1402  m_arguments.push_back(arg);
1403  }
1404 
1405  ~CommandObjectThreadReturn() override = default;
1406 
1407  Options *GetOptions() override { return &m_options; }
1408 
1409 protected:
1410  bool DoExecute(llvm::StringRef command,
1411  CommandReturnObject &result) override {
1412  // I am going to handle this by hand, because I don't want you to have to
1413  // say:
1414  // "thread return -- -5".
1415  if (command.startswith("-x")) {
1416  if (command.size() != 2U)
1417  result.AppendWarning("Return values ignored when returning from user "
1418  "called expressions");
1419 
1420  Thread *thread = m_exe_ctx.GetThreadPtr();
1421  Status error;
1422  error = thread->UnwindInnermostExpression();
1423  if (!error.Success()) {
1424  result.AppendErrorWithFormat("Unwinding expression failed - %s.",
1425  error.AsCString());
1426  } else {
1427  bool success =
1428  thread->SetSelectedFrameByIndexNoisily(0, result.GetOutputStream());
1429  if (success) {
1430  m_exe_ctx.SetFrameSP(thread->GetSelectedFrame());
1432  } else {
1433  result.AppendErrorWithFormat(
1434  "Could not select 0th frame after unwinding expression.");
1435  }
1436  }
1437  return result.Succeeded();
1438  }
1439 
1440  ValueObjectSP return_valobj_sp;
1441 
1442  StackFrameSP frame_sp = m_exe_ctx.GetFrameSP();
1443  uint32_t frame_idx = frame_sp->GetFrameIndex();
1444 
1445  if (frame_sp->IsInlined()) {
1446  result.AppendError("Don't know how to return from inlined frames.");
1447  return false;
1448  }
1449 
1450  if (!command.empty()) {
1451  Target *target = m_exe_ctx.GetTargetPtr();
1452  EvaluateExpressionOptions options;
1453 
1454  options.SetUnwindOnError(true);
1456 
1458  exe_results = target->EvaluateExpression(command, frame_sp.get(),
1459  return_valobj_sp, options);
1460  if (exe_results != eExpressionCompleted) {
1461  if (return_valobj_sp)
1462  result.AppendErrorWithFormat(
1463  "Error evaluating result expression: %s",
1464  return_valobj_sp->GetError().AsCString());
1465  else
1466  result.AppendErrorWithFormat(
1467  "Unknown error evaluating result expression.");
1468  return false;
1469  }
1470  }
1471 
1472  Status error;
1473  ThreadSP thread_sp = m_exe_ctx.GetThreadSP();
1474  const bool broadcast = true;
1475  error = thread_sp->ReturnFromFrame(frame_sp, return_valobj_sp, broadcast);
1476  if (!error.Success()) {
1477  result.AppendErrorWithFormat(
1478  "Error returning from frame %d of thread %d: %s.", frame_idx,
1479  thread_sp->GetIndexID(), error.AsCString());
1480  return false;
1481  }
1482 
1484  return true;
1485  }
1486 
1488 };
1489 
1490 // CommandObjectThreadJump
1491 #define LLDB_OPTIONS_thread_jump
1492 #include "CommandOptions.inc"
1493 
1495 public:
1496  class CommandOptions : public Options {
1497  public:
1498  CommandOptions() : Options() { OptionParsingStarting(nullptr); }
1499 
1500  ~CommandOptions() override = default;
1501 
1502  void OptionParsingStarting(ExecutionContext *execution_context) override {
1503  m_filenames.Clear();
1504  m_line_num = 0;
1505  m_line_offset = 0;
1506  m_load_addr = LLDB_INVALID_ADDRESS;
1507  m_force = false;
1508  }
1509 
1510  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1511  ExecutionContext *execution_context) override {
1512  const int short_option = m_getopt_table[option_idx].val;
1513  Status error;
1514 
1515  switch (short_option) {
1516  case 'f':
1517  m_filenames.AppendIfUnique(FileSpec(option_arg));
1518  if (m_filenames.GetSize() > 1)
1519  return Status("only one source file expected.");
1520  break;
1521  case 'l':
1522  if (option_arg.getAsInteger(0, m_line_num))
1523  return Status("invalid line number: '%s'.", option_arg.str().c_str());
1524  break;
1525  case 'b':
1526  if (option_arg.getAsInteger(0, m_line_offset))
1527  return Status("invalid line offset: '%s'.", option_arg.str().c_str());
1528  break;
1529  case 'a':
1530  m_load_addr = OptionArgParser::ToAddress(execution_context, option_arg,
1532  break;
1533  case 'r':
1534  m_force = true;
1535  break;
1536  default:
1537  llvm_unreachable("Unimplemented option");
1538  }
1539  return error;
1540  }
1541 
1542  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1543  return llvm::makeArrayRef(g_thread_jump_options);
1544  }
1545 
1546  FileSpecList m_filenames;
1548  int32_t m_line_offset;
1550  bool m_force;
1551  };
1552 
1555  interpreter, "thread jump",
1556  "Sets the program counter to a new address.", "thread jump",
1557  eCommandRequiresFrame | eCommandTryTargetAPILock |
1558  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
1559  m_options() {}
1560 
1561  ~CommandObjectThreadJump() override = default;
1562 
1563  Options *GetOptions() override { return &m_options; }
1564 
1565 protected:
1566  bool DoExecute(Args &args, CommandReturnObject &result) override {
1567  RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext();
1568  StackFrame *frame = m_exe_ctx.GetFramePtr();
1569  Thread *thread = m_exe_ctx.GetThreadPtr();
1570  Target *target = m_exe_ctx.GetTargetPtr();
1571  const SymbolContext &sym_ctx =
1572  frame->GetSymbolContext(eSymbolContextLineEntry);
1573 
1574  if (m_options.m_load_addr != LLDB_INVALID_ADDRESS) {
1575  // Use this address directly.
1576  Address dest = Address(m_options.m_load_addr);
1577 
1578  lldb::addr_t callAddr = dest.GetCallableLoadAddress(target);
1579  if (callAddr == LLDB_INVALID_ADDRESS) {
1580  result.AppendErrorWithFormat("Invalid destination address.");
1581  return false;
1582  }
1583 
1584  if (!reg_ctx->SetPC(callAddr)) {
1585  result.AppendErrorWithFormat("Error changing PC value for thread %d.",
1586  thread->GetIndexID());
1587  return false;
1588  }
1589  } else {
1590  // Pick either the absolute line, or work out a relative one.
1591  int32_t line = (int32_t)m_options.m_line_num;
1592  if (line == 0)
1593  line = sym_ctx.line_entry.line + m_options.m_line_offset;
1594 
1595  // Try the current file, but override if asked.
1596  FileSpec file = sym_ctx.line_entry.file;
1597  if (m_options.m_filenames.GetSize() == 1)
1598  file = m_options.m_filenames.GetFileSpecAtIndex(0);
1599 
1600  if (!file) {
1601  result.AppendErrorWithFormat(
1602  "No source file available for the current location.");
1603  return false;
1604  }
1605 
1606  std::string warnings;
1607  Status err = thread->JumpToLine(file, line, m_options.m_force, &warnings);
1608 
1609  if (err.Fail()) {
1610  result.SetError(err);
1611  return false;
1612  }
1613 
1614  if (!warnings.empty())
1615  result.AppendWarning(warnings.c_str());
1616  }
1617 
1619  return true;
1620  }
1621 
1623 };
1624 
1625 // Next are the subcommands of CommandObjectMultiwordThreadPlan
1626 
1627 // CommandObjectThreadPlanList
1628 #define LLDB_OPTIONS_thread_plan_list
1629 #include "CommandOptions.inc"
1630 
1632 public:
1633  class CommandOptions : public Options {
1634  public:
1636  // Keep default values of all options in one place: OptionParsingStarting
1637  // ()
1638  OptionParsingStarting(nullptr);
1639  }
1640 
1641  ~CommandOptions() override = default;
1642 
1643  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1644  ExecutionContext *execution_context) override {
1645  const int short_option = m_getopt_table[option_idx].val;
1646 
1647  switch (short_option) {
1648  case 'i':
1649  m_internal = true;
1650  break;
1651  case 't':
1652  lldb::tid_t tid;
1653  if (option_arg.getAsInteger(0, tid))
1654  return Status("invalid tid: '%s'.", option_arg.str().c_str());
1655  m_tids.push_back(tid);
1656  break;
1657  case 'u':
1658  m_unreported = false;
1659  break;
1660  case 'v':
1661  m_verbose = true;
1662  break;
1663  default:
1664  llvm_unreachable("Unimplemented option");
1665  }
1666  return {};
1667  }
1668 
1669  void OptionParsingStarting(ExecutionContext *execution_context) override {
1670  m_verbose = false;
1671  m_internal = false;
1672  m_unreported = true; // The variable is "skip unreported" and we want to
1673  // skip unreported by default.
1674  m_tids.clear();
1675  }
1676 
1677  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1678  return llvm::makeArrayRef(g_thread_plan_list_options);
1679  }
1680 
1681  // Instance variables to hold the values for command options.
1685  std::vector<lldb::tid_t> m_tids;
1686  };
1687 
1690  interpreter, "thread plan list",
1691  "Show thread plans for one or more threads. If no threads are "
1692  "specified, show the "
1693  "current thread. Use the thread-index \"all\" to see all threads.",
1694  nullptr,
1695  eCommandRequiresProcess | eCommandRequiresThread |
1696  eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
1697  eCommandProcessMustBePaused),
1698  m_options() {}
1699 
1700  ~CommandObjectThreadPlanList() override = default;
1701 
1702  Options *GetOptions() override { return &m_options; }
1703 
1704  bool DoExecute(Args &command, CommandReturnObject &result) override {
1705  // If we are reporting all threads, dispatch to the Process to do that:
1706  if (command.GetArgumentCount() == 0 && m_options.m_tids.empty()) {
1707  Stream &strm = result.GetOutputStream();
1708  DescriptionLevel desc_level = m_options.m_verbose
1711  m_exe_ctx.GetProcessPtr()->DumpThreadPlans(
1712  strm, desc_level, m_options.m_internal, true, m_options.m_unreported);
1714  return true;
1715  } else {
1716  // Do any TID's that the user may have specified as TID, then do any
1717  // Thread Indexes...
1718  if (!m_options.m_tids.empty()) {
1719  Process *process = m_exe_ctx.GetProcessPtr();
1720  StreamString tmp_strm;
1721  for (lldb::tid_t tid : m_options.m_tids) {
1722  bool success = process->DumpThreadPlansForTID(
1723  tmp_strm, tid, eDescriptionLevelFull, m_options.m_internal,
1724  true /* condense_trivial */, m_options.m_unreported);
1725  // If we didn't find a TID, stop here and return an error.
1726  if (!success) {
1727  result.AppendError("Error dumping plans:");
1728  result.AppendError(tmp_strm.GetString());
1729  return false;
1730  }
1731  // Otherwise, add our data to the output:
1732  result.GetOutputStream() << tmp_strm.GetString();
1733  }
1734  }
1735  return CommandObjectIterateOverThreads::DoExecute(command, result);
1736  }
1737  }
1738 
1739 protected:
1740  bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
1741  // If we have already handled this from a -t option, skip it here.
1742  if (llvm::is_contained(m_options.m_tids, tid))
1743  return true;
1744 
1745  Process *process = m_exe_ctx.GetProcessPtr();
1746 
1747  Stream &strm = result.GetOutputStream();
1749  if (m_options.m_verbose)
1750  desc_level = eDescriptionLevelVerbose;
1751 
1752  process->DumpThreadPlansForTID(strm, tid, desc_level, m_options.m_internal,
1753  true /* condense_trivial */,
1754  m_options.m_unreported);
1755  return true;
1756  }
1757 
1759 };
1760 
1762 public:
1764  : CommandObjectParsed(interpreter, "thread plan discard",
1765  "Discards thread plans up to and including the "
1766  "specified index (see 'thread plan list'.) "
1767  "Only user visible plans can be discarded.",
1768  nullptr,
1769  eCommandRequiresProcess | eCommandRequiresThread |
1770  eCommandTryTargetAPILock |
1771  eCommandProcessMustBeLaunched |
1772  eCommandProcessMustBePaused) {
1774  CommandArgumentData plan_index_arg;
1775 
1776  // Define the first (and only) variant of this arg.
1777  plan_index_arg.arg_type = eArgTypeUnsignedInteger;
1778  plan_index_arg.arg_repetition = eArgRepeatPlain;
1779 
1780  // There is only one variant this argument could be; put it into the
1781  // argument entry.
1782  arg.push_back(plan_index_arg);
1783 
1784  // Push the data for the first argument into the m_arguments vector.
1785  m_arguments.push_back(arg);
1786  }
1787 
1788  ~CommandObjectThreadPlanDiscard() override = default;
1789 
1790  void
1792  OptionElementVector &opt_element_vector) override {
1793  if (!m_exe_ctx.HasThreadScope() || request.GetCursorIndex())
1794  return;
1795 
1796  m_exe_ctx.GetThreadPtr()->AutoCompleteThreadPlans(request);
1797  }
1798 
1799  bool DoExecute(Args &args, CommandReturnObject &result) override {
1800  Thread *thread = m_exe_ctx.GetThreadPtr();
1801  if (args.GetArgumentCount() != 1) {
1802  result.AppendErrorWithFormat("Too many arguments, expected one - the "
1803  "thread plan index - but got %zu.",
1804  args.GetArgumentCount());
1805  return false;
1806  }
1807 
1808  uint32_t thread_plan_idx;
1809  if (!llvm::to_integer(args.GetArgumentAtIndex(0), thread_plan_idx)) {
1810  result.AppendErrorWithFormat(
1811  "Invalid thread index: \"%s\" - should be unsigned int.",
1812  args.GetArgumentAtIndex(0));
1813  return false;
1814  }
1815 
1816  if (thread_plan_idx == 0) {
1817  result.AppendErrorWithFormat(
1818  "You wouldn't really want me to discard the base thread plan.");
1819  return false;
1820  }
1821 
1822  if (thread->DiscardUserThreadPlansUpToIndex(thread_plan_idx)) {
1824  return true;
1825  } else {
1826  result.AppendErrorWithFormat(
1827  "Could not find User thread plan with index %s.",
1828  args.GetArgumentAtIndex(0));
1829  return false;
1830  }
1831  }
1832 };
1833 
1835 public:
1837  : CommandObjectParsed(interpreter, "thread plan prune",
1838  "Removes any thread plans associated with "
1839  "currently unreported threads. "
1840  "Specify one or more TID's to remove, or if no "
1841  "TID's are provides, remove threads for all "
1842  "unreported threads",
1843  nullptr,
1844  eCommandRequiresProcess |
1845  eCommandTryTargetAPILock |
1846  eCommandProcessMustBeLaunched |
1847  eCommandProcessMustBePaused) {
1849  CommandArgumentData tid_arg;
1850 
1851  // Define the first (and only) variant of this arg.
1852  tid_arg.arg_type = eArgTypeThreadID;
1853  tid_arg.arg_repetition = eArgRepeatStar;
1854 
1855  // There is only one variant this argument could be; put it into the
1856  // argument entry.
1857  arg.push_back(tid_arg);
1858 
1859  // Push the data for the first argument into the m_arguments vector.
1860  m_arguments.push_back(arg);
1861  }
1862 
1863  ~CommandObjectThreadPlanPrune() override = default;
1864 
1865  bool DoExecute(Args &args, CommandReturnObject &result) override {
1866  Process *process = m_exe_ctx.GetProcessPtr();
1867 
1868  if (args.GetArgumentCount() == 0) {
1869  process->PruneThreadPlans();
1871  return true;
1872  }
1873 
1874  const size_t num_args = args.GetArgumentCount();
1875 
1876  std::lock_guard<std::recursive_mutex> guard(
1877  process->GetThreadList().GetMutex());
1878 
1879  for (size_t i = 0; i < num_args; i++) {
1880  lldb::tid_t tid;
1881  if (!llvm::to_integer(args.GetArgumentAtIndex(i), tid)) {
1882  result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n",
1883  args.GetArgumentAtIndex(i));
1884  return false;
1885  }
1886  if (!process->PruneThreadPlansForTID(tid)) {
1887  result.AppendErrorWithFormat("Could not find unreported tid: \"%s\"\n",
1888  args.GetArgumentAtIndex(i));
1889  return false;
1890  }
1891  }
1893  return true;
1894  }
1895 };
1896 
1897 // CommandObjectMultiwordThreadPlan
1898 
1900 public:
1903  interpreter, "plan",
1904  "Commands for managing thread plans that control execution.",
1905  "thread plan <subcommand> [<subcommand objects]") {
1906  LoadSubCommand(
1907  "list", CommandObjectSP(new CommandObjectThreadPlanList(interpreter)));
1908  LoadSubCommand(
1909  "discard",
1910  CommandObjectSP(new CommandObjectThreadPlanDiscard(interpreter)));
1911  LoadSubCommand(
1912  "prune",
1913  CommandObjectSP(new CommandObjectThreadPlanPrune(interpreter)));
1914  }
1915 
1916  ~CommandObjectMultiwordThreadPlan() override = default;
1917 };
1918 
1919 // Next are the subcommands of CommandObjectMultiwordTrace
1920 
1921 // CommandObjectTraceExport
1922 
1924 public:
1927  interpreter, "trace thread export",
1928  "Commands for exporting traces of the threads in the current "
1929  "process to different formats.",
1930  "thread trace export <export-plugin> [<subcommand objects>]") {
1931 
1932  for (uint32_t i = 0; true; i++) {
1933  if (const char *plugin_name =
1934  PluginManager::GetTraceExporterPluginNameAtIndex(i)) {
1935  if (ThreadTraceExportCommandCreator command_creator =
1936  PluginManager::GetThreadTraceExportCommandCreatorAtIndex(i)) {
1937  LoadSubCommand(plugin_name, command_creator(interpreter));
1938  }
1939  } else {
1940  break;
1941  }
1942  }
1943  }
1944 };
1945 
1946 // CommandObjectTraceStart
1947 
1949 public:
1952  /*live_debug_session_only=*/true, interpreter, "thread trace start",
1953  "Start tracing threads with the corresponding trace "
1954  "plug-in for the current process.",
1955  "thread trace start [<trace-options>]") {}
1956 
1957 protected:
1958  lldb::CommandObjectSP GetDelegateCommand(Trace &trace) override {
1959  return trace.GetThreadTraceStartCommand(m_interpreter);
1960  }
1961 };
1962 
1963 // CommandObjectTraceStop
1964 
1966 public:
1969  interpreter, "thread trace stop",
1970  "Stop tracing threads, including the ones traced with the "
1971  "\"process trace start\" command."
1972  "Defaults to the current thread. Thread indices can be "
1973  "specified as arguments.\n Use the thread-index \"all\" to stop "
1974  "tracing "
1975  "for all existing threads.",
1976  "thread trace stop [<thread-index> <thread-index> ...]",
1977  eCommandRequiresProcess | eCommandTryTargetAPILock |
1978  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused |
1979  eCommandProcessMustBeTraced) {}
1980 
1981  ~CommandObjectTraceStop() override = default;
1982 
1984  llvm::ArrayRef<lldb::tid_t> tids) override {
1985  ProcessSP process_sp = m_exe_ctx.GetProcessSP();
1986 
1987  TraceSP trace_sp = process_sp->GetTarget().GetTrace();
1988 
1989  if (llvm::Error err = trace_sp->Stop(tids))
1990  result.AppendError(toString(std::move(err)));
1991  else
1993 
1994  return result.Succeeded();
1995  }
1996 };
1997 
1998 // CommandObjectTraceDumpInstructions
1999 #define LLDB_OPTIONS_thread_trace_dump_instructions
2000 #include "CommandOptions.inc"
2001 
2004 public:
2005  class CommandOptions : public Options {
2006  public:
2007  CommandOptions() : Options() { OptionParsingStarting(nullptr); }
2008 
2009  ~CommandOptions() override = default;
2010 
2011  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2012  ExecutionContext *execution_context) override {
2013  Status error;
2014  const int short_option = m_getopt_table[option_idx].val;
2015 
2016  switch (short_option) {
2017  case 'c': {
2018  int32_t count;
2019  if (option_arg.empty() || option_arg.getAsInteger(0, count) ||
2020  count < 0)
2021  error.SetErrorStringWithFormat(
2022  "invalid integer value for option '%s'",
2023  option_arg.str().c_str());
2024  else
2025  m_count = count;
2026  break;
2027  }
2028  case 's': {
2029  int32_t skip;
2030  if (option_arg.empty() || option_arg.getAsInteger(0, skip) || skip < 0)
2031  error.SetErrorStringWithFormat(
2032  "invalid integer value for option '%s'",
2033  option_arg.str().c_str());
2034  else
2035  m_skip = skip;
2036  break;
2037  }
2038  case 'r': {
2039  m_raw = true;
2040  break;
2041  }
2042  case 'f': {
2043  m_forwards = true;
2044  break;
2045  }
2046  case 't': {
2047  m_show_tsc = true;
2048  break;
2049  }
2050  default:
2051  llvm_unreachable("Unimplemented option");
2052  }
2053  return error;
2054  }
2055 
2056  void OptionParsingStarting(ExecutionContext *execution_context) override {
2057  m_count = kDefaultCount;
2058  m_skip = 0;
2059  m_raw = false;
2060  m_forwards = false;
2061  m_show_tsc = false;
2062  }
2063 
2064  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2065  return llvm::makeArrayRef(g_thread_trace_dump_instructions_options);
2066  }
2067 
2068  static const size_t kDefaultCount = 20;
2069 
2070  // Instance variables to hold the values for command options.
2071  size_t m_count;
2072  size_t m_skip;
2073  bool m_raw;
2076  };
2077 
2080  interpreter, "thread trace dump instructions",
2081  "Dump the traced instructions for one or more threads. If no "
2082  "threads are specified, show the current thread. Use the "
2083  "thread-index \"all\" to see all threads.",
2084  nullptr,
2085  eCommandRequiresProcess | eCommandTryTargetAPILock |
2086  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused |
2087  eCommandProcessMustBeTraced),
2088  m_options(), m_create_repeat_command_just_invoked(false) {}
2089 
2090  ~CommandObjectTraceDumpInstructions() override = default;
2091 
2092  Options *GetOptions() override { return &m_options; }
2093 
2094  const char *GetRepeatCommand(Args &current_command_args,
2095  uint32_t index) override {
2096  current_command_args.GetCommandString(m_repeat_command);
2097  m_create_repeat_command_just_invoked = true;
2098  return m_repeat_command.c_str();
2099  }
2100 
2101 protected:
2102  bool DoExecute(Args &args, CommandReturnObject &result) override {
2103  if (!IsRepeatCommand())
2104  m_dumpers.clear();
2105 
2106  bool status = CommandObjectIterateOverThreads::DoExecute(args, result);
2107 
2108  m_create_repeat_command_just_invoked = false;
2109  return status;
2110  }
2111 
2113  return !m_repeat_command.empty() && !m_create_repeat_command_just_invoked;
2114  }
2115 
2116  bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
2117  Stream &s = result.GetOutputStream();
2118 
2119  const TraceSP &trace_sp = m_exe_ctx.GetTargetSP()->GetTrace();
2120  ThreadSP thread_sp =
2121  m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
2122 
2123  if (!m_dumpers.count(thread_sp->GetID())) {
2124  lldb::TraceCursorUP cursor_up = trace_sp->GetCursor(*thread_sp);
2125  // Set up the cursor and return the presentation index of the first
2126  // instruction to dump after skipping instructions.
2127  auto setUpCursor = [&]() {
2128  cursor_up->SetForwards(m_options.m_forwards);
2129  if (m_options.m_forwards)
2130  return cursor_up->Seek(m_options.m_skip, TraceCursor::SeekType::Set);
2131  return -cursor_up->Seek(-m_options.m_skip, TraceCursor::SeekType::End);
2132  };
2133 
2134  int initial_index = setUpCursor();
2135 
2136  auto dumper = std::make_unique<TraceInstructionDumper>(
2137  std::move(cursor_up), initial_index, m_options.m_raw,
2138  m_options.m_show_tsc);
2139 
2140  // This happens when the seek value was more than the number of available
2141  // instructions.
2142  if (std::abs(initial_index) < (int)m_options.m_skip)
2143  dumper->SetNoMoreData();
2144 
2145  m_dumpers[thread_sp->GetID()] = std::move(dumper);
2146  }
2147 
2148  m_dumpers[thread_sp->GetID()]->DumpInstructions(s, m_options.m_count);
2149  return true;
2150  }
2151 
2153 
2154  // Repeat command helpers
2157  std::map<lldb::tid_t, std::unique_ptr<TraceInstructionDumper>> m_dumpers;
2158 };
2159 
2160 // CommandObjectTraceDumpInfo
2161 #define LLDB_OPTIONS_thread_trace_dump_info
2162 #include "CommandOptions.inc"
2163 
2165 public:
2166  class CommandOptions : public Options {
2167  public:
2168  CommandOptions() : Options() { OptionParsingStarting(nullptr); }
2169 
2170  ~CommandOptions() override = default;
2171 
2172  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2173  ExecutionContext *execution_context) override {
2174  Status error;
2175  const int short_option = m_getopt_table[option_idx].val;
2176 
2177  switch (short_option) {
2178  case 'v': {
2179  m_verbose = true;
2180  break;
2181  }
2182  default:
2183  llvm_unreachable("Unimplemented option");
2184  }
2185  return error;
2186  }
2187 
2188  void OptionParsingStarting(ExecutionContext *execution_context) override {
2189  m_verbose = false;
2190  }
2191 
2192  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2193  return llvm::makeArrayRef(g_thread_trace_dump_info_options);
2194  }
2195 
2196  // Instance variables to hold the values for command options.
2198  };
2199 
2200  bool DoExecute(Args &command, CommandReturnObject &result) override {
2201  Target &target = m_exe_ctx.GetTargetRef();
2202  result.GetOutputStream().Format("Trace technology: {0}\n",
2203  target.GetTrace()->GetPluginName());
2204  return CommandObjectIterateOverThreads::DoExecute(command, result);
2205  }
2206 
2209  interpreter, "thread trace dump info",
2210  "Dump the traced information for one or more threads. If no "
2211  "threads are specified, show the current thread. Use the "
2212  "thread-index \"all\" to see all threads.",
2213  nullptr,
2214  eCommandRequiresProcess | eCommandTryTargetAPILock |
2215  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused |
2216  eCommandProcessMustBeTraced),
2217  m_options() {}
2218 
2219  ~CommandObjectTraceDumpInfo() override = default;
2220 
2221  Options *GetOptions() override { return &m_options; }
2222 
2223 protected:
2224  bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
2225  const TraceSP &trace_sp = m_exe_ctx.GetTargetSP()->GetTrace();
2226  ThreadSP thread_sp =
2227  m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
2228  trace_sp->DumpTraceInfo(*thread_sp, result.GetOutputStream(),
2229  m_options.m_verbose);
2230  return true;
2231  }
2232 
2234 };
2235 
2236 // CommandObjectMultiwordTraceDump
2238 public:
2241  interpreter, "dump",
2242  "Commands for displaying trace information of the threads "
2243  "in the current process.",
2244  "thread trace dump <subcommand> [<subcommand objects>]") {
2245  LoadSubCommand(
2246  "instructions",
2247  CommandObjectSP(new CommandObjectTraceDumpInstructions(interpreter)));
2248  LoadSubCommand(
2249  "info", CommandObjectSP(new CommandObjectTraceDumpInfo(interpreter)));
2250  }
2251  ~CommandObjectMultiwordTraceDump() override = default;
2252 };
2253 
2254 // CommandObjectMultiwordTrace
2256 public:
2259  interpreter, "trace",
2260  "Commands for operating on traces of the threads in the current "
2261  "process.",
2262  "thread trace <subcommand> [<subcommand objects>]") {
2263  LoadSubCommand("dump", CommandObjectSP(new CommandObjectMultiwordTraceDump(
2264  interpreter)));
2265  LoadSubCommand("start",
2266  CommandObjectSP(new CommandObjectTraceStart(interpreter)));
2267  LoadSubCommand("stop",
2268  CommandObjectSP(new CommandObjectTraceStop(interpreter)));
2269  LoadSubCommand("export",
2270  CommandObjectSP(new CommandObjectTraceExport(interpreter)));
2271  }
2272 
2273  ~CommandObjectMultiwordTrace() override = default;
2274 };
2275 
2276 // CommandObjectMultiwordThread
2277 
2278 CommandObjectMultiwordThread::CommandObjectMultiwordThread(
2279  CommandInterpreter &interpreter)
2280  : CommandObjectMultiword(interpreter, "thread",
2281  "Commands for operating on "
2282  "one or more threads in "
2283  "the current process.",
2284  "thread <subcommand> [<subcommand-options>]") {
2285  LoadSubCommand("backtrace", CommandObjectSP(new CommandObjectThreadBacktrace(
2286  interpreter)));
2287  LoadSubCommand("continue",
2288  CommandObjectSP(new CommandObjectThreadContinue(interpreter)));
2289  LoadSubCommand("list",
2290  CommandObjectSP(new CommandObjectThreadList(interpreter)));
2291  LoadSubCommand("return",
2292  CommandObjectSP(new CommandObjectThreadReturn(interpreter)));
2293  LoadSubCommand("jump",
2294  CommandObjectSP(new CommandObjectThreadJump(interpreter)));
2295  LoadSubCommand("select",
2296  CommandObjectSP(new CommandObjectThreadSelect(interpreter)));
2297  LoadSubCommand("until",
2298  CommandObjectSP(new CommandObjectThreadUntil(interpreter)));
2299  LoadSubCommand("info",
2300  CommandObjectSP(new CommandObjectThreadInfo(interpreter)));
2301  LoadSubCommand("exception", CommandObjectSP(new CommandObjectThreadException(
2302  interpreter)));
2303  LoadSubCommand("step-in",
2304  CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
2305  interpreter, "thread step-in",
2306  "Source level single step, stepping into calls. Defaults "
2307  "to current thread unless specified.",
2308  nullptr, eStepTypeInto, eStepScopeSource)));
2309 
2310  LoadSubCommand("step-out",
2311  CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
2312  interpreter, "thread step-out",
2313  "Finish executing the current stack frame and stop after "
2314  "returning. Defaults to current thread unless specified.",
2315  nullptr, eStepTypeOut, eStepScopeSource)));
2316 
2317  LoadSubCommand("step-over",
2318  CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
2319  interpreter, "thread step-over",
2320  "Source level single step, stepping over calls. Defaults "
2321  "to current thread unless specified.",
2322  nullptr, eStepTypeOver, eStepScopeSource)));
2323 
2324  LoadSubCommand("step-inst",
2325  CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
2326  interpreter, "thread step-inst",
2327  "Instruction level single step, stepping into calls. "
2328  "Defaults to current thread unless specified.",
2330 
2331  LoadSubCommand("step-inst-over",
2332  CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
2333  interpreter, "thread step-inst-over",
2334  "Instruction level single step, stepping over calls. "
2335  "Defaults to current thread unless specified.",
2337 
2339  "step-scripted",
2340  CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
2341  interpreter, "thread step-scripted",
2342  "Step as instructed by the script class passed in the -C option. "
2343  "You can also specify a dictionary of key (-k) and value (-v) pairs "
2344  "that will be used to populate an SBStructuredData Dictionary, which "
2345  "will be passed to the constructor of the class implementing the "
2346  "scripted step. See the Python Reference for more details.",
2347  nullptr, eStepTypeScripted, eStepScopeSource)));
2348 
2349  LoadSubCommand("plan", CommandObjectSP(new CommandObjectMultiwordThreadPlan(
2350  interpreter)));
2351  LoadSubCommand("trace",
2352  CommandObjectSP(new CommandObjectMultiwordTrace(interpreter)));
2353 }
2354 
lldb_private::toString
const char * toString(AppleArm64ExceptionClass EC)
Definition: AppleArm64ExceptionClass.h:38
lldb::eArgTypeThreadID
@ eArgTypeThreadID
Definition: lldb-enumerations.h:586
eStepScopeInstruction
@ eStepScopeInstruction
Definition: CommandObjectThread.cpp:189
lldb_private::eArgRepeatOptional
@ eArgRepeatOptional
Definition: lldb-private-enumerations.h:96
lldb_private::LineTable::FindLineEntryByAddress
bool FindLineEntryByAddress(const Address &so_addr, LineEntry &line_entry, uint32_t *index_ptr=nullptr)
Find a line entry that contains the section offset address so_addr.
Definition: LineTable.cpp:188
CommandObjectThreadPlanList::CommandOptions::m_tids
std::vector< lldb::tid_t > m_tids
Definition: CommandObjectThread.cpp:1685
lldb::eArgTypeThreadIndex
@ eArgTypeThreadIndex
Definition: lldb-enumerations.h:587
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
CommandObjectThreadJump::DoExecute
bool DoExecute(Args &args, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1566
lldb_private::Stream::Format
void Format(const char *format, Args &&... args)
Definition: Stream.h:309
lldb_private::CommandObjectParsed
Definition: CommandObject.h:394
lldb_private::OptionGroupPythonClassWithDict
Definition: OptionGroupPythonClassWithDict.h:25
lldb_private::Block::GetRangeContainingAddress
bool GetRangeContainingAddress(const Address &addr, AddressRange &range)
Definition: Block.cpp:239
lldb_private::SymbolContext::block
Block * block
The Block for a given query.
Definition: SymbolContext.h:321
CommandObjectTraceDumpInstructions::GetOptions
Options * GetOptions() override
Definition: CommandObjectThread.cpp:2092
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
CommandObjectThreadPlanList::CommandOptions
Definition: CommandObjectThread.cpp:1633
lldb_private::SymbolContext::comp_unit
CompileUnit * comp_unit
The CompileUnit for a given query.
Definition: SymbolContext.h:319
CommandObjectThreadPlanList::m_options
CommandOptions m_options
Definition: CommandObjectThread.cpp:1758
CommandObjectThreadPlanList::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectThread.cpp:1677
CommandObjectThreadPlanList::HandleOneThread
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1740
lldb_private::LineEntry::file
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
CommandObjectThreadContinue::CommandObjectThreadContinue
CommandObjectThreadContinue(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:595
lldb_private::Process::GetThreadStatus
size_t GetThreadStatus(Stream &ostrm, bool only_threads_with_stop_reason, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format)
Definition: Process.cpp:5504
lldb_private::Process::GetStatus
void GetStatus(Stream &ostrm)
Definition: Process.cpp:5484
lldb_private::Thread::SetResumeState
void SetResumeState(lldb::StateType state, bool override_suspend=false)
Sets the USER resume state for this thread.
Definition: Thread.h:182
lldb_private::ThreadPlanStepInRange::SetAvoidRegexp
void SetAvoidRegexp(const char *name)
Definition: ThreadPlanStepInRange.cpp:293
CommandObjectTraceDumpInstructions::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectThread.cpp:2011
CommandObjectThreadBacktrace::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectThread.cpp:50
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:336
CommandObjectTraceDumpInstructions::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectThread.cpp:2064
lldb_private::eArgRepeatPlain
@ eArgRepeatPlain
Definition: lldb-private-enumerations.h:95
lldb_private::Thread::GetIndexID
uint32_t GetIndexID() const
Definition: Thread.cpp:1387
lldb_private::CommandReturnObject::SetError
void SetError(const Status &error, const char *fallback_error_cstr=nullptr)
Definition: CommandReturnObject.cpp:107
lldb_private::Thread::GetDescription
bool GetDescription(Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo)
Definition: Thread.cpp:1766
CommandObjectTraceDumpInfo::CommandOptions
Definition: CommandObjectThread.cpp:2166
CompileUnit.h
CommandObjectThreadStepWithTypeAndScope::m_options
ThreadStepScopeOptionGroup m_options
Definition: CommandObjectThread.cpp:586
ThreadStepScopeOptionGroup::m_step_count
uint32_t m_step_count
Definition: CommandObjectThread.cpp:313
CommandObjectThreadStepWithTypeAndScope::m_step_type
StepType m_step_type
Definition: CommandObjectThread.cpp:584
CommandObjectTraceDumpInfo
Definition: CommandObjectThread.cpp:2164
lldb_private::Function::GetAddressRange
const AddressRange & GetAddressRange()
Definition: Function.h:461
CommandObjectThreadPlanDiscard::CommandObjectThreadPlanDiscard
CommandObjectThreadPlanDiscard(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1763
lldb::eNoDynamicValues
@ eNoDynamicValues
Definition: lldb-enumerations.h:495
lldb_private::eVoteYes
@ eVoteYes
Definition: lldb-private-enumerations.h:59
CommandObjectTraceDumpInstructions::CommandOptions::m_skip
size_t m_skip
Definition: CommandObjectThread.cpp:2072
CommandObjectThreadReturn::CommandObjectThreadReturn
CommandObjectThreadReturn(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1378
ThreadStepScopeOptionGroup::m_end_line_is_block_end
bool m_end_line_is_block_end
Definition: CommandObjectThread.cpp:315
CommandObjectThreadSelect::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectThread.cpp:1103
CommandObjectThreadContinue::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:629
CommandObjectTraceDumpInstructions::m_repeat_command
std::string m_repeat_command
Definition: CommandObjectThread.cpp:2155
CommandObjectThreadPlanList::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1704
lldb_private::Thread::QueueThreadPlanForStepOverRange
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:1246
lldb::ExpressionResults
ExpressionResults
The results of expression evaluation.
Definition: lldb-enumerations.h:270
CommandObjectThreadBacktrace::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectThread.cpp:58
lldb_private::Thread::JumpToLine
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
Definition: Thread.cpp:1543
ThreadStepScopeOptionGroup::m_step_in_target
std::string m_step_in_target
Definition: CommandObjectThread.cpp:312
lldb_private::Process::PruneThreadPlans
void PruneThreadPlans()
Prune ThreadPlanStacks for all unreported threads.
Definition: Process.cpp:1234
lldb_private::Process::DumpThreadPlansForTID
bool DumpThreadPlansForTID(Stream &strm, lldb::tid_t tid, lldb::DescriptionLevel desc_level, bool internal, bool condense_trivial, bool skip_unreported_plans)
Dump the thread plans associated with thread with tid.
Definition: Process.cpp:1238
CommandObjectMultiwordTraceDump
Definition: CommandObjectThread.cpp:2237
lldb_private::StackFrame::GetFrameCodeAddress
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
Definition: StackFrame.cpp:188
CommandObjectThreadInfo::CommandObjectThreadInfo
CommandObjectThreadInfo(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1225
lldb_private::eLazyBoolYes
@ eLazyBoolYes
Definition: lldb-private-enumerations.h:115
CommandObjectThreadPlanDiscard::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectThread.cpp:1791
lldb_private::Thread::QueueThreadPlanForStepOut
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut(bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote report_stop_vote, Vote report_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:1303
CommandObjectThreadPlanList::CommandOptions::m_unreported
bool m_unreported
Definition: CommandObjectThread.cpp:1684
CommandObjectThreadStepWithTypeAndScope::CommandObjectThreadStepWithTypeAndScope
CommandObjectThreadStepWithTypeAndScope(CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax, StepType step_type, StepScope step_scope)
Definition: CommandObjectThread.cpp:320
lldb_private::Process
Definition: Process.h:341
lldb_private::Thread::GetSelectedFrameIndex
uint32_t GetSelectedFrameIndex()
Definition: Thread.h:429
CommandObjectThreadException
Definition: CommandObjectThread.cpp:1277
skip
static bool skip(llvm::StringRef data)
Check if we should reply to the given packet.
Definition: GDBRemoteCommunicationReplayServer.cpp:54
CommandObjectThreadUntil::CommandOptions::m_step_thread_idx
uint32_t m_step_thread_idx
Definition: CommandObjectThread.cpp:846
lldb_private::OptionGroupOptions
Definition: Options.h:255
lldb_private::AddressRange::GetByteSize
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
Definition: AddressRange.h:221
lldb_private::eStepTypeOut
@ eStepTypeOut
Single step out a specified context.
Definition: lldb-private-enumerations.h:25
CommandObjectThreadJump::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:1502
lldb_private::Process::GetThreadList
ThreadList & GetThreadList()
Definition: Process.h:2108
CommandObjectTraceDumpInfo::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectThread.cpp:2172
lldb_private::CommandObject::CommandArgumentData
Definition: CommandObject.h:89
ThreadStepScopeOptionGroup::m_run_mode
RunMode m_run_mode
Definition: CommandObjectThread.cpp:310
lldb_private::OptionGroup
Definition: Options.h:233
lldb_private::EvaluateExpressionOptions
Definition: Target.h:259
lldb_private::StateAsCString
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
CommandObjectThreadJump::CommandOptions::m_line_offset
int32_t m_line_offset
Definition: CommandObjectThread.cpp:1548
CommandObjectTraceDumpInstructions::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:2056
lldb_private::Thread::UnwindInnermostExpression
Status UnwindInnermostExpression()
Unwinds the thread stack for the innermost expression plan currently on the thread plan stack.
Definition: Thread.cpp:1220
CommandObjectTraceDumpInstructions::HandleOneThread
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:2116
lldb_private::Thread::DiscardUserThreadPlansUpToIndex
bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index)
Discards the plans queued on the plan stack of the current thread up to and including the plan in tha...
Definition: Thread.cpp:1179
lldb::eExpressionSetupError
@ eExpressionSetupError
Definition: lldb-enumerations.h:272
CommandObjectTraceDumpInstructions::m_dumpers
std::map< lldb::tid_t, std::unique_ptr< TraceInstructionDumper > > m_dumpers
Definition: CommandObjectThread.cpp:2157
lldb::eArgTypeExpression
@ eArgTypeExpression
Definition: lldb-enumerations.h:533
OptionArgParser.h
lldb_private::SystemRuntime
Definition: SystemRuntime.h:43
Trace.h
CommandObjectThreadContinue
Definition: CommandObjectThread.cpp:593
lldb_private::CommandObject::CommandArgumentData::arg_repetition
ArgumentRepetitionType arg_repetition
Definition: CommandObject.h:92
ThreadStepScopeOptionGroup::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:218
lldb_private::eVoteNoOpinion
@ eVoteNoOpinion
Definition: lldb-private-enumerations.h:59
CommandObjectThreadBacktrace::CommandOptions::m_extended_backtrace
bool m_extended_backtrace
Definition: CommandObjectThread.cpp:105
CommandObjectTraceDumpInstructions::m_options
CommandOptions m_options
Definition: CommandObjectThread.cpp:2152
CommandObjectTraceDumpInfo::GetOptions
Options * GetOptions() override
Definition: CommandObjectThread.cpp:2221
CommandObjectThreadSelect::CommandObjectThreadSelect
CommandObjectThreadSelect(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1079
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
CommandObjectTraceStop
Definition: CommandObjectThread.cpp:1965
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
CommandObjectThreadPlanList::CommandObjectThreadPlanList
CommandObjectThreadPlanList(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1688
lldb_private::LazyBool
LazyBool
Definition: lldb-private-enumerations.h:115
CommandObjectMultiwordThreadPlan
Definition: CommandObjectThread.cpp:1899
TraceInstructionDumper.h
lldb::eArgTypeLineNum
@ eArgTypeLineNum
Definition: lldb-enumerations.h:547
lldb_private::eArgRepeatPlus
@ eArgRepeatPlus
Definition: lldb-private-enumerations.h:97
CommandReturnObject.h
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:451
CommandObjectTraceDumpInfo::CommandOptions::m_verbose
bool m_verbose
Definition: CommandObjectThread.cpp:2197
lldb_private::StackFrame::HasDebugInformation
bool HasDebugInformation()
Determine whether this StackFrame has debug information available or not.
Definition: StackFrame.cpp:1133
lldb_private::CommandObjectTraceProxy
This class works by delegating the logic to the actual trace plug-in that can support the current pro...
Definition: CommandObjectTrace.h:25
CommandObjectThreadPlanDiscard
Definition: CommandObjectThread.cpp:1761
CommandObjectThreadBacktrace::DoExtendedBacktrace
void DoExtendedBacktrace(Thread *thread, CommandReturnObject &result)
Definition: CommandObjectThread.cpp:130
CommandObjectTrace.h
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
eStepScopeSource
@ eStepScopeSource
Definition: CommandObjectThread.cpp:189
CommandObjectThreadJump::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectThread.cpp:1542
lldb_private::Process::GetState
lldb::StateType GetState()
Get accessor for the current process state.
Definition: Process.cpp:1295
CommandObjectThreadJump::CommandOptions::m_line_num
uint32_t m_line_num
Definition: CommandObjectThread.cpp:1547
lldb_private::Process::GetIOHandlerID
uint32_t GetIOHandlerID() const
Definition: Process.h:2160
Process.h
g_duo_running_mode
static constexpr OptionEnumValueElement g_duo_running_mode[]
Definition: CommandObjectThread.cpp:765
lldb::eReturnStatusSuccessFinishNoResult
@ eReturnStatusSuccessFinishNoResult
Definition: lldb-enumerations.h:260
CommandObjectThreadJump::CommandOptions
Definition: CommandObjectThread.cpp:1496
CommandObjectThreadBacktrace::m_options
CommandOptions m_options
Definition: CommandObjectThread.cpp:186
lldb::eStateStopped
@ eStateStopped
Process or thread is stopped and can be examined.
Definition: lldb-enumerations.h:84
Target.h
LLDB_INVALID_FRAME_ID
#define LLDB_INVALID_FRAME_ID
Definition: lldb-defines.h:95
ThreadStepScopeOptionGroup::m_step_in_avoid_no_debug
LazyBool m_step_in_avoid_no_debug
Definition: CommandObjectThread.cpp:308
lldb_private::eStepTypeScripted
@ eStepTypeScripted
A step type implemented by the script interpreter.
Definition: lldb-private-enumerations.h:26
CommandObjectThreadReturn::CommandOptions
Definition: CommandObjectThread.cpp:1331
lldb_private::Trace
Definition: Trace.h:46
lldb_private::Thread::GetProcess
lldb::ProcessSP GetProcess() const
Definition: Thread.h:152
CommandObjectThreadStepWithTypeAndScope::m_all_options
OptionGroupOptions m_all_options
Definition: CommandObjectThread.cpp:588
CommandObjectThreadPlanList::CommandOptions::m_verbose
bool m_verbose
Definition: CommandObjectThread.cpp:1682
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::CommandObjectMultiword
Definition: CommandObjectMultiword.h:19
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
Options.h
lldb_private::StreamString::GetSize
size_t GetSize() const
Definition: StreamString.cpp:38
lldb_private::ThreadList::SetSelectedThreadByID
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
Definition: ThreadList.cpp:660
lldb_private::LineTable
Definition: LineTable.h:40
ThreadStepScopeOptionGroup::ThreadStepScopeOptionGroup
ThreadStepScopeOptionGroup()
Definition: CommandObjectThread.cpp:206
CommandObjectTraceDumpInstructions::CommandOptions::m_count
size_t m_count
Definition: CommandObjectThread.cpp:2071
lldb::eStateCrashed
@ eStateCrashed
Process or thread has crashed and can be examined.
Definition: lldb-enumerations.h:88
lldb_private::Options
Definition: Options.h:57
lldb_private::eStepTypeOver
@ eStepTypeOver
Single step over a specified context.
Definition: lldb-private-enumerations.h:24
CommandObjectTraceDumpInfo::m_options
CommandOptions m_options
Definition: CommandObjectThread.cpp:2233
CommandObjectThreadUntil::CommandOptions::m_until_addrs
std::vector< lldb::addr_t > m_until_addrs
Definition: CommandObjectThread.cpp:848
CommandObjectThreadInfo::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectThread.cpp:1217
lldb_private::SystemRuntime::GetExtendedBacktraceTypes
virtual const std::vector< ConstString > & GetExtendedBacktraceTypes()
Return a list of thread origin extended backtraces that may be available.
Definition: SystemRuntime.cpp:42
OptionGroupPythonClassWithDict.h
CommandObjectThreadReturn::DoExecute
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1410
CommandObjectThreadPlanList
Definition: CommandObjectThread.cpp:1631
lldb_private::Thread
Definition: Thread.h:60
lldb_private::CommandObjectMultiword::LoadSubCommand
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
Definition: CommandObjectMultiword.cpp:80
CommandObjectThreadJump::CommandObjectThreadJump
CommandObjectThreadJump(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1553
LLDB_OPT_SET_1
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:113
lldb_private::CommandReturnObject::SetStatus
void SetStatus(lldb::ReturnStatus status)
Definition: CommandReturnObject.cpp:121
CommandObjectThreadBacktrace
Definition: CommandObjectThread.cpp:46
CommandObjectThreadJump::CommandOptions::m_load_addr
lldb::addr_t m_load_addr
Definition: CommandObjectThread.cpp:1549
lldb_private::Address::GetCallableLoadAddress
lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect=false) const
Get the load address as a callable code load address.
Definition: Address.cpp:335
lldb_private::eStepTypeInto
@ eStepTypeInto
Single step into a specified context.
Definition: lldb-private-enumerations.h:23
LineEntry.h
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:182
lldb::eExpressionCompleted
@ eExpressionCompleted
Definition: lldb-enumerations.h:271
CommandObjectThreadStepWithTypeAndScope::m_class_options
OptionGroupPythonClassWithDict m_class_options
Definition: CommandObjectThread.cpp:587
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
CommandObjectThreadReturn::GetOptions
Options * GetOptions() override
Definition: CommandObjectThread.cpp:1407
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:290
CommandObjectTraceDumpInstructions::CommandOptions::m_forwards
bool m_forwards
Definition: CommandObjectThread.cpp:2074
lldb_private::CommandReturnObject::GetOutputStream
Stream & GetOutputStream()
Definition: CommandReturnObject.h:45
CommandObjectThreadBacktrace::GetOptions
Options * GetOptions() override
Definition: CommandObjectThread.cpp:127
lldb_private::StreamString
Definition: StreamString.h:23
CommandObjectThreadStepWithTypeAndScope::GetOptions
Options * GetOptions() override
Definition: CommandObjectThread.cpp:367
CommandObjectThreadStepWithTypeAndScope::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:370
CommandObjectThreadPlanList::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectThread.cpp:1643
lldb::eDescriptionLevelFull
@ eDescriptionLevelFull
Definition: lldb-enumerations.h:209
lldb_private::Args::entries
llvm::ArrayRef< ArgEntry > entries() const
Definition: Args.h:130
lldb_private::AddressRange
Definition: AddressRange.h:25
CommandObjectTraceDumpInfo::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectThread.cpp:2192
CommandObjectTraceDumpInfo::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:2188
CommandObjectThreadList
Definition: CommandObjectThread.cpp:1150
CommandObjectThreadInfo
Definition: CommandObjectThread.cpp:1184
lldb_private::Thread::QueueThreadPlanForStepInRange
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:1273
lldb_private::ThreadList::GetMutex
std::recursive_mutex & GetMutex() const override
Definition: ThreadList.cpp:748
CommandObjectThreadInfo::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectThread.cpp:1241
CommandObjectMultiwordTrace::CommandObjectMultiwordTrace
CommandObjectMultiwordTrace(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:2257
TriRunningModes
static constexpr OptionEnumValues TriRunningModes()
Definition: CommandObjectThread.cpp:197
lldb_private::Trace::GetThreadTraceStartCommand
virtual lldb::CommandObjectSP GetThreadTraceStartCommand(CommandInterpreter &interpreter)=0
Get the command handle for the "thread trace start" command.
CommandObjectThreadUntil::CommandOptions
Definition: CommandObjectThread.cpp:778
ThreadStepScopeOptionGroup::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectThread.cpp:214
if
if(CMAKE_SYSTEM_NAME MATCHES "Windows") add_definitions(-DEXPORT_LIBLLDB) endif() get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS) if(LLDB_BUILD_FRAMEWORK) set(option_install_prefix INSTALL_PREFIX $
Definition: API/CMakeLists.txt:1
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::eArgRepeatStar
@ eArgRepeatStar
Definition: lldb-private-enumerations.h:98
lldb_private::RegisterContext::SetPC
bool SetPC(uint64_t pc)
Definition: RegisterContext.cpp:112
lldb_private::CommandObjectMultipleThreads
Class similar to CommandObjectIterateOverThreads, but which performs an action on multiple threads at...
Definition: CommandObjectThreadUtil.h:81
lldb_private::Process::ResumeSynchronous
Status ResumeSynchronous(Stream *stream)
Definition: Process.cpp:1359
lldb_private::Process::PruneThreadPlansForTID
bool PruneThreadPlansForTID(lldb::tid_t tid)
Prune ThreadPlanStacks for unreported threads.
Definition: Process.cpp:1230
CommandObjectThreadInfo::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:1192
CommandObjectThread.h
CommandObjectThreadException::CommandObjectThreadException
CommandObjectThreadException(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1279
CommandObjectTraceStart
Definition: CommandObjectThread.cpp:1948
CommandObjectThreadException::HandleOneThread
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1298
CommandObjectThreadInfo::CommandOptions
Definition: CommandObjectThread.cpp:1186
lldb_private::CommandObject::CommandArgumentData::arg_type
lldb::CommandArgumentType arg_type
Definition: CommandObject.h:91
ThreadStepScopeOptionGroup::m_end_line
uint32_t m_end_line
Definition: CommandObjectThread.cpp:314
lldb_private::OptionElementVector
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:42
CommandObjectThreadPlanList::CommandOptions::m_internal
bool m_internal
Definition: CommandObjectThread.cpp:1683
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::ThreadList::GetThreadAtIndex
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
Definition: ThreadList.cpp:90
CommandObjectThreadPlanPrune
Definition: CommandObjectThread.cpp:1834
CommandObjectThreadJump
Definition: CommandObjectThread.cpp:1494
CommandObjectThreadReturn::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:1365
lldb_private::Address::GetSection
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:420
CommandObjectThreadInfo::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectThread.cpp:1188
CommandObjectTraceStart::GetDelegateCommand
lldb::CommandObjectSP GetDelegateCommand(Trace &trace) override
Definition: CommandObjectThread.cpp:1958
lldb_private::EvaluateExpressionOptions::SetUnwindOnError
void SetUnwindOnError(bool unwind=false)
Definition: Target.h:306
lldb_private::CompileUnit::GetLineTable
LineTable * GetLineTable()
Get the line table for the compile unit.
Definition: CompileUnit.cpp:161
CommandObjectThreadUntil::CommandObjectThreadUntil
CommandObjectThreadUntil(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:853
CommandObjectThreadUntil::m_options
CommandOptions m_options
Definition: CommandObjectThread.cpp:1072
lldb::eReturnStatusSuccessContinuingNoResult
@ eReturnStatusSuccessContinuingNoResult
Definition: lldb-enumerations.h:262
Thread.h
CommandObjectThreadReturn::m_options
CommandOptions m_options
Definition: CommandObjectThread.cpp:1487
CommandObjectThreadReturn::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectThread.cpp:1341
CommandObjectThreadStepWithTypeAndScope
Definition: CommandObjectThread.cpp:318
CommandObjectTraceDumpInstructions::IsRepeatCommand
bool IsRepeatCommand()
Definition: CommandObjectThread.cpp:2112
lldb_private::CommandObjectRaw
Definition: CommandObject.h:411
lldb_private::Thread::SetSelectedFrameByIndexNoisily
bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx, Stream &output_stream)
Definition: Thread.cpp:292
lldb_private::RegisterContext
Definition: RegisterContext.h:17
CommandObjectTraceStop::DoExecuteOnThreads
bool DoExecuteOnThreads(Args &command, CommandReturnObject &result, llvm::ArrayRef< lldb::tid_t > tids) override
Definition: CommandObjectThread.cpp:1983
CommandObjectThreadInfo::HandleOneThread
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1250
ValueObject.h
lldb_private::LineEntry::line
uint32_t line
The source line number, or zero if there is no line number information.
Definition: LineEntry.h:143
lldb::RunMode
RunMode
Thread Run Modes.
Definition: lldb-enumerations.h:135
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
LLDB_INVALID_LINE_NUMBER
#define LLDB_INVALID_LINE_NUMBER
Definition: lldb-defines.h:98
CommandObjectThreadJump::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectThread.cpp:1510
CommandObjectThreadJump::CommandOptions::m_filenames
FileSpecList m_filenames
Definition: CommandObjectThread.cpp:1546
CommandObjectMultiwordTrace
Definition: CommandObjectThread.cpp:2255
CommandObjectThreadBacktrace::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectThread.cpp:98
ThreadPlan.h
lldb_private::eStepTypeTraceOver
@ eStepTypeTraceOver
Single step one instruction, stepping over.
Definition: lldb-private-enumerations.h:22
lldb_private::Thread::GetStatus
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:1713
CommandObjectThreadInfo::CommandOptions::m_json_thread
bool m_json_thread
Definition: CommandObjectThread.cpp:1221
CommandObjectTraceDumpInstructions::DoExecute
bool DoExecute(Args &args, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:2102
CommandObjectThreadBacktrace::CommandObjectThreadBacktrace
CommandObjectThreadBacktrace(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:108
lldb::eStateSuspended
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
Definition: lldb-enumerations.h:91
ThreadPlanStepInRange.h
ThreadStepScopeOptionGroup::m_avoid_regexp
std::string m_avoid_regexp
Definition: CommandObjectThread.cpp:311
lldb_private::StepType
StepType
Definition: lldb-private-enumerations.h:19
lldb_private::ExecutionContext::GetProcessSP
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
Definition: ExecutionContext.h:459
lldb_private::CompileUnit::FindLineEntry
uint32_t FindLineEntry(uint32_t start_idx, uint32_t line, const FileSpec *file_spec_ptr, bool exact, LineEntry *line_entry)
Find the line entry by line and optional inlined file spec.
Definition: CompileUnit.cpp:228
lldb_private::Status
Definition: Status.h:44
CommandObjectThreadUntil::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectThread.cpp:791
lldb_private::Args::GetArgumentAtIndex
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Definition: Args.cpp:259
CommandObjectTraceDumpInstructions::CommandOptions
Definition: CommandObjectThread.cpp:2005
CommandObjectThreadBacktrace::HandleOneThread
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:152
lldb_private::Block
Definition: Block.h:41
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
uint32_t
lldb_private::eLazyBoolNo
@ eLazyBoolNo
Definition: lldb-private-enumerations.h:115
StepScope
StepScope
Definition: CommandObjectThread.cpp:189
CommandObjectMultiwordThreadPlan::CommandObjectMultiwordThreadPlan
CommandObjectMultiwordThreadPlan(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1901
lldb_private::EvaluateExpressionOptions::SetUseDynamic
void SetUseDynamic(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
Definition: Target.h:321
lldb::eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishResult
Definition: lldb-enumerations.h:261
CommandObjectTraceDumpInfo::CommandObjectTraceDumpInfo
CommandObjectTraceDumpInfo(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:2207
CommandObjectThreadInfo::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectThread.cpp:1197
CommandObjectTraceDumpInstructions
Definition: CommandObjectThread.cpp:2002
lldb_private::Address
Definition: Address.h:59
CommandObjectThreadPlanList::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectThread.cpp:1635
CommandObjectTraceDumpInfo::HandleOneThread
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:2224
lldb::eOnlyDuringStepping
@ eOnlyDuringStepping
Definition: lldb-enumerations.h:135
lldb_private::Target::EvaluateExpression
lldb::ExpressionResults EvaluateExpression(llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options=EvaluateExpressionOptions(), std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Definition: Target.cpp:2381
CommandObjectThreadJump::m_options
CommandOptions m_options
Definition: CommandObjectThread.cpp:1622
CommandObjectThreadJump::CommandOptions::m_force
bool m_force
Definition: CommandObjectThread.cpp:1550
CommandObjectThreadUntil::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectThread.cpp:842
lldb_private::CommandReturnObject::AppendWarning
void void AppendWarning(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:94
CommandObjectThreadSelect::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1114
CommandObjectTraceStop::CommandObjectTraceStop
CommandObjectTraceStop(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1967
CommandObjectThreadUntil::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:835
ThreadStepScopeOptionGroup
Definition: CommandObjectThread.cpp:204
lldb_private::CommandReturnObject::AppendMessageWithFormat
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:64
CommandObjectTraceDumpInfo::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:2200
LineTable.h
CommandObjectThreadPlanList::GetOptions
Options * GetOptions() override
Definition: CommandObjectThread.cpp:1702
CommandObjectThreadUntil
Definition: CommandObjectThread.cpp:776
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:310
CommandObjectThreadJump::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectThread.cpp:1498
lldb_private::ThreadList::GetSize
uint32_t GetSize(bool can_update=true)
Definition: ThreadList.cpp:82
CommandObjectThreadUntil::GetOptions
Options * GetOptions() override
Definition: CommandObjectThread.cpp:883
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
lldb_private::CommandObjectMultiwordThread::~CommandObjectMultiwordThread
~CommandObjectMultiwordThread() override
CommandObjectTraceExport::CommandObjectTraceExport
CommandObjectTraceExport(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1925
CommandObjectTraceDumpInstructions::CommandOptions::m_show_tsc
bool m_show_tsc
Definition: CommandObjectThread.cpp:2075
lldb_private::Thread::QueueThreadPlanForStepUntil
virtual lldb::ThreadPlanSP QueueThreadPlanForStepUntil(bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses, bool stop_others, uint32_t frame_idx, Status &status)
Definition: Thread.cpp:1359
lldb_private::SystemRuntime::GetExtendedBacktraceThread
virtual lldb::ThreadSP GetExtendedBacktraceThread(lldb::ThreadSP thread, ConstString type)
Return a Thread which shows the origin of this thread's creation.
Definition: SystemRuntime.cpp:46
lldb_private::Thread::GetSelectedFrame
lldb::StackFrameSP GetSelectedFrame()
Definition: Thread.cpp:263
lldb_private::LineEntry::range
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:139
lldb::eArgTypeUnsignedInteger
@ eArgTypeUnsignedInteger
Definition: lldb-enumerations.h:590
g_tri_running_mode
static constexpr OptionEnumValueElement g_tri_running_mode[]
Definition: CommandObjectThread.cpp:191
DuoRunningModes
static constexpr OptionEnumValues DuoRunningModes()
Definition: CommandObjectThread.cpp:769
lldb_private::CommandReturnObject::Succeeded
bool Succeeded()
Definition: CommandReturnObject.cpp:125
CommandObjectThreadUntil::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:886
PluginManager.h
CommandObjectThreadList::CommandObjectThreadList
CommandObjectThreadList(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1152
CommandObjectThreadInfo::GetOptions
Options * GetOptions() override
Definition: CommandObjectThread.cpp:1248
SystemRuntime.h
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::CommandReturnObject::SetDidChangeProcessState
void SetDidChangeProcessState(bool b)
Definition: CommandReturnObject.cpp:152
lldb_private::ExecutionContext::GetTargetSP
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
Definition: ExecutionContext.h:454
lldb_private::Args::GetCommandString
bool GetCommandString(std::string &command) const
Definition: Args.cpp:212
Function.h
lldb_private::Process::GetID
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Definition: Process.h:541
CommandObjectThreadBacktrace::CommandOptions::m_count
uint32_t m_count
Definition: CommandObjectThread.cpp:103
lldb_private::CommandReturnObject::AppendErrorWithFormat
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:46
OptionParser.h
lldb_private::CompletionRequest::GetCursorIndex
size_t GetCursorIndex() const
Definition: CompletionRequest.h:156
CommandObjectThreadJump::GetOptions
Options * GetOptions() override
Definition: CommandObjectThread.cpp:1563
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
CommandObjectThreadUtil.h
lldb::eDescriptionLevelVerbose
@ eDescriptionLevelVerbose
Definition: lldb-enumerations.h:210
CommandObjectThreadPlanDiscard::DoExecute
bool DoExecute(Args &args, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1799
lldb_private::eLazyBoolCalculate
@ eLazyBoolCalculate
Definition: lldb-private-enumerations.h:115
CommandObjectThreadPlanList::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:1669
ThreadStepScopeOptionGroup::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:287
CommandObjectTraceDumpInstructions::m_create_repeat_command_just_invoked
bool m_create_repeat_command_just_invoked
Definition: CommandObjectThread.cpp:2156
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:29
CommandObjectThreadPlanPrune::CommandObjectThreadPlanPrune
CommandObjectThreadPlanPrune(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1836
lldb_private::ThreadList::FindThreadByIndexID
lldb::ThreadSP FindThreadByIndexID(uint32_t index_id, bool can_update=true)
Definition: ThreadList.cpp:208
CommandObjectTraceDumpInstructions::GetRepeatCommand
const char * GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
Definition: CommandObjectThread.cpp:2094
lldb_private::Target::GetTrace
lldb::TraceSP GetTrace()
Get the Trace object containing processor trace information of this target.
Definition: Target.cpp:3075
CommandObjectTraceDumpInstructions::CommandObjectTraceDumpInstructions
CommandObjectTraceDumpInstructions(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:2078
CommandInterpreter.h
lldb_private::Thread::QueueThreadPlanForStepScripted
virtual lldb::ThreadPlanSP QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name, StructuredData::ObjectSP extra_args_sp, bool stop_other_threads, Status &status)
Definition: Thread.cpp:1369
lldb::eAllThreads
@ eAllThreads
Definition: lldb-enumerations.h:135
lldb_private::eStepTypeTrace
@ eStepTypeTrace
Single step one instruction.
Definition: lldb-private-enumerations.h:21
CommandObjectThreadReturn
Definition: CommandObjectThread.cpp:1329
lldb_private::Process::Resume
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
Definition: Process.cpp:1340
CommandObjectThreadStepWithTypeAndScope::m_step_scope
StepScope m_step_scope
Definition: CommandObjectThread.cpp:585
lldb_private::Address::GetOffset
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:310
State.h
CommandObjectThreadStepWithTypeAndScope::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectThread.cpp:357
LLDB_INVALID_INDEX32
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:87
LLDB_INVALID_THREAD_ID
#define LLDB_INVALID_THREAD_ID
Definition: lldb-defines.h:94
CommandObjectThreadInfo::CommandOptions::m_json_stopinfo
bool m_json_stopinfo
Definition: CommandObjectThread.cpp:1222
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
CommandObjectThreadSelect
Definition: CommandObjectThread.cpp:1077
CommandObjectThreadReturn::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectThread.cpp:1333
CommandObjectThreadBacktrace::CommandOptions::m_start
uint32_t m_start
Definition: CommandObjectThread.cpp:104
CommandObjectThreadInfo::m_options
CommandOptions m_options
Definition: CommandObjectThread.cpp:1272
CommandObjectThreadList::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1165
lldb_private::Thread::GetStackFrameAtIndex
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Definition: Thread.h:397
lldb_private::Thread::QueueThreadPlanForStepSingleInstruction
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:1237
lldb_private::SymbolContext::line_entry
LineEntry line_entry
The LineEntry for a given query.
Definition: SymbolContext.h:322
CommandObjectThreadBacktrace::CommandOptions
Definition: CommandObjectThread.cpp:48
lldb_private::CommandObject::CommandArgumentEntry
std::vector< CommandArgumentData > CommandArgumentEntry
Definition: CommandObject.h:105
CommandObjectTraceDumpInfo::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectThread.cpp:2168
lldb_private::CommandReturnObject::AppendError
void void AppendError(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:100
CommandObjectMultiwordTraceDump::CommandObjectMultiwordTraceDump
CommandObjectMultiwordTraceDump(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:2239
lldb_private::AddressRange::ContainsLoadAddress
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'...
Definition: AddressRange.cpp:102
lldb_private::StackFrame
Definition: StackFrame.h:40
CommandObjectTraceDumpInstructions::CommandOptions::m_raw
bool m_raw
Definition: CommandObjectThread.cpp:2073
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:118
lldb_private::CommandObjectIterateOverThreads
Definition: CommandObjectThreadUtil.h:16
CommandObjectThreadBacktrace::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectThread.cpp:92
LLDB_OPT_SET_2
#define LLDB_OPT_SET_2
Definition: lldb-defines.h:114
CommandObjectThreadPlanPrune::DoExecute
bool DoExecute(Args &args, CommandReturnObject &result) override
Definition: CommandObjectThread.cpp:1865
lldb
Definition: SBAddress.h:15
lldb_private::SymbolContext::GetAddressRangeFromHereToEndLine
bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Status &error)
Definition: SymbolContext.cpp:697
CommandObjectThreadUntil::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectThread.cpp:783
lldb::eStateRunning
@ eStateRunning
Process or thread is running and can't be examined.
Definition: lldb-enumerations.h:85
lldb_private::Process::SyncIOHandler
void SyncIOHandler(uint32_t iohandler_id, const Timeout< std::micro > &timeout)
Waits for the process state to be running within a given msec timeout.
Definition: Process.cpp:625
RegisterContext.h
lldb_private::ThreadPlanStepInRange
Definition: ThreadPlanStepInRange.h:20
CommandObjectThreadContinue::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectThread.cpp:622
CommandObjectTraceExport
Definition: CommandObjectThread.cpp:1923
lldb_private::StackFrame::GetSymbolContext
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:298
lldb_private::CommandReturnObject::AppendMessage
void AppendMessage(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:88
lldb_private::LineEntry
Definition: LineEntry.h:20
CommandObjectThreadUntil::CommandOptions::m_stop_others
bool m_stop_others
Definition: CommandObjectThread.cpp:847
CommandObjectTraceStart::CommandObjectTraceStart
CommandObjectTraceStart(CommandInterpreter &interpreter)
Definition: CommandObjectThread.cpp:1950
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
lldb::eOnlyThisThread
@ eOnlyThisThread
Definition: lldb-enumerations.h:135
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
ThreadStepScopeOptionGroup::m_step_out_avoid_no_debug
LazyBool m_step_out_avoid_no_debug
Definition: CommandObjectThread.cpp:309
CommandObjectThreadException::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectThread.cpp:1291
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
CommandObjectTraceDumpInstructions::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectThread.cpp:2007
CommandObjectThreadReturn::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectThread.cpp:1369