LLDB  mainline
BreakpointOptions.cpp
Go to the documentation of this file.
1 //===-- BreakpointOptions.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 
10 
12 #include "lldb/Core/Value.h"
15 #include "lldb/Target/Process.h"
16 #include "lldb/Target/Target.h"
17 #include "lldb/Target/ThreadSpec.h"
18 #include "lldb/Utility/Stream.h"
20 
21 #include "llvm/ADT/STLExtras.h"
22 
23 using namespace lldb;
24 using namespace lldb_private;
25 
26 const char
27  *BreakpointOptions::CommandData::g_option_names[static_cast<uint32_t>(
28  BreakpointOptions::CommandData::OptionNames::LastOptionName)]{
29  "UserSource", "ScriptSource", "StopOnError"};
30 
32 BreakpointOptions::CommandData::SerializeToStructuredData() {
33  size_t num_strings = user_source.GetSize();
34  if (num_strings == 0 && script_source.empty()) {
35  // We shouldn't serialize commands if there aren't any, return an empty sp
36  // to indicate this.
37  return StructuredData::ObjectSP();
38  }
39 
40  StructuredData::DictionarySP options_dict_sp(
42  options_dict_sp->AddBooleanItem(GetKey(OptionNames::StopOnError),
43  stop_on_error);
44 
45  StructuredData::ArraySP user_source_sp(new StructuredData::Array());
46  for (size_t i = 0; i < num_strings; i++) {
48  new StructuredData::String(user_source[i]));
49  user_source_sp->AddItem(item_sp);
50  options_dict_sp->AddItem(GetKey(OptionNames::UserSource), user_source_sp);
51  }
52 
53  options_dict_sp->AddStringItem(
54  GetKey(OptionNames::Interpreter),
55  ScriptInterpreter::LanguageToString(interpreter));
56  return options_dict_sp;
57 }
58 
59 std::unique_ptr<BreakpointOptions::CommandData>
60 BreakpointOptions::CommandData::CreateFromStructuredData(
61  const StructuredData::Dictionary &options_dict, Status &error) {
62  std::unique_ptr<CommandData> data_up(new CommandData());
63  bool found_something = false;
64 
65  bool success = options_dict.GetValueForKeyAsBoolean(
66  GetKey(OptionNames::StopOnError), data_up->stop_on_error);
67 
68  if (success)
69  found_something = true;
70 
71  llvm::StringRef interpreter_str;
72  ScriptLanguage interp_language;
73  success = options_dict.GetValueForKeyAsString(
74  GetKey(OptionNames::Interpreter), interpreter_str);
75 
76  if (!success) {
77  error.SetErrorString("Missing command language value.");
78  return data_up;
79  }
80 
81  found_something = true;
82  interp_language = ScriptInterpreter::StringToLanguage(interpreter_str);
83  if (interp_language == eScriptLanguageUnknown) {
84  error.SetErrorStringWithFormatv("Unknown breakpoint command language: {0}.",
85  interpreter_str);
86  return data_up;
87  }
88  data_up->interpreter = interp_language;
89 
90  StructuredData::Array *user_source;
91  success = options_dict.GetValueForKeyAsArray(GetKey(OptionNames::UserSource),
92  user_source);
93  if (success) {
94  found_something = true;
95  size_t num_elems = user_source->GetSize();
96  for (size_t i = 0; i < num_elems; i++) {
97  llvm::StringRef elem_string;
98  success = user_source->GetItemAtIndexAsString(i, elem_string);
99  if (success)
100  data_up->user_source.AppendString(elem_string);
101  }
102  }
103 
104  if (found_something)
105  return data_up;
106  else
107  return std::unique_ptr<BreakpointOptions::CommandData>();
108 }
109 
110 const char *BreakpointOptions::g_option_names[(
111  size_t)BreakpointOptions::OptionNames::LastOptionName]{
112  "ConditionText", "IgnoreCount",
113  "EnabledState", "OneShotState", "AutoContinue"};
114 
115 bool BreakpointOptions::NullCallback(void *baton,
116  StoppointCallbackContext *context,
117  lldb::user_id_t break_id,
118  lldb::user_id_t break_loc_id) {
119  return true;
120 }
121 
122 // BreakpointOptions constructor
123 BreakpointOptions::BreakpointOptions(bool all_flags_set)
124  : m_callback(BreakpointOptions::NullCallback), m_callback_baton_sp(),
125  m_baton_is_command_baton(false), m_callback_is_synchronous(false),
126  m_enabled(true), m_one_shot(false), m_ignore_count(0), m_thread_spec_up(),
127  m_condition_text(), m_condition_text_hash(0), m_auto_continue(false),
128  m_set_flags(0) {
129  if (all_flags_set)
131 }
132 
133 BreakpointOptions::BreakpointOptions(const char *condition, bool enabled,
134  int32_t ignore, bool one_shot,
135  bool auto_continue)
136  : m_callback(nullptr), m_baton_is_command_baton(false),
137  m_callback_is_synchronous(false), m_enabled(enabled),
138  m_one_shot(one_shot), m_ignore_count(ignore),
139  m_condition_text_hash(0), m_auto_continue(auto_continue)
140 {
142  | eAutoContinue);
143  if (condition && *condition != '\0') {
144  SetCondition(condition);
145  }
146 }
147 
148 // BreakpointOptions copy constructor
150  : m_callback(rhs.m_callback), m_callback_baton_sp(rhs.m_callback_baton_sp),
151  m_baton_is_command_baton(rhs.m_baton_is_command_baton),
152  m_callback_is_synchronous(rhs.m_callback_is_synchronous),
153  m_enabled(rhs.m_enabled), m_one_shot(rhs.m_one_shot),
154  m_ignore_count(rhs.m_ignore_count), m_thread_spec_up(),
155  m_auto_continue(rhs.m_auto_continue), m_set_flags(rhs.m_set_flags) {
156  if (rhs.m_thread_spec_up != nullptr)
157  m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
160 }
161 
162 // BreakpointOptions assignment operator
165  m_callback = rhs.m_callback;
169  m_enabled = rhs.m_enabled;
170  m_one_shot = rhs.m_one_shot;
172  if (rhs.m_thread_spec_up != nullptr)
173  m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
177  m_set_flags = rhs.m_set_flags;
178  return *this;
179 }
180 
182 {
183  if (incoming.m_set_flags.Test(eEnabled))
184  {
185  m_enabled = incoming.m_enabled;
187  }
188  if (incoming.m_set_flags.Test(eOneShot))
189  {
190  m_one_shot = incoming.m_one_shot;
192  }
193  if (incoming.m_set_flags.Test(eCallback))
194  {
195  m_callback = incoming.m_callback;
200  }
201  if (incoming.m_set_flags.Test(eIgnoreCount))
202  {
203  m_ignore_count = incoming.m_ignore_count;
205  }
206  if (incoming.m_set_flags.Test(eCondition))
207  {
208  // If we're copying over an empty condition, mark it as unset.
209  if (incoming.m_condition_text.empty()) {
210  m_condition_text.clear();
213  } else {
217  }
218  }
219  if (incoming.m_set_flags.Test(eAutoContinue))
220  {
221  m_auto_continue = incoming.m_auto_continue;
223  }
224  if (incoming.m_set_flags.Test(eThreadSpec) && incoming.m_thread_spec_up) {
225  if (!m_thread_spec_up)
227  std::make_unique<ThreadSpec>(*incoming.m_thread_spec_up);
228  else
229  *m_thread_spec_up = *incoming.m_thread_spec_up;
231  }
232 }
233 
234 // Destructor
236 
237 std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
238  Target &target, const StructuredData::Dictionary &options_dict,
239  Status &error) {
240  bool enabled = true;
241  bool one_shot = false;
242  bool auto_continue = false;
243  int32_t ignore_count = 0;
244  llvm::StringRef condition_ref("");
245  Flags set_options;
246 
247  const char *key = GetKey(OptionNames::EnabledState);
248  bool success;
249  if (key && options_dict.HasKey(key)) {
250  success = options_dict.GetValueForKeyAsBoolean(key, enabled);
251  if (!success) {
252  error.SetErrorStringWithFormat("%s key is not a boolean.", key);
253  return nullptr;
254  }
255  set_options.Set(eEnabled);
256  }
257 
259  if (key && options_dict.HasKey(key)) {
260  success = options_dict.GetValueForKeyAsBoolean(key, one_shot);
261  if (!success) {
262  error.SetErrorStringWithFormat("%s key is not a boolean.", key);
263  return nullptr;
264  }
265  set_options.Set(eOneShot);
266  }
267 
269  if (key && options_dict.HasKey(key)) {
270  success = options_dict.GetValueForKeyAsBoolean(key, auto_continue);
271  if (!success) {
272  error.SetErrorStringWithFormat("%s key is not a boolean.", key);
273  return nullptr;
274  }
275  set_options.Set(eAutoContinue);
276  }
277 
279  if (key && options_dict.HasKey(key)) {
280  success = options_dict.GetValueForKeyAsInteger(key, ignore_count);
281  if (!success) {
282  error.SetErrorStringWithFormat("%s key is not an integer.", key);
283  return nullptr;
284  }
285  set_options.Set(eIgnoreCount);
286  }
287 
289  if (key && options_dict.HasKey(key)) {
290  success = options_dict.GetValueForKeyAsString(key, condition_ref);
291  if (!success) {
292  error.SetErrorStringWithFormat("%s key is not an string.", key);
293  return nullptr;
294  }
295  set_options.Set(eCondition);
296  }
297 
298  std::unique_ptr<CommandData> cmd_data_up;
299  StructuredData::Dictionary *cmds_dict;
300  success = options_dict.GetValueForKeyAsDictionary(
301  CommandData::GetSerializationKey(), cmds_dict);
302  if (success && cmds_dict) {
303  Status cmds_error;
304  cmd_data_up = CommandData::CreateFromStructuredData(*cmds_dict, cmds_error);
305  if (cmds_error.Fail()) {
306  error.SetErrorStringWithFormat(
307  "Failed to deserialize breakpoint command options: %s.",
308  cmds_error.AsCString());
309  return nullptr;
310  }
311  }
312 
313  auto bp_options = std::make_unique<BreakpointOptions>(
314  condition_ref.str().c_str(), enabled,
315  ignore_count, one_shot, auto_continue);
316  if (cmd_data_up) {
317  if (cmd_data_up->interpreter == eScriptLanguageNone)
318  bp_options->SetCommandDataCallback(cmd_data_up);
319  else {
321  if (!interp) {
322  error.SetErrorString(
323  "Can't set script commands - no script interpreter");
324  return nullptr;
325  }
326  if (interp->GetLanguage() != cmd_data_up->interpreter) {
327  error.SetErrorStringWithFormat(
328  "Current script language doesn't match breakpoint's language: %s",
329  ScriptInterpreter::LanguageToString(cmd_data_up->interpreter)
330  .c_str());
331  return nullptr;
332  }
333  Status script_error;
334  script_error =
335  interp->SetBreakpointCommandCallback(*bp_options, cmd_data_up);
336  if (script_error.Fail()) {
337  error.SetErrorStringWithFormat("Error generating script callback: %s.",
338  error.AsCString());
339  return nullptr;
340  }
341  }
342  }
343 
344  StructuredData::Dictionary *thread_spec_dict;
345  success = options_dict.GetValueForKeyAsDictionary(
346  ThreadSpec::GetSerializationKey(), thread_spec_dict);
347  if (success) {
348  Status thread_spec_error;
349  std::unique_ptr<ThreadSpec> thread_spec_up =
350  ThreadSpec::CreateFromStructuredData(*thread_spec_dict,
351  thread_spec_error);
352  if (thread_spec_error.Fail()) {
353  error.SetErrorStringWithFormat(
354  "Failed to deserialize breakpoint thread spec options: %s.",
355  thread_spec_error.AsCString());
356  return nullptr;
357  }
358  bp_options->SetThreadSpec(thread_spec_up);
359  }
360  return bp_options;
361 }
362 
364  StructuredData::DictionarySP options_dict_sp(
367  options_dict_sp->AddBooleanItem(GetKey(OptionNames::EnabledState),
368  m_enabled);
370  options_dict_sp->AddBooleanItem(GetKey(OptionNames::OneShotState),
371  m_one_shot);
373  options_dict_sp->AddBooleanItem(GetKey(OptionNames::AutoContinue),
376  options_dict_sp->AddIntegerItem(GetKey(OptionNames::IgnoreCount),
379  options_dict_sp->AddStringItem(GetKey(OptionNames::ConditionText),
381 
383  auto cmd_baton =
384  std::static_pointer_cast<CommandBaton>(m_callback_baton_sp);
385  StructuredData::ObjectSP commands_sp =
386  cmd_baton->getItem()->SerializeToStructuredData();
387  if (commands_sp) {
388  options_dict_sp->AddItem(
390  }
391  }
393  StructuredData::ObjectSP thread_spec_sp =
394  m_thread_spec_up->SerializeToStructuredData();
395  options_dict_sp->AddItem(ThreadSpec::GetSerializationKey(), thread_spec_sp);
396  }
397 
398  return options_dict_sp;
399 }
400 
401 // Callbacks
402 void BreakpointOptions::SetCallback(BreakpointHitCallback callback,
403  const lldb::BatonSP &callback_baton_sp,
404  bool callback_is_synchronous) {
405  // FIXME: This seems unsafe. If BatonSP actually *is* a CommandBaton, but
406  // in a shared_ptr<Baton> instead of a shared_ptr<CommandBaton>, then we will
407  // set m_baton_is_command_baton to false, which is incorrect. One possible
408  // solution is to make the base Baton class provide a method such as:
409  // virtual StringRef getBatonId() const { return ""; }
410  // and have CommandBaton override this to return something unique, and then
411  // check for it here. Another option might be to make Baton using the llvm
412  // casting infrastructure, so that we could write something like:
413  // if (llvm::isa<CommandBaton>(callback_baton_sp))
414  // at relevant callsites instead of storing a boolean.
415  m_callback_is_synchronous = callback_is_synchronous;
416  m_callback = callback;
417  m_callback_baton_sp = callback_baton_sp;
418  m_baton_is_command_baton = false;
420 }
421 
423  BreakpointHitCallback callback,
424  const BreakpointOptions::CommandBatonSP &callback_baton_sp,
425  bool callback_is_synchronous) {
426  m_callback_is_synchronous = callback_is_synchronous;
427  m_callback = callback;
428  m_callback_baton_sp = callback_baton_sp;
431 }
432 
436  m_callback_baton_sp.reset();
437  m_baton_is_command_baton = false;
439 }
440 
442 
443 const Baton *BreakpointOptions::GetBaton() const {
444  return m_callback_baton_sp.get();
445 }
446 
448  lldb::user_id_t break_id,
449  lldb::user_id_t break_loc_id) {
450  if (m_callback) {
451  if (context->is_synchronous == IsCallbackSynchronous()) {
453  : nullptr,
454  context, break_id, break_loc_id);
455  } else if (IsCallbackSynchronous()) {
456  return false;
457  }
458  }
459  return true;
460 }
461 
464 }
465 
467  if (!HasCallback())
468  return false;
470  return false;
471 
472  auto cmd_baton = std::static_pointer_cast<CommandBaton>(m_callback_baton_sp);
473  CommandData *data = cmd_baton->getItem();
474  if (!data)
475  return false;
476  command_list = data->user_source;
477  return true;
478 }
479 
480 void BreakpointOptions::SetCondition(const char *condition) {
481  if (!condition || condition[0] == '\0') {
482  condition = "";
484  }
485  else
487 
488  m_condition_text.assign(condition);
489  std::hash<std::string> hasher;
491 }
492 
493 const char *BreakpointOptions::GetConditionText(size_t *hash) const {
494  if (!m_condition_text.empty()) {
495  if (hash)
496  *hash = m_condition_text_hash;
497 
498  return m_condition_text.c_str();
499  } else {
500  return nullptr;
501  }
502 }
503 
505  return m_thread_spec_up.get();
506 }
507 
509  if (m_thread_spec_up == nullptr) {
511  m_thread_spec_up = std::make_unique<ThreadSpec>();
512  }
513 
514  return m_thread_spec_up.get();
515 }
516 
518  GetThreadSpec()->SetTID(thread_id);
520 }
521 
523  std::unique_ptr<ThreadSpec> &thread_spec_up) {
524  m_thread_spec_up = std::move(thread_spec_up);
526 }
527 
529  lldb::DescriptionLevel level) const {
530  // Figure out if there are any options not at their default value, and only
531  // print anything if there are:
532 
533  if (m_ignore_count != 0 || !m_enabled || m_one_shot || m_auto_continue ||
534  (GetThreadSpecNoCreate() != nullptr &&
535  GetThreadSpecNoCreate()->HasSpecification())) {
536  if (level == lldb::eDescriptionLevelVerbose) {
537  s->EOL();
538  s->IndentMore();
539  s->Indent();
540  s->PutCString("Breakpoint Options:\n");
541  s->IndentMore();
542  s->Indent();
543  } else
544  s->PutCString(" Options: ");
545 
546  if (m_ignore_count > 0)
547  s->Printf("ignore: %d ", m_ignore_count);
548  s->Printf("%sabled ", m_enabled ? "en" : "dis");
549 
550  if (m_one_shot)
551  s->Printf("one-shot ");
552 
553  if (m_auto_continue)
554  s->Printf("auto-continue ");
555 
556  if (m_thread_spec_up)
557  m_thread_spec_up->GetDescription(s, level);
558 
559  if (level == lldb::eDescriptionLevelFull) {
560  s->IndentLess();
561  s->IndentMore();
562  }
563  }
564 
565  if (m_callback_baton_sp.get()) {
566  if (level != eDescriptionLevelBrief) {
567  s->EOL();
568  m_callback_baton_sp->GetDescription(s->AsRawOstream(), level,
569  s->GetIndentLevel());
570  }
571  }
572  if (!m_condition_text.empty()) {
573  if (level != eDescriptionLevelBrief) {
574  s->EOL();
575  s->Printf("Condition: %s\n", m_condition_text.c_str());
576  }
577  }
578 }
579 
581  llvm::raw_ostream &s, lldb::DescriptionLevel level,
582  unsigned indentation) const {
583  const CommandData *data = getItem();
584 
585  if (level == eDescriptionLevelBrief) {
586  s << ", commands = "
587  << ((data && data->user_source.GetSize() > 0) ? "yes" : "no");
588  return;
589  }
590 
591  indentation += 2;
592  s.indent(indentation);
593  s << "Breakpoint commands";
594  if (data->interpreter != eScriptLanguageNone)
595  s << llvm::formatv(" ({0}):\n",
597  else
598  s << ":\n";
599 
600  indentation += 2;
601  if (data && data->user_source.GetSize() > 0) {
602  for (llvm::StringRef str : data->user_source) {
603  s.indent(indentation);
604  s << str << "\n";
605  }
606  } else
607  s << "No commands.\n";
608 }
609 
611  std::unique_ptr<CommandData> &cmd_data) {
612  cmd_data->interpreter = eScriptLanguageNone;
613  auto baton_sp = std::make_shared<CommandBaton>(std::move(cmd_data));
616 }
617 
619  void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id,
620  lldb::user_id_t break_loc_id) {
621  bool ret_value = true;
622  if (baton == nullptr)
623  return true;
624 
625  CommandData *data = (CommandData *)baton;
626  StringList &commands = data->user_source;
627 
628  if (commands.GetSize() > 0) {
629  ExecutionContext exe_ctx(context->exe_ctx_ref);
630  Target *target = exe_ctx.GetTargetPtr();
631  if (target) {
632  Debugger &debugger = target->GetDebugger();
633  CommandReturnObject result(debugger.GetUseColor());
634 
635  // Rig up the results secondary output stream to the debugger's, so the
636  // output will come out synchronously if the debugger is set up that way.
637  StreamSP output_stream(debugger.GetAsyncOutputStream());
638  StreamSP error_stream(debugger.GetAsyncErrorStream());
639  result.SetImmediateOutputStream(output_stream);
640  result.SetImmediateErrorStream(error_stream);
641 
643  options.SetStopOnContinue(true);
644  options.SetStopOnError(data->stop_on_error);
645  options.SetEchoCommands(true);
646  options.SetPrintResults(true);
647  options.SetPrintErrors(true);
648  options.SetAddToHistory(false);
649 
650  debugger.GetCommandInterpreter().HandleCommands(commands, exe_ctx,
651  options, result);
652  result.GetImmediateOutputStream()->Flush();
653  result.GetImmediateErrorStream()->Flush();
654  }
655  }
656  return ret_value;
657 }
658 
660 {
661  m_set_flags.Clear();
662  m_thread_spec_up.release();
663  m_one_shot = false;
664  m_ignore_count = 0;
665  m_auto_continue = false;
666  m_callback = nullptr;
667  m_callback_baton_sp.reset();
668  m_baton_is_command_baton = false;
670  m_enabled = false;
671  m_condition_text.clear();
672 }
lldb_private::BreakpointOptions::CommandData::stop_on_error
bool stop_on_error
Definition: BreakpointOptions.h:67
lldb_private::Stream::IndentLess
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:171
lldb_private::BreakpointOptions::m_condition_text
std::string m_condition_text
The condition to test.
Definition: BreakpointOptions.h:394
lldb_private::ScriptInterpreter::SetBreakpointCommandCallback
Status SetBreakpointCommandCallback(std::vector< std::reference_wrapper< BreakpointOptions >> &bp_options_vec, const char *callback_text)
Set the specified text as the callback for the breakpoint.
Definition: ScriptInterpreter.cpp:109
lldb_private::BreakpointOptions::GetDescription
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
Definition: BreakpointOptions.cpp:528
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::BreakpointOptions::GetThreadSpec
ThreadSpec * GetThreadSpec()
Returns a pointer to the ThreadSpec for this option, creating it.
Definition: BreakpointOptions.cpp:508
lldb::ScriptLanguage
ScriptLanguage
Script interpreter types.
Definition: lldb-enumerations.h:216
lldb_private::StructuredData::Dictionary
Definition: StructuredData.h:352
lldb_private::BreakpointOptions::m_condition_text_hash
size_t m_condition_text_hash
Its hash, so that locations know when the condition is updated.
Definition: BreakpointOptions.h:396
lldb_private::StoppointCallbackContext
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
Definition: StoppointCallbackContext.h:26
lldb_private::BreakpointOptions::CommandData
Definition: BreakpointOptions.h:45
lldb_private::BreakpointOptions::m_callback
BreakpointHitCallback m_callback
For BreakpointOptions only.
Definition: BreakpointOptions.h:381
lldb_private::BreakpointOptions::m_baton_is_command_baton
bool m_baton_is_command_baton
Definition: BreakpointOptions.h:384
lldb_private::StructuredData::Array
Definition: StructuredData.h:165
lldb_private::BreakpointOptions::GetBaton
Baton * GetBaton()
Fetch the baton from the callback.
Definition: BreakpointOptions.cpp:441
lldb_private::Debugger::GetCommandInterpreter
CommandInterpreter & GetCommandInterpreter()
Definition: Debugger.h:199
lldb_private::BreakpointOptions::OptionNames::OneShotState
@ OneShotState
lldb_private::BreakpointOptions::OptionNames::EnabledState
@ EnabledState
lldb_private::BreakpointOptions::SetCondition
void SetCondition(const char *condition)
Set the breakpoint option's condition.
Definition: BreakpointOptions.cpp:480
lldb_private::BreakpointOptions::m_one_shot
bool m_one_shot
If set, the breakpoint delete itself after being hit once.
Definition: BreakpointOptions.h:388
lldb_private::BreakpointOptions::eCondition
@ eCondition
Definition: BreakpointOptions.h:40
lldb_private::BreakpointOptions::GetConditionText
const char * GetConditionText(size_t *hash=nullptr) const
Return a pointer to the text of the condition expression.
Definition: BreakpointOptions.cpp:493
lldb_private::TypedBaton< CommandData >::data
void * data() override
Definition: Baton.h:69
lldb_private::BreakpointOptions::SetThreadID
void SetThreadID(lldb::tid_t thread_id)
Definition: BreakpointOptions.cpp:517
lldb_private::Flags::Clear
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
Definition: Flags.h:61
lldb_private::CommandInterpreterRunOptions::SetAddToHistory
void SetAddToHistory(bool add_to_history)
Definition: CommandInterpreter.h:165
lldb_private::StoppointCallbackContext::exe_ctx_ref
ExecutionContextRef exe_ctx_ref
Definition: StoppointCallbackContext.h:43
StoppointCallbackContext.h
lldb_private::BreakpointOptions::CommandData::user_source
StringList user_source
Definition: BreakpointOptions.h:62
lldb_private::Flags
Definition: Flags.h:22
lldb_private::Flags::Test
bool Test(ValueType bit) const
Test a single flag bit.
Definition: Flags.h:96
lldb_private::Stream
Definition: Stream.h:28
lldb_private::BreakpointOptions::NullCallback
static bool NullCallback(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
This is the default empty callback.
Definition: BreakpointOptions.cpp:115
lldb_private::Target::GetDebugger
Debugger & GetDebugger()
Definition: Target.h:1000
CommandReturnObject.h
lldb_private::CommandInterpreterRunOptions
Definition: CommandInterpreter.h:59
lldb_private::Target
Definition: Target.h:451
lldb_private::Debugger::GetScriptInterpreter
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, llvm::Optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1364
lldb_private::BreakpointOptions::OptionNames::ConditionText
@ ConditionText
Process.h
lldb_private::StructuredData::Dictionary::GetValueForKeyAsInteger
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
Definition: StructuredData.h:414
lldb::eScriptLanguageNone
@ eScriptLanguageNone
Definition: lldb-enumerations.h:217
lldb_private::StringList::GetSize
size_t GetSize() const
Definition: StringList.cpp:68
lldb_private::BreakpointOptions::GetThreadSpecNoCreate
const ThreadSpec * GetThreadSpecNoCreate() const
Return the current thread spec for this option.
Definition: BreakpointOptions.cpp:504
Target.h
lldb_private::StoppointCallbackContext::is_synchronous
bool is_synchronous
Definition: StoppointCallbackContext.h:44
lldb_private::ScriptInterpreter::GetLanguage
lldb::ScriptLanguage GetLanguage()
Definition: ScriptInterpreter.h:559
lldb_private::BreakpointOptions::CreateFromStructuredData
static std::unique_ptr< BreakpointOptions > CreateFromStructuredData(Target &target, const StructuredData::Dictionary &data_dict, Status &error)
Definition: BreakpointOptions.cpp:237
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::BreakpointOptions::m_enabled
bool m_enabled
Definition: BreakpointOptions.h:386
lldb_private::CommandInterpreterRunOptions::SetEchoCommands
void SetEchoCommands(bool echo_commands)
Definition: CommandInterpreter.h:139
lldb_private::StructuredData::StringSP
std::shared_ptr< String > StringSP
Definition: StructuredData.h:66
lldb_private::BreakpointOptions::OptionNames::IgnoreCount
@ IgnoreCount
lldb_private::StructuredData::String
Definition: StructuredData.h:336
lldb_private::Stream::Indent
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
lldb_private::BreakpointOptions::~BreakpointOptions
virtual ~BreakpointOptions()
lldb_private::BreakpointOptions::OptionNames::AutoContinue
@ AutoContinue
lldb_private::CommandInterpreterRunOptions::SetStopOnContinue
void SetStopOnContinue(bool stop_on_continue)
Definition: CommandInterpreter.h:121
ThreadSpec.h
lldb_private::BreakpointOptions::m_ignore_count
uint32_t m_ignore_count
Number of times to ignore this breakpoint.
Definition: BreakpointOptions.h:390
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:182
lldb_private::BreakpointOptions::SetCallback
void SetCallback(BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous=false)
Adds a callback to the breakpoint option set.
Definition: BreakpointOptions.cpp:402
lldb_private::Debugger::GetAsyncOutputStream
lldb::StreamSP GetAsyncOutputStream()
Definition: Debugger.cpp:1150
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb_private::CommandReturnObject::GetImmediateErrorStream
lldb::StreamSP GetImmediateErrorStream()
Definition: CommandReturnObject.h:95
lldb_private::BreakpointOptions::m_thread_spec_up
std::unique_ptr< ThreadSpec > m_thread_spec_up
Thread for which this breakpoint will stop.
Definition: BreakpointOptions.h:392
lldb_private::BreakpointOptions::CommandBatonSP
std::shared_ptr< CommandBaton > CommandBatonSP
Definition: BreakpointOptions.h:94
lldb_private::BreakpointOptions::HasCallback
bool HasCallback() const
Check if the breakpoint option has a callback set.
Definition: BreakpointOptions.cpp:462
lldb_private::Debugger::GetAsyncErrorStream
lldb::StreamSP GetAsyncErrorStream()
Definition: Debugger.cpp:1154
lldb_private::StringList
Definition: StringList.h:25
lldb_private::BreakpointOptions
Definition: BreakpointOptions.h:27
lldb::eDescriptionLevelFull
@ eDescriptionLevelFull
Definition: lldb-enumerations.h:209
lldb_private::BreakpointOptions::m_set_flags
Flags m_set_flags
Which options are set at this level.
Definition: BreakpointOptions.h:403
lldb_private::TypedBaton< CommandData >::getItem
CommandData * getItem()
Definition: Baton.h:66
lldb_private::CommandReturnObject::GetImmediateOutputStream
lldb::StreamSP GetImmediateOutputStream()
Definition: CommandReturnObject.h:91
lldb_private::StructuredData::DictionarySP
std::shared_ptr< Dictionary > DictionarySP
Definition: StructuredData.h:67
lldb_private::Debugger
Definition: Debugger.h:70
lldb_private::Stream::GetIndentLevel
unsigned GetIndentLevel() const
Get the current indentation level.
Definition: Stream.cpp:160
lldb::eScriptLanguageUnknown
@ eScriptLanguageUnknown
Definition: lldb-enumerations.h:220
StringList.h
lldb_private::BreakpointOptions::SetCommandDataCallback
void SetCommandDataCallback(std::unique_ptr< CommandData > &cmd_data)
Set a callback based on BreakpointOptions::CommandData.
Definition: BreakpointOptions.cpp:610
lldb_private::ThreadSpec::SetTID
void SetTID(lldb::tid_t tid)
Definition: ThreadSpec.h:47
lldb_private::BreakpointOptions::BreakpointOptionsCallbackFunction
static bool BreakpointOptionsCallbackFunction(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Definition: BreakpointOptions.cpp:618
lldb_private::ThreadSpec
Definition: ThreadSpec.h:33
BreakpointOptions.h
lldb_private::BreakpointOptions::InvokeCallback
bool InvokeCallback(StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Use this function to invoke the callback for a specific stop.
Definition: BreakpointOptions.cpp:447
lldb_private::BreakpointOptions::SerializeToStructuredData
virtual StructuredData::ObjectSP SerializeToStructuredData()
Definition: BreakpointOptions.cpp:363
lldb_private::Status
Definition: Status.h:44
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
uint32_t
lldb_private::BreakpointOptions::eAutoContinue
@ eAutoContinue
Definition: BreakpointOptions.h:41
lldb_private::BreakpointOptions::SetThreadSpec
void SetThreadSpec(std::unique_ptr< ThreadSpec > &thread_spec_up)
Definition: BreakpointOptions.cpp:522
lldb_private::Stream::IndentMore
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:168
lldb_private::CommandReturnObject::SetImmediateOutputStream
void SetImmediateOutputStream(const lldb::StreamSP &stream_sp)
Definition: CommandReturnObject.h:79
lldb_private::BreakpointOptions::eCallback
@ eCallback
Definition: BreakpointOptions.h:35
lldb_private::BreakpointOptions::operator=
const BreakpointOptions & operator=(const BreakpointOptions &rhs)
Definition: BreakpointOptions.cpp:164
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
lldb_private::BreakpointOptions::eOneShot
@ eOneShot
Definition: BreakpointOptions.h:37
lldb_private::BreakpointOptions::CommandData::GetSerializationKey
static const char * GetSerializationKey()
Definition: BreakpointOptions.h:54
lldb_private::BreakpointOptions::BreakpointOptions
BreakpointOptions(const char *condition, bool enabled=true, int32_t ignore=0, bool one_shot=false, bool auto_continue=false)
This constructor allows you to specify all the breakpoint options except the callback.
Definition: BreakpointOptions.cpp:133
lldb_private::Stream::AsRawOstream
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
lldb_private::StructuredData::Dictionary::HasKey
bool HasKey(llvm::StringRef key) const
Definition: StructuredData.h:499
lldb_private::ScriptInterpreter::LanguageToString
static std::string LanguageToString(lldb::ScriptLanguage language)
Definition: ScriptInterpreter.cpp:63
lldb_private::BreakpointOptions::m_callback_baton_sp
lldb::BatonSP m_callback_baton_sp
This is the client data for the callback.
Definition: BreakpointOptions.h:383
lldb_private::BreakpointOptions::IsCallbackSynchronous
bool IsCallbackSynchronous() const
Used in InvokeCallback to tell whether it is the right time to run this kind of callback.
Definition: BreakpointOptions.h:234
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
lldb_private::Baton
Definition: Baton.h:35
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::ThreadSpec::GetSerializationKey
static const char * GetSerializationKey()
Definition: ThreadSpec.h:43
lldb_private::Debugger::GetUseColor
bool GetUseColor() const
Definition: Debugger.cpp:352
lldb_private::BreakpointOptions::m_callback_is_synchronous
bool m_callback_is_synchronous
Definition: BreakpointOptions.h:385
lldb_private::BreakpointOptions::eThreadSpec
@ eThreadSpec
Definition: BreakpointOptions.h:39
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private::BreakpointOptions::GetKey
static const char * GetKey(OptionNames enum_value)
Definition: BreakpointOptions.h:367
lldb_private::CommandInterpreterRunOptions::SetPrintResults
void SetPrintResults(bool print_results)
Definition: CommandInterpreter.h:153
lldb_private::BreakpointOptions::m_auto_continue
bool m_auto_continue
If set, auto-continue from breakpoint.
Definition: BreakpointOptions.h:400
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::eDescriptionLevelVerbose
@ eDescriptionLevelVerbose
Definition: lldb-enumerations.h:210
lldb_private::StructuredData::Dictionary::GetValueForKeyAsDictionary
bool GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const
Definition: StructuredData.h:478
lldb_private::BreakpointOptions::eEnabled
@ eEnabled
Definition: BreakpointOptions.h:36
lldb_private::Flags::Set
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
CommandInterpreter.h
lldb_private::BreakpointOptions::CommandBaton::GetDescription
void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level, unsigned indentation) const override
Definition: BreakpointOptions.cpp:580
lldb_private::BreakpointOptions::eIgnoreCount
@ eIgnoreCount
Definition: BreakpointOptions.h:38
lldb_private::ThreadSpec::CreateFromStructuredData
static std::unique_ptr< ThreadSpec > CreateFromStructuredData(const StructuredData::Dictionary &data_dict, Status &error)
Definition: ThreadSpec.cpp:22
lldb_private::CommandReturnObject::SetImmediateErrorStream
void SetImmediateErrorStream(const lldb::StreamSP &stream_sp)
Definition: CommandReturnObject.h:85
lldb_private::StructuredData::Array::GetItemAtIndexAsString
bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result) const
Definition: StructuredData.h:216
Stream.h
lldb_private::StructuredData::ArraySP
std::shared_ptr< Array > ArraySP
Definition: StructuredData.h:62
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::StructuredData::Dictionary::GetValueForKeyAsString
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
Definition: StructuredData.h:434
lldb_private::StructuredData::Dictionary::GetValueForKeyAsArray
bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
Definition: StructuredData.h:489
lldb_private::StructuredData::Array::GetSize
size_t GetSize() const
Definition: StructuredData.h:180
lldb_private::CommandInterpreterRunOptions::SetStopOnError
void SetStopOnError(bool stop_on_error)
Definition: CommandInterpreter.h:127
lldb_private::BreakpointOptions::GetCommandLineCallbacks
bool GetCommandLineCallbacks(StringList &command_list)
Returns the command line commands for the callback on this breakpoint.
Definition: BreakpointOptions.cpp:466
lldb_private::StructuredData::Dictionary::GetValueForKeyAsBoolean
bool GetValueForKeyAsBoolean(llvm::StringRef key, bool &result) const
Definition: StructuredData.h:401
lldb_private::CommandInterpreterRunOptions::SetPrintErrors
void SetPrintErrors(bool print_errors)
Definition: CommandInterpreter.h:159
lldb
Definition: SBAddress.h:15
lldb_private::BreakpointOptions::ClearCallback
void ClearCallback()
Remove the callback from this option set.
Definition: BreakpointOptions.cpp:433
Value.h
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:200
lldb::eDescriptionLevelBrief
@ eDescriptionLevelBrief
Definition: lldb-enumerations.h:208
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
lldb_private::BreakpointOptions::CopyOverSetOptions
void CopyOverSetOptions(const BreakpointOptions &rhs)
Copy over only the options set in the incoming BreakpointOptions.
Definition: BreakpointOptions.cpp:181
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
lldb_private::BreakpointOptions::Clear
void Clear()
Definition: BreakpointOptions.cpp:659
lldb_private::CommandInterpreter::HandleCommands
void HandleCommands(const StringList &commands, const ExecutionContext &context, const CommandInterpreterRunOptions &options, CommandReturnObject &result)
Execute a list of commands in sequence.
lldb_private::Status::AsCString
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:131
lldb_private::BreakpointOptions::CommandData::CreateFromStructuredData
static std::unique_ptr< CommandData > CreateFromStructuredData(const StructuredData::Dictionary &options_dict, Status &error)
Definition: BreakpointOptions.cpp:60