LLDB mainline
Debugger.h
Go to the documentation of this file.
1//===-- Debugger.h ----------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_CORE_DEBUGGER_H
10#define LLDB_CORE_DEBUGGER_H
11
12#include <cstdint>
13
14#include <memory>
15#include <optional>
16#include <vector>
17
20#include "lldb/Core/IOHandler.h"
25#include "lldb/Host/Terminal.h"
33#include "lldb/Utility/Status.h"
34#include "lldb/Utility/UserID.h"
35#include "lldb/lldb-defines.h"
37#include "lldb/lldb-forward.h"
40#include "lldb/lldb-types.h"
41
42#include "llvm/ADT/ArrayRef.h"
43#include "llvm/ADT/SmallVector.h"
44#include "llvm/ADT/StringMap.h"
45#include "llvm/ADT/StringRef.h"
46#include "llvm/Support/DynamicLibrary.h"
47#include "llvm/Support/FormatVariadic.h"
48#include "llvm/Support/Threading.h"
49
50#include <cassert>
51#include <cstddef>
52#include <cstdio>
53
54namespace llvm {
55class raw_ostream;
56class ThreadPoolInterface;
57} // namespace llvm
58
59namespace lldb_private {
60class Address;
61class CallbackLogHandler;
62class CommandInterpreter;
63class LogHandler;
64class Process;
65class Stream;
66class SymbolContext;
67class Target;
68
69namespace repro {
70class DataRecorder;
71}
72
73/// \class Debugger Debugger.h "lldb/Core/Debugger.h"
74/// A class to manage flag bits.
75///
76/// Provides a global root objects for the debugger core.
77
78class Debugger : public std::enable_shared_from_this<Debugger>,
79 public UserID,
80 public Properties {
81public:
82 using DebuggerList = std::vector<lldb::DebuggerSP>;
83
84 static llvm::StringRef GetStaticBroadcasterClass();
85
86 /// Get the public broadcaster for this debugger.
88 const Broadcaster &GetBroadcaster() const { return m_broadcaster; }
89
90 ~Debugger() override;
91
92 static lldb::DebuggerSP
93 CreateInstance(lldb::LogOutputCallback log_callback = nullptr,
94 void *baton = nullptr);
95
97
99
100 static void Initialize(LoadPluginCallbackType load_plugin_callback);
101
102 static void Terminate();
103
104 static void SettingsInitialize();
105
106 static void SettingsTerminate();
107
108 static void Destroy(lldb::DebuggerSP &debugger_sp);
109
111
112 static lldb::DebuggerSP
113 FindDebuggerWithInstanceName(llvm::StringRef instance_name);
114
115 static size_t GetNumDebuggers();
116
117 static lldb::DebuggerSP GetDebuggerAtIndex(size_t index);
118
119 static bool FormatDisassemblerAddress(const FormatEntity::Entry *format,
120 const SymbolContext *sc,
121 const SymbolContext *prev_sc,
122 const ExecutionContext *exe_ctx,
123 const Address *addr, Stream &s);
124
125 static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace,
126 llvm::StringRef prompt);
127
128 void Clear();
129
130 bool GetAsyncExecution();
131
132 void SetAsyncExecution(bool async);
133
135
137
139
141
142 File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
143
144 File &GetErrorFile() { return m_error_stream_sp->GetFile(); }
145
147
149
150 repro::DataRecorder *GetInputRecorder();
151
152 Status SetInputString(const char *data);
153
154 void SetInputFile(lldb::FileSP file);
155
156 void SetOutputFile(lldb::FileSP file);
157
158 void SetErrorFile(lldb::FileSP file);
159
161
163
165
167
169 assert(m_command_interpreter_up.get());
171 }
172
174 GetScriptInterpreter(bool can_create = true,
175 std::optional<lldb::ScriptLanguage> language = {});
176
178
179 // This returns the Debugger's scratch source manager. It won't be able to
180 // look up files in debug information, but it can look up files by absolute
181 // path and display them to you. To get the target's source manager, call
182 // GetSourceManager on the target instead.
184
187 }
188
190 /// Get accessor for the target list.
191 ///
192 /// The target list is part of the global debugger object. This the single
193 /// debugger shared instance to control where targets get created and to
194 /// allow for tracking and searching for targets based on certain criteria.
195 ///
196 /// \return
197 /// A global shared target list.
199
201
203
205
206 // If any of the streams are not set, set them to the in/out/err stream of
207 // the top most input reader to ensure they at least have something
210 lldb::StreamFileSP &err);
211
212 /// Run the given IO handler and return immediately.
213 void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp,
214 bool cancel_top_handler = true);
215
216 /// Run the given IO handler and block until it's complete.
217 void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp);
218
219 /// Remove the given IO handler if it's currently active.
220 bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp);
221
222 bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp);
223
225 IOHandler::Type second_top_type);
226
227 void PrintAsync(const char *s, size_t len, bool is_stdout);
228
229 llvm::StringRef GetTopIOHandlerControlSequence(char ch);
230
231 const char *GetIOHandlerCommandPrefix();
232
233 const char *GetIOHandlerHelpPrologue();
234
235 void ClearIOHandlers();
236
237 bool EnableLog(llvm::StringRef channel,
238 llvm::ArrayRef<const char *> categories,
239 llvm::StringRef log_file, uint32_t log_options,
240 size_t buffer_size, LogHandlerKind log_handler_kind,
241 llvm::raw_ostream &error_stream);
242
243 void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
244
245 // Properties Functions
251 };
252
254 VarSetOperationType op, llvm::StringRef property_path,
255 llvm::StringRef value) override;
256
257 bool GetAutoConfirm() const;
258
260
261 const FormatEntity::Entry *GetFrameFormat() const;
262
264
265 uint64_t GetStopDisassemblyMaxSize() const;
266
268
270
272
273 bool SetScriptLanguage(lldb::ScriptLanguage script_lang);
274
276
277 bool SetREPLLanguage(lldb::LanguageType repl_lang);
278
279 uint64_t GetTerminalWidth() const;
280
281 bool SetTerminalWidth(uint64_t term_width);
282
283 uint64_t GetTerminalHeight() const;
284
285 bool SetTerminalHeight(uint64_t term_height);
286
287 llvm::StringRef GetPrompt() const;
288
289 llvm::StringRef GetPromptAnsiPrefix() const;
290
291 llvm::StringRef GetPromptAnsiSuffix() const;
292
293 void SetPrompt(llvm::StringRef p);
294 void SetPrompt(const char *) = delete;
295
296 bool GetUseExternalEditor() const;
297 bool SetUseExternalEditor(bool use_external_editor_p);
298
299 llvm::StringRef GetExternalEditor() const;
300
301 bool SetExternalEditor(llvm::StringRef editor);
302
303 bool GetUseColor() const;
304
305 bool SetUseColor(bool use_color);
306
307 bool GetShowProgress() const;
308
309 bool SetShowProgress(bool show_progress);
310
311 llvm::StringRef GetShowProgressAnsiPrefix() const;
312
313 llvm::StringRef GetShowProgressAnsiSuffix() const;
314
315 bool GetUseAutosuggestion() const;
316
317 llvm::StringRef GetAutosuggestionAnsiPrefix() const;
318
319 llvm::StringRef GetAutosuggestionAnsiSuffix() const;
320
321 llvm::StringRef GetRegexMatchAnsiPrefix() const;
322
323 llvm::StringRef GetRegexMatchAnsiSuffix() const;
324
325 bool GetShowDontUsePoHint() const;
326
327 bool GetUseSourceCache() const;
328
329 bool SetUseSourceCache(bool use_source_cache);
330
331 bool GetHighlightSource() const;
332
334
335 llvm::StringRef GetStopShowColumnAnsiPrefix() const;
336
337 llvm::StringRef GetStopShowColumnAnsiSuffix() const;
338
339 uint64_t GetStopSourceLineCount(bool before) const;
340
342
343 uint64_t GetDisassemblyLineCount() const;
344
345 llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const;
346
347 llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const;
348
349 bool GetAutoOneLineSummaries() const;
350
351 bool GetAutoIndent() const;
352
353 bool SetAutoIndent(bool b);
354
355 bool GetPrintDecls() const;
356
357 bool SetPrintDecls(bool b);
358
359 uint64_t GetTabSize() const;
360
361 bool SetTabSize(uint64_t tab_size);
362
364
365 bool GetEscapeNonPrintables() const;
366
367 bool GetNotifyVoid() const;
368
369 const std::string &GetInstanceName() { return m_instance_name; }
370
371 bool GetShowInlineDiagnostics() const;
372
373 bool SetShowInlineDiagnostics(bool);
374
375 bool LoadPlugin(const FileSpec &spec, Status &error);
376
377 void RunIOHandlers();
378
379 bool IsForwardingEvents();
380
381 void EnableForwardEvents(const lldb::ListenerSP &listener_sp);
382
383 void CancelForwardEvents(const lldb::ListenerSP &listener_sp);
384
386
387 Status RunREPL(lldb::LanguageType language, const char *repl_options);
388
389 /// Interruption in LLDB:
390 ///
391 /// This is a voluntary interruption mechanism, not preemptive. Parts of lldb
392 /// that do work that can be safely interrupted call
393 /// Debugger::InterruptRequested and if that returns true, they should return
394 /// at a safe point, shortcutting the rest of the work they were to do.
395 ///
396 /// lldb clients can both offer a CommandInterpreter (through
397 /// RunCommandInterpreter) and use the SB API's for their own purposes, so it
398 /// is convenient to separate "interrupting the CommandInterpreter execution"
399 /// and interrupting the work it is doing with the SB API's. So there are two
400 /// ways to cause an interrupt:
401 /// * CommandInterpreter::InterruptCommand: Interrupts the command currently
402 /// running in the command interpreter IOHandler thread
403 /// * Debugger::RequestInterrupt: Interrupts are active on anything but the
404 /// CommandInterpreter thread till CancelInterruptRequest is called.
405 ///
406 /// Since the two checks are mutually exclusive, however, it's also convenient
407 /// to have just one function to check the interrupt state.
408
409 /// Bump the "interrupt requested" count on the debugger to support
410 /// cooperative interruption. If this is non-zero, InterruptRequested will
411 /// return true. Interruptible operations are expected to query the
412 /// InterruptRequested API periodically, and interrupt what they were doing
413 /// if it returns \b true.
414 ///
415 void RequestInterrupt();
416
417 /// Decrement the "interrupt requested" counter.
419
420 /// This is the correct way to query the state of Interruption.
421 /// If you are on the RunCommandInterpreter thread, it will check the
422 /// command interpreter state, and if it is on another thread it will
423 /// check the debugger Interrupt Request state.
424 /// \param[in] cur_func
425 /// For reporting if the interruption was requested. Don't provide this by
426 /// hand, use INTERRUPT_REQUESTED so this gets done consistently.
427 ///
428 /// \param[in] formatv
429 /// A formatv string for the interrupt message. If the elements of the
430 /// message are expensive to compute, you can use the no-argument form of
431 /// InterruptRequested, then make up the report using REPORT_INTERRUPTION.
432 ///
433 /// \return
434 /// A boolean value, if \b true an interruptible operation should interrupt
435 /// itself.
436 template <typename... Args>
437 bool InterruptRequested(const char *cur_func, const char *formatv,
438 Args &&...args) {
439 bool ret_val = InterruptRequested();
440 if (ret_val) {
441 if (!formatv)
442 formatv = "Unknown message";
443 if (!cur_func)
444 cur_func = "<UNKNOWN>";
446 cur_func, llvm::formatv(formatv, std::forward<Args>(args)...)));
447 }
448 return ret_val;
449 }
450
451 /// This handy define will keep you from having to generate a report for the
452 /// interruption by hand. Use this except in the case where the arguments to
453 /// the message description are expensive to compute.
454#define INTERRUPT_REQUESTED(debugger, ...) \
455 (debugger).InterruptRequested(__func__, __VA_ARGS__)
456
457 // This form just queries for whether to interrupt, and does no reporting:
458 bool InterruptRequested();
459
460 // FIXME: Do we want to capture a backtrace at the interruption point?
462 public:
463 InterruptionReport(std::string function_name, std::string description)
464 : m_function_name(std::move(function_name)),
465 m_description(std::move(description)),
466 m_interrupt_time(std::chrono::system_clock::now()),
467 m_thread_id(llvm::get_threadid()) {}
468
469 InterruptionReport(std::string function_name,
470 const llvm::formatv_object_base &payload);
471
472 template <typename... Args>
473 InterruptionReport(std::string function_name, const char *format,
474 Args &&...args)
476 function_name,
477 llvm::formatv(format, std::forward<Args>(args)...)) {}
478
479 std::string m_function_name;
480 std::string m_description;
481 const std::chrono::time_point<std::chrono::system_clock> m_interrupt_time;
482 const uint64_t m_thread_id;
483 };
484 void ReportInterruption(const InterruptionReport &report);
485#define REPORT_INTERRUPTION(debugger, ...) \
486 (debugger).ReportInterruption( \
487 Debugger::InterruptionReport(__func__, __VA_ARGS__))
488
490
491public:
492 // This is for use in the command interpreter, when you either want the
493 // selected target, or if no target is present you want to prime the dummy
494 // target with entities that will be copied over to new targets.
495 Target &GetSelectedOrDummyTarget(bool prefer_dummy = false);
497
500 }
501
502 /// Shared thread pool. Use only with ThreadPoolTaskGroup.
503 static llvm::ThreadPoolInterface &GetThreadPool();
504
505 /// Report warning events.
506 ///
507 /// Warning events will be delivered to any debuggers that have listeners
508 /// for the eBroadcastBitWarning.
509 ///
510 /// \param[in] message
511 /// The warning message to be reported.
512 ///
513 /// \param [in] debugger_id
514 /// If this optional parameter has a value, it indicates the unique
515 /// debugger identifier that this diagnostic should be delivered to. If
516 /// this optional parameter does not have a value, the diagnostic event
517 /// will be delivered to all debuggers.
518 ///
519 /// \param [in] once
520 /// If a pointer is passed to a std::once_flag, then it will be used to
521 /// ensure the given warning is only broadcast once.
522 static void
523 ReportWarning(std::string message,
524 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
525 std::once_flag *once = nullptr);
526
527 /// Report error events.
528 ///
529 /// Error events will be delivered to any debuggers that have listeners
530 /// for the eBroadcastBitError.
531 ///
532 /// \param[in] message
533 /// The error message to be reported.
534 ///
535 /// \param [in] debugger_id
536 /// If this optional parameter has a value, it indicates the unique
537 /// debugger identifier that this diagnostic should be delivered to. If
538 /// this optional parameter does not have a value, the diagnostic event
539 /// will be delivered to all debuggers.
540 ///
541 /// \param [in] once
542 /// If a pointer is passed to a std::once_flag, then it will be used to
543 /// ensure the given error is only broadcast once.
544 static void
545 ReportError(std::string message,
546 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
547 std::once_flag *once = nullptr);
548
549 /// Report info events.
550 ///
551 /// Unlike warning and error events, info events are not broadcast but are
552 /// logged for diagnostic purposes.
553 ///
554 /// \param[in] message
555 /// The info message to be reported.
556 ///
557 /// \param [in] debugger_id
558 /// If this optional parameter has a value, it indicates this diagnostic is
559 /// associated with a unique debugger instance.
560 ///
561 /// \param [in] once
562 /// If a pointer is passed to a std::once_flag, then it will be used to
563 /// ensure the given info is only logged once.
564 static void
565 ReportInfo(std::string message,
566 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
567 std::once_flag *once = nullptr);
568
569 static void ReportSymbolChange(const ModuleSpec &module_spec);
570
571 /// DEPRECATED: We used to only support one Destroy callback. Now that we
572 /// support Add and Remove, you should only remove callbacks that you added.
573 /// Use Add and Remove instead.
574 ///
575 /// Clear all previously added callbacks and only add the given one.
576 void
578 void *baton);
579
580 /// Add a callback for when the debugger is destroyed. Return a token, which
581 /// can be used to remove said callback. Multiple callbacks can be added by
582 /// calling this function multiple times, and will be invoked in FIFO order.
585 void *baton);
586
587 /// Remove the specified callback. Return true if successful.
589
590 /// Manually start the global event handler thread. It is useful to plugins
591 /// that directly use the \a lldb_private namespace and want to use the
592 /// debugger's default event handler thread instead of defining their own.
594
595 /// Manually stop the debugger's default event handler.
597
598 /// Force flushing the process's pending stdout and stderr to the debugger's
599 /// asynchronous stdout and stderr streams.
600 void FlushProcessOutput(Process &process, bool flush_stdout,
601 bool flush_stderr);
602
604 return m_source_file_cache;
605 }
606
607protected:
608 friend class CommandInterpreter;
609 friend class REPL;
610 friend class Progress;
611 friend class ProgressManager;
612
613 /// Report progress events.
614 ///
615 /// Progress events will be delivered to any debuggers that have listeners
616 /// for the eBroadcastBitProgress. This function is called by the
617 /// lldb_private::Progress class to deliver the events to any debuggers that
618 /// qualify.
619 ///
620 /// \param [in] progress_id
621 /// The unique integer identifier for the progress to report.
622 ///
623 /// \param[in] message
624 /// The title of the progress dialog to display in the UI.
625 ///
626 /// \param [in] completed
627 /// The amount of work completed. If \a completed is zero, then this event
628 /// is a progress started event. If \a completed is equal to \a total, then
629 /// this event is a progress end event. Otherwise completed indicates the
630 /// current progress compare to the total value.
631 ///
632 /// \param [in] total
633 /// The total amount of work units that need to be completed. If this value
634 /// is UINT64_MAX, then an indeterminate progress indicator should be
635 /// displayed.
636 ///
637 /// \param [in] debugger_id
638 /// If this optional parameter has a value, it indicates the unique
639 /// debugger identifier that this progress should be delivered to. If this
640 /// optional parameter does not have a value, the progress will be
641 /// delivered to all debuggers.
642 static void
643 ReportProgress(uint64_t progress_id, std::string title, std::string details,
644 uint64_t completed, uint64_t total,
645 std::optional<lldb::user_id_t> debugger_id,
646 uint32_t progress_category_bit = lldb::eBroadcastBitProgress);
647
648 static void ReportDiagnosticImpl(lldb::Severity severity, std::string message,
649 std::optional<lldb::user_id_t> debugger_id,
650 std::once_flag *once);
651
653
655
656 void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
657 bool cancel_top_handler = true);
658
659 bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
660
661 bool HasIOHandlerThread() const;
662
664
665 void StopIOHandlerThread();
666
667 // Sets the IOHandler thread to the new_thread, and returns
668 // the previous IOHandler thread.
670
671 void JoinIOHandlerThread();
672
674
676
678
679 void HandleBreakpointEvent(const lldb::EventSP &event_sp);
680
681 void HandleProcessEvent(const lldb::EventSP &event_sp);
682
683 void HandleThreadEvent(const lldb::EventSP &event_sp);
684
685 void HandleProgressEvent(const lldb::EventSP &event_sp);
686
687 void HandleDiagnosticEvent(const lldb::EventSP &event_sp);
688
689 // Ensures two threads don't attempt to flush process output in parallel.
691
692 void InstanceInitialize();
693
694 // these should never be NULL
698
699 /// Used for shadowing the input file when capturing a reproducer.
700 repro::DataRecorder *m_input_recorder;
701
703 // broadcaster manager of
704 // last resort.
705 // It needs to get constructed before the target_list or any other member
706 // that might want to broadcast through the debugger.
707
710
713 std::unique_ptr<SourceManager> m_source_manager_up; // This is a scratch
714 // source manager that we
715 // return if we have no
716 // targets.
718 // for targets created in
719 // this debugger used this
720 // shared
721 // source file cache.
722 std::unique_ptr<CommandInterpreter> m_command_interpreter_up;
723
724 std::recursive_mutex m_script_interpreter_mutex;
725 std::array<lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown>
727
729 std::recursive_mutex m_io_handler_synchronous_mutex;
730
731 std::optional<uint64_t> m_current_event_id;
732
733 llvm::StringMap<std::weak_ptr<LogHandler>> m_stream_handlers;
734 std::shared_ptr<CallbackLogHandler> m_callback_handler_sp;
735 const std::string m_instance_name;
737 typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
741 Broadcaster m_sync_broadcaster; ///< Private debugger synchronization.
742 Broadcaster m_broadcaster; ///< Public Debugger event broadcaster.
744 llvm::once_flag m_clear_once;
747
754 void *baton)
758 void *baton;
759 };
760 llvm::SmallVector<DestroyCallbackInfo, 2> m_destroy_callbacks;
761
762 uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
764
765 // Events for m_sync_broadcaster
766 enum {
768 };
769
770private:
771 // Use Debugger::CreateInstance() to get a shared pointer to a new debugger
772 // object
773 Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
774
775 Debugger(const Debugger &) = delete;
776 const Debugger &operator=(const Debugger &) = delete;
777};
778
779} // namespace lldb_private
780
781#endif // LLDB_CORE_DEBUGGER_H
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address class.
Definition: Address.h:62
A command line argument class.
Definition: Args.h:33
An event broadcasting class.
Definition: Broadcaster.h:146
const std::chrono::time_point< std::chrono::system_clock > m_interrupt_time
Definition: Debugger.h:481
InterruptionReport(std::string function_name, std::string description)
Definition: Debugger.h:463
InterruptionReport(std::string function_name, const char *format, Args &&...args)
Definition: Debugger.h:473
A class to manage flag bits.
Definition: Debugger.h:80
static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace, llvm::StringRef prompt)
Definition: Debugger.cpp:1460
llvm::StringRef GetAutosuggestionAnsiPrefix() const
Definition: Debugger.cpp:463
repro::DataRecorder * GetInputRecorder()
Definition: Debugger.cpp:1022
lldb::StreamFileSP m_error_stream_sp
Definition: Debugger.h:697
@ eBroadcastBitEventThreadIsListening
Definition: Debugger.h:767
bool SetUseExternalEditor(bool use_external_editor_p)
Definition: Debugger.cpp:405
PlatformList m_platform_list
Definition: Debugger.h:711
HostThread m_event_handler_thread
Definition: Debugger.h:739
static lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid)
Definition: Debugger.cpp:841
uint64_t GetDisassemblyLineCount() const
Definition: Debugger.cpp:558
lldb::TargetSP GetSelectedTarget()
Definition: Debugger.h:185
uint64_t GetTerminalHeight() const
Definition: Debugger.cpp:383
bool SetExternalEditor(llvm::StringRef editor)
Definition: Debugger.cpp:416
void RequestInterrupt()
Interruption in LLDB:
Definition: Debugger.cpp:1332
void ReportInterruption(const InterruptionReport &report)
Definition: Debugger.cpp:1364
StreamFile & GetOutputStream()
Definition: Debugger.h:146
ExecutionContext GetSelectedExecutionContext()
Definition: Debugger.cpp:1103
const std::string m_instance_name
Definition: Debugger.h:735
static void Terminate()
Definition: Debugger.cpp:645
void HandleProgressEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:2078
SourceManager & GetSourceManager()
Definition: Debugger.cpp:1735
bool SetShowProgress(bool show_progress)
Definition: Debugger.cpp:440
lldb::StreamSP GetAsyncOutputStream()
Definition: Debugger.cpp:1324
bool StartEventHandlerThread()
Manually start the global event handler thread.
Definition: Debugger.cpp:2024
bool SetUseSourceCache(bool use_source_cache)
Definition: Debugger.cpp:499
void StopEventHandlerThread()
Manually stop the debugger's default event handler.
Definition: Debugger.cpp:2064
static void ReportInfo(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report info events.
Definition: Debugger.cpp:1634
void SetAsyncExecution(bool async)
Definition: Debugger.cpp:1018
HostThread SetIOHandlerThread(HostThread &new_thread)
Definition: Debugger.cpp:2176
SourceManager::SourceFileCache & GetSourceFileCache()
Definition: Debugger.h:603
void CancelForwardEvents(const lldb::ListenerSP &listener_sp)
Definition: Debugger.cpp:1919
bool GetPrintDecls() const
Definition: Debugger.cpp:587
lldb::FileSP GetInputFileSP()
Definition: Debugger.h:134
bool GetHighlightSource() const
Definition: Debugger.cpp:507
llvm::StringMap< std::weak_ptr< LogHandler > > m_stream_handlers
Definition: Debugger.h:733
CommandInterpreter & GetCommandInterpreter()
Definition: Debugger.h:168
LoadedPluginsList m_loaded_plugins
Definition: Debugger.h:738
bool GetShowInlineDiagnostics() const
Definition: Debugger.cpp:616
std::vector< llvm::sys::DynamicLibrary > LoadedPluginsList
Definition: Debugger.h:737
Debugger(const Debugger &)=delete
bool SetTabSize(uint64_t tab_size)
Definition: Debugger.cpp:604
bool IsHandlingEvents() const
Definition: Debugger.h:385
void HandleDiagnosticEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:2163
static lldb::DebuggerSP GetDebuggerAtIndex(size_t index)
Definition: Debugger.cpp:1390
llvm::StringRef GetAutosuggestionAnsiSuffix() const
Definition: Debugger.cpp:469
StreamFile & GetErrorStream()
Definition: Debugger.h:148
lldb::ListenerSP m_listener_sp
Definition: Debugger.h:712
void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Definition: Debugger.cpp:1270
std::mutex m_destroy_callback_mutex
Definition: Debugger.h:748
lldb::callback_token_t AddDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
Add a callback for when the debugger is destroyed.
Definition: Debugger.cpp:1484
lldb::thread_result_t IOHandlerThread()
Definition: Debugger.cpp:2072
static lldb::TargetSP FindTargetWithProcess(Process *process)
Definition: Debugger.cpp:855
bool GetUseExternalEditor() const
Definition: Debugger.cpp:399
TerminalState m_terminal_state
Definition: Debugger.h:708
const FormatEntity::Entry * GetThreadStopFormat() const
Definition: Debugger.cpp:340
TargetList & GetTargetList()
Get accessor for the target list.
Definition: Debugger.h:198
bool GetEscapeNonPrintables() const
Definition: Debugger.cpp:570
lldb::TargetSP m_dummy_target_sp
Definition: Debugger.h:745
llvm::SmallVector< DestroyCallbackInfo, 2 > m_destroy_callbacks
Definition: Debugger.h:760
std::unique_ptr< CommandInterpreter > m_command_interpreter_up
Definition: Debugger.h:722
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
Definition: Debugger.cpp:1622
static bool FormatDisassemblerAddress(const FormatEntity::Entry *format, const SymbolContext *sc, const SymbolContext *prev_sc, const ExecutionContext *exe_ctx, const Address *addr, Stream &s)
Definition: Debugger.cpp:1418
static void SettingsInitialize()
Definition: Debugger.cpp:671
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
Definition: Debugger.cpp:2271
llvm::StringRef GetShowProgressAnsiSuffix() const
Definition: Debugger.cpp:451
bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp)
Definition: Debugger.cpp:1190
bool HasIOHandlerThread() const
Definition: Debugger.cpp:2172
bool IsIOHandlerThreadCurrentThread() const
Definition: Debugger.cpp:2212
lldb::ListenerSP m_forward_listener_sp
Definition: Debugger.h:743
std::array< lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown > m_script_interpreters
Definition: Debugger.h:726
std::shared_ptr< CallbackLogHandler > m_callback_handler_sp
Definition: Debugger.h:734
void SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
DEPRECATED: We used to only support one Destroy callback.
Definition: Debugger.cpp:1476
StopDisassemblyType GetStopDisassemblyDisplay() const
Definition: Debugger.cpp:551
Broadcaster m_broadcaster
Public Debugger event broadcaster.
Definition: Debugger.h:742
static void Initialize(LoadPluginCallbackType load_plugin_callback)
Definition: Debugger.cpp:636
static lldb::DebuggerSP FindDebuggerWithInstanceName(llvm::StringRef instance_name)
Definition: Debugger.cpp:826
uint64_t GetTerminalWidth() const
Definition: Debugger.cpp:367
std::mutex m_interrupt_mutex
Definition: Debugger.h:763
std::recursive_mutex m_io_handler_synchronous_mutex
Definition: Debugger.h:729
bool InterruptRequested(const char *cur_func, const char *formatv, Args &&...args)
This is the correct way to query the state of Interruption.
Definition: Debugger.h:437
bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp)
Remove the given IO handler if it's currently active.
Definition: Debugger.cpp:1220
Diagnostics::CallbackID m_diagnostics_callback_id
Definition: Debugger.h:746
void SetPrompt(const char *)=delete
bool GetAutoOneLineSummaries() const
Definition: Debugger.cpp:564
const char * GetIOHandlerCommandPrefix()
Definition: Debugger.cpp:1212
bool GetUseColor() const
Definition: Debugger.cpp:421
lldb::BroadcasterManagerSP m_broadcaster_manager_sp
Definition: Debugger.h:702
Status RunREPL(lldb::LanguageType language, const char *repl_options)
Definition: Debugger.cpp:2226
bool PopIOHandler(const lldb::IOHandlerSP &reader_sp)
Definition: Debugger.cpp:1297
bool RemoveDestroyCallback(lldb::callback_token_t token)
Remove the specified callback. Return true if successful.
Definition: Debugger.cpp:1492
static LoadPluginCallbackType g_load_plugin_callback
Definition: Debugger.h:736
std::recursive_mutex m_script_interpreter_mutex
Definition: Debugger.h:724
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
Definition: Debugger.cpp:1224
void SetInputFile(lldb::FileSP file)
Definition: Debugger.cpp:1077
lldb::StreamFileSP GetErrorStreamSP()
Definition: Debugger.h:138
void SetPrompt(llvm::StringRef p)
Definition: Debugger.cpp:324
lldb::StreamSP GetAsyncErrorStream()
Definition: Debugger.cpp:1328
bool EnableLog(llvm::StringRef channel, llvm::ArrayRef< const char * > categories, llvm::StringRef log_file, uint32_t log_options, size_t buffer_size, LogHandlerKind log_handler_kind, llvm::raw_ostream &error_stream)
Definition: Debugger.cpp:1668
uint64_t GetStopDisassemblyMaxSize() const
Definition: Debugger.cpp:294
bool SetTerminalHeight(uint64_t term_height)
Definition: Debugger.cpp:389
Broadcaster m_sync_broadcaster
Private debugger synchronization.
Definition: Debugger.h:741
void RestoreInputTerminalState()
Definition: Debugger.cpp:1101
bool GetUseSourceCache() const
Definition: Debugger.cpp:493
HostThread m_io_handler_thread
Definition: Debugger.h:740
llvm::StringRef GetRegexMatchAnsiSuffix() const
Definition: Debugger.cpp:481
static llvm::StringRef GetStaticBroadcasterClass()
Definition: Debugger.cpp:869
lldb::FileSP m_input_file_sp
Definition: Debugger.h:695
const Broadcaster & GetBroadcaster() const
Definition: Debugger.h:88
bool SetREPLLanguage(lldb::LanguageType repl_lang)
Definition: Debugger.cpp:362
const FormatEntity::Entry * GetDisassemblyFormat() const
Definition: Debugger.cpp:279
bool GetAutoIndent() const
Definition: Debugger.cpp:576
llvm::StringRef GetStopShowColumnAnsiSuffix() const
Definition: Debugger.cpp:526
Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value) override
Definition: Debugger.cpp:200
llvm::StringRef GetPromptAnsiSuffix() const
Definition: Debugger.cpp:318
void SetErrorFile(lldb::FileSP file)
Definition: Debugger.cpp:1090
bool GetAutoConfirm() const
Definition: Debugger.cpp:273
TargetList m_target_list
Definition: Debugger.h:709
lldb::ScriptLanguage GetScriptLanguage() const
Definition: Debugger.cpp:345
lldb::callback_token_t m_destroy_callback_next_token
Definition: Debugger.h:749
std::unique_ptr< SourceManager > m_source_manager_up
Definition: Debugger.h:713
static lldb::DebuggerSP CreateInstance(lldb::LogOutputCallback log_callback=nullptr, void *baton=nullptr)
Definition: Debugger.cpp:763
lldb::StopShowColumn GetStopShowColumn() const
Definition: Debugger.cpp:513
static void ReportSymbolChange(const ModuleSpec &module_spec)
Definition: Debugger.cpp:1640
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
Definition: Debugger.cpp:1628
bool SetPrintDecls(bool b)
Definition: Debugger.cpp:593
bool SetScriptLanguage(lldb::ScriptLanguage script_lang)
Definition: Debugger.cpp:352
bool SetShowInlineDiagnostics(bool)
Definition: Debugger.cpp:622
bool LoadPlugin(const FileSpec &spec, Status &error)
Definition: Debugger.cpp:675
void SetOutputFile(lldb::FileSP file)
Definition: Debugger.cpp:1085
uint64_t GetStopSourceLineCount(bool before) const
Definition: Debugger.cpp:544
void EnableForwardEvents(const lldb::ListenerSP &listener_sp)
Definition: Debugger.cpp:1915
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id)
Definition: Debugger.cpp:1402
void HandleBreakpointEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1742
bool CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
Definition: Debugger.cpp:1194
PlatformList & GetPlatformList()
Definition: Debugger.h:200
Target & GetDummyTarget()
Definition: Debugger.h:496
const FormatEntity::Entry * GetFrameFormat() const
Definition: Debugger.cpp:284
lldb::ListenerSP GetListener()
Definition: Debugger.h:177
static void Destroy(lldb::DebuggerSP &debugger_sp)
Definition: Debugger.cpp:794
SourceManager::SourceFileCache m_source_file_cache
Definition: Debugger.h:717
llvm::StringRef GetPromptAnsiPrefix() const
Definition: Debugger.cpp:312
std::optional< uint64_t > m_current_event_id
Definition: Debugger.h:731
void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp)
Run the given IO handler and block until it's complete.
Definition: Debugger.cpp:1159
const FormatEntity::Entry * GetThreadFormat() const
Definition: Debugger.cpp:335
Broadcaster & GetBroadcaster()
Get the public broadcaster for this debugger.
Definition: Debugger.h:87
llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const
Definition: Debugger.cpp:532
bool GetShowDontUsePoHint() const
Definition: Debugger.cpp:487
uint64_t GetTabSize() const
Definition: Debugger.cpp:598
lldb::StreamFileSP m_output_stream_sp
Definition: Debugger.h:696
bool GetShowProgress() const
Definition: Debugger.cpp:434
llvm::StringRef GetRegexMatchAnsiPrefix() const
Definition: Debugger.cpp:475
std::mutex m_output_flush_mutex
Definition: Debugger.h:690
llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const
Definition: Debugger.cpp:538
void PrintProgress(const ProgressEventData &data)
bool SetUseColor(bool use_color)
Definition: Debugger.cpp:427
const char * GetIOHandlerHelpPrologue()
Definition: Debugger.cpp:1216
Status SetInputString(const char *data)
Definition: Debugger.cpp:1033
bool GetUseAutosuggestion() const
Definition: Debugger.cpp:457
Target & GetSelectedOrDummyTarget(bool prefer_dummy=false)
Definition: Debugger.cpp:2218
void HandleProcessEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1809
IOHandlerStack m_io_handler_stack
Definition: Debugger.h:728
repro::DataRecorder * m_input_recorder
Used for shadowing the input file when capturing a reproducer.
Definition: Debugger.h:700
lldb::StreamFileSP GetOutputStreamSP()
Definition: Debugger.h:136
llvm::once_flag m_clear_once
Definition: Debugger.h:744
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::StreamFileSP &out, lldb::StreamFileSP &err)
Definition: Debugger.cpp:1229
static void SettingsTerminate()
Definition: Debugger.cpp:673
static void ReportProgress(uint64_t progress_id, std::string title, std::string details, uint64_t completed, uint64_t total, std::optional< lldb::user_id_t > debugger_id, uint32_t progress_category_bit=lldb::eBroadcastBitProgress)
Report progress events.
Definition: Debugger.cpp:1520
lldb::LanguageType GetREPLLanguage() const
Definition: Debugger.cpp:357
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1719
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton)
Definition: Debugger.cpp:1467
bool SetTerminalWidth(uint64_t term_width)
Definition: Debugger.cpp:373
llvm::StringRef GetExternalEditor() const
Definition: Debugger.cpp:410
void HandleThreadEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1896
static size_t GetNumDebuggers()
Definition: Debugger.cpp:1382
File & GetOutputFile()
Definition: Debugger.h:142
uint32_t m_interrupt_requested
Tracks interrupt requests.
Definition: Debugger.h:762
lldb::DWIMPrintVerbosity GetDWIMPrintVerbosity() const
Definition: Debugger.cpp:609
const std::string & GetInstanceName()
Definition: Debugger.h:369
lldb::BroadcasterManagerSP GetBroadcasterManager()
Definition: Debugger.h:498
lldb::thread_result_t DefaultEventHandler()
Definition: Debugger.cpp:1923
void PrintAsync(const char *s, size_t len, bool is_stdout)
Definition: Debugger.cpp:1199
llvm::StringRef GetPrompt() const
Definition: Debugger.cpp:306
bool GetNotifyVoid() const
Definition: Debugger.cpp:300
llvm::StringRef GetShowProgressAnsiPrefix() const
Definition: Debugger.cpp:445
const FormatEntity::Entry * GetFrameFormatUnique() const
Definition: Debugger.cpp:289
llvm::StringRef GetTopIOHandlerControlSequence(char ch)
Definition: Debugger.cpp:1208
void FlushProcessOutput(Process &process, bool flush_stdout, bool flush_stderr)
Force flushing the process's pending stdout and stderr to the debugger's asynchronous stdout and stde...
Definition: Debugger.cpp:1789
void CancelInterruptRequest()
Decrement the "interrupt requested" counter.
Definition: Debugger.cpp:1337
static void ReportDiagnosticImpl(lldb::Severity severity, std::string message, std::optional< lldb::user_id_t > debugger_id, std::once_flag *once)
Definition: Debugger.cpp:1581
std::vector< lldb::DebuggerSP > DebuggerList
Definition: Debugger.h:82
bool SetAutoIndent(bool b)
Definition: Debugger.cpp:582
const Debugger & operator=(const Debugger &)=delete
llvm::StringRef GetStopShowColumnAnsiPrefix() const
Definition: Debugger.cpp:520
static DebuggerList DebuggersRequestingInterruption()
Definition: Debugger.cpp:1370
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file utility class.
Definition: FileSpec.h:56
An abstract base class for files.
Definition: File.h:36
A plug-in interface definition class for debugging a process.
Definition: Process.h:343
A class used to group progress reports by category.
Definition: Progress.h:168
A Progress indicator helper class.
Definition: Progress.h:60
The SourceFileCache class separates the source manager from the cache of source files.
An error handling class.
Definition: Status.h:118
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:34
lldb::TargetSP GetSelectedTarget()
Definition: TargetList.cpp:545
A RAII-friendly terminal state saving/restoring class.
Definition: Terminal.h:87
A class that represents a running process on the host machine.
void(* DebuggerDestroyCallback)(lldb::user_id_t debugger_id, void *baton)
llvm::sys::DynamicLibrary(* LoadPluginCallbackType)(const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error)
VarSetOperationType
Settable state variable types.
ScriptLanguage
Script interpreter types.
Severity
Used for expressing severity in logs and diagnostics.
std::shared_ptr< lldb_private::BroadcasterManager > BroadcasterManagerSP
Definition: lldb-forward.h:330
@ eBroadcastBitProgress
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
Definition: lldb-forward.h:361
void * thread_result_t
Definition: lldb-types.h:62
DWIMPrintVerbosity
Enum to control the verbosity level of dwim-print execution.
LanguageType
Programming language type.
std::shared_ptr< lldb_private::Stream > StreamSP
Definition: lldb-forward.h:432
std::shared_ptr< lldb_private::Debugger > DebuggerSP
Definition: lldb-forward.h:339
std::shared_ptr< lldb_private::Event > EventSP
Definition: lldb-forward.h:345
uint64_t pid_t
Definition: lldb-types.h:83
std::shared_ptr< lldb_private::Listener > ListenerSP
Definition: lldb-forward.h:368
std::shared_ptr< lldb_private::StreamFile > StreamFileSP
Definition: lldb-forward.h:433
int32_t callback_token_t
Definition: lldb-types.h:81
uint64_t user_id_t
Definition: lldb-types.h:82
void(* LogOutputCallback)(const char *, void *baton)
Definition: lldb-types.h:73
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:448
std::shared_ptr< lldb_private::File > FileSP
Definition: lldb-forward.h:353
Definition: Debugger.h:54
DestroyCallbackInfo(lldb::callback_token_t token, lldb_private::DebuggerDestroyCallback callback, void *baton)
Definition: Debugger.h:752
lldb_private::DebuggerDestroyCallback callback
Definition: Debugger.h:757
A mix in class that contains a generic user ID.
Definition: UserID.h:31