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"
24#include "lldb/Core/Telemetry.h"
28#include "lldb/Host/Terminal.h"
36#include "lldb/Utility/Status.h"
38#include "lldb/Utility/UserID.h"
39#include "lldb/lldb-defines.h"
41#include "lldb/lldb-forward.h"
44#include "lldb/lldb-types.h"
45
46#include "llvm/ADT/ArrayRef.h"
47#include "llvm/ADT/SmallVector.h"
48#include "llvm/ADT/StringMap.h"
49#include "llvm/ADT/StringRef.h"
50#include "llvm/Support/DynamicLibrary.h"
51#include "llvm/Support/FormatVariadic.h"
52#include "llvm/Support/Threading.h"
53
54#include <cassert>
55#include <cstddef>
56#include <cstdio>
57
58namespace llvm {
59class raw_ostream;
60class ThreadPoolInterface;
61} // namespace llvm
62
63namespace lldb_private {
64class Address;
65class CallbackLogHandler;
66class CommandInterpreter;
67class LogHandler;
68class Process;
69class Stream;
70class SymbolContext;
71class Target;
72class Debugger;
73
74#ifndef NDEBUG
75/// Global properties used in the LLDB testsuite.
78 bool GetInjectVarLocListError() const;
80
81 /// Overwrites the testing.safe-auto-load-paths settings.
83
84 /// Appends a path to the testing.safe-auto-load-paths setting.
86
87private:
88 friend Debugger;
89
90 /// Callers should use Debugger::GetSafeAutoLoadPaths since it
91 /// accounts for default paths configured via CMake.
93};
94#endif
95
96/// A class to manage flag bits.
97///
98/// Provides a global root objects for the debugger core.
99class Debugger : public std::enable_shared_from_this<Debugger>,
100 public UserID,
101 public Properties {
102public:
103 using DebuggerList = std::vector<lldb::DebuggerSP>;
104
105 static llvm::StringRef GetStaticBroadcasterClass();
106
107 /// Get the public broadcaster for this debugger.
109 const Broadcaster &GetBroadcaster() const { return m_broadcaster; }
110
111 ~Debugger() override;
112
113 static lldb::DebuggerSP
114 CreateInstance(lldb::LogOutputCallback log_callback = nullptr,
115 void *baton = nullptr);
116
117 static void Initialize(LoadPluginCallbackType load_plugin_callback);
118
119 static void Terminate();
120
121 static void SettingsInitialize();
122
123 static void SettingsTerminate();
124
125 static void Destroy(lldb::DebuggerSP &debugger_sp);
126
127 /// Get the build configuration as structured data.
129
131
132 static lldb::DebuggerSP
133 FindDebuggerWithInstanceName(llvm::StringRef instance_name);
134
135 static size_t GetNumDebuggers();
136
137 static lldb::DebuggerSP GetDebuggerAtIndex(size_t index);
138
139 static bool FormatDisassemblerAddress(const FormatEntity::Entry *format,
140 const SymbolContext *sc,
141 const SymbolContext *prev_sc,
142 const ExecutionContext *exe_ctx,
143 const Address *addr, Stream &s);
144
145 static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace,
146 llvm::StringRef prompt);
147
148 /// Get the list of paths that LLDB will consider automatically loading
149 /// scripting resources from. Currently whether to load scripts
150 /// unconditionally is controlled via the
151 /// `target.load-script-from-symbol-file` setting.
153
154 void Clear();
155
157
158 bool GetAsyncExecution();
159
160 void SetAsyncExecution(bool async);
161
164
166 return m_output_stream_sp->GetUnlockedFileSP();
167 }
168
170 return m_error_stream_sp->GetUnlockedFileSP();
171 }
172
173 Status SetInputString(const char *data);
174
175 void SetInputFile(lldb::FileSP file);
176
177 void SetOutputFile(lldb::FileSP file);
178
179 void SetErrorFile(lldb::FileSP file);
180
182
184
186
188
193
195 GetScriptInterpreter(bool can_create = true,
196 std::optional<lldb::ScriptLanguage> language = {});
197
199
200 // This returns the Debugger's scratch source manager. It won't be able to
201 // look up files in debug information, but it can look up files by absolute
202 // path and display them to you. To get the target's source manager, call
203 // GetSourceManager on the target instead.
205
207 return m_target_list.GetSelectedTarget();
208 }
209
210 /// Get the execution context representing the selected entities in the
211 /// selected target.
213
214 /// Similar to GetSelectedExecutionContext but returns a
215 /// ExecutionContextRef, and will hold the dummy target if no target is
216 /// currently selected.
218
219 /// Get accessor for the target list.
220 ///
221 /// The target list is part of the global debugger object. This the single
222 /// debugger shared instance to control where targets get created and to
223 /// allow for tracking and searching for targets based on certain criteria.
224 ///
225 /// \return
226 /// A global shared target list.
228
230
232
234
235 // If any of the streams are not set, set them to the in/out/err stream of
236 // the top most input reader to ensure they at least have something
240
241 /// Run the given IO handler and return immediately.
242 void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp,
243 bool cancel_top_handler = true);
244
245 /// Run the given IO handler and block until it's complete.
246 void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp);
247
248 /// Remove the given IO handler if it's currently active.
249 bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp);
250
251 bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp);
252
254 IOHandler::Type second_top_type);
255
256 void PrintAsync(const char *s, size_t len, bool is_stdout);
257
258 llvm::StringRef GetTopIOHandlerControlSequence(char ch);
259
260 const char *GetIOHandlerCommandPrefix();
261
262 const char *GetIOHandlerHelpPrologue();
263
264 void RefreshIOHandler();
265
266 void ClearIOHandlers();
267
268 bool EnableLog(llvm::StringRef channel,
269 llvm::ArrayRef<const char *> categories,
270 llvm::StringRef log_file, uint32_t log_options,
271 size_t buffer_size, LogHandlerKind log_handler_kind,
272 llvm::raw_ostream &error_stream);
273
274 void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
275
277 VarSetOperationType op, llvm::StringRef property_path,
278 llvm::StringRef value) override;
279
280 bool GetAutoConfirm() const;
281
283
285
287
288 uint64_t GetStopDisassemblyMaxSize() const;
289
291
293
295
296 bool SetScriptLanguage(lldb::ScriptLanguage script_lang);
297
299
300 bool SetREPLLanguage(lldb::LanguageType repl_lang);
301
302 uint64_t GetTerminalWidth() const;
303
304 bool SetTerminalWidth(uint64_t term_width);
305
306 uint64_t GetTerminalHeight() const;
307
308 bool SetTerminalHeight(uint64_t term_height);
309
310 llvm::StringRef GetPrompt() const;
311
312 llvm::StringRef GetPromptAnsiPrefix() const;
313
314 llvm::StringRef GetPromptAnsiSuffix() const;
315
316 void SetPrompt(llvm::StringRef p);
317 void SetPrompt(const char *) = delete;
318
319 bool GetUseExternalEditor() const;
320 bool SetUseExternalEditor(bool use_external_editor_p);
321
322 llvm::StringRef GetExternalEditor() const;
323
324 bool SetExternalEditor(llvm::StringRef editor);
325
326 bool GetUseColor() const;
327
328 bool SetUseColor(bool use_color);
329
330 bool GetShowProgress() const;
331
332 bool SetShowProgress(bool show_progress);
333
334 bool GetShowStatusline() const;
335
337 bool SetStatuslineFormat(const FormatEntity::Entry &format);
338
339 llvm::StringRef GetSeparator() const;
340 bool SetSeparator(llvm::StringRef s);
341
342 llvm::StringRef GetShowProgressAnsiPrefix() const;
343
344 llvm::StringRef GetShowProgressAnsiSuffix() const;
345
346 llvm::StringRef GetDisabledAnsiPrefix() const;
347
348 llvm::StringRef GetDisabledAnsiSuffix() const;
349
350 bool GetUseAutosuggestion() const;
351
352 llvm::StringRef GetAutosuggestionAnsiPrefix() const;
353
354 llvm::StringRef GetAutosuggestionAnsiSuffix() const;
355
356 llvm::StringRef GetRegexMatchAnsiPrefix() const;
357
358 llvm::StringRef GetRegexMatchAnsiSuffix() const;
359
360 bool GetShowDontUsePoHint() const;
361
362 bool GetUseSourceCache() const;
363
364 bool SetUseSourceCache(bool use_source_cache);
365
366 bool GetMarkHiddenFrames() const;
367
368 bool GetHighlightSource() const;
369
371
372 llvm::StringRef GetStopShowColumnAnsiPrefix() const;
373
374 llvm::StringRef GetStopShowColumnAnsiSuffix() const;
375
376 uint64_t GetStopSourceLineCount(bool before) const;
377
379
380 uint64_t GetDisassemblyLineCount() const;
381
382 llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const;
383
384 llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const;
385
386 bool GetAutoOneLineSummaries() const;
387
388 bool GetAutoIndent() const;
389
390 bool SetAutoIndent(bool b);
391
392 bool GetPrintDecls() const;
393
394 bool SetPrintDecls(bool b);
395
396 uint64_t GetTabSize() const;
397
398 bool SetTabSize(uint64_t tab_size);
399
401
402 bool GetEscapeNonPrintables() const;
403
404 bool GetNotifyVoid() const;
405
406 const std::string &GetInstanceName() const { return m_instance_name; }
407
408 bool GetShowInlineDiagnostics() const;
409
410 bool SetShowInlineDiagnostics(bool);
411
412 bool LoadPlugin(const FileSpec &spec, Status &error);
413
414 void RunIOHandlers();
415
416 bool IsForwardingEvents();
417
418 void EnableForwardEvents(const lldb::ListenerSP &listener_sp);
419
420 void CancelForwardEvents(const lldb::ListenerSP &listener_sp);
421
422 bool IsHandlingEvents() const { return m_event_handler_thread.IsJoinable(); }
423
424 Status RunREPL(lldb::LanguageType language, const char *repl_options);
425
426 /// Interruption in LLDB:
427 ///
428 /// This is a voluntary interruption mechanism, not preemptive. Parts of lldb
429 /// that do work that can be safely interrupted call
430 /// Debugger::InterruptRequested and if that returns true, they should return
431 /// at a safe point, shortcutting the rest of the work they were to do.
432 ///
433 /// lldb clients can both offer a CommandInterpreter (through
434 /// RunCommandInterpreter) and use the SB API's for their own purposes, so it
435 /// is convenient to separate "interrupting the CommandInterpreter execution"
436 /// and interrupting the work it is doing with the SB API's. So there are two
437 /// ways to cause an interrupt:
438 /// * CommandInterpreter::InterruptCommand: Interrupts the command currently
439 /// running in the command interpreter IOHandler thread
440 /// * Debugger::RequestInterrupt: Interrupts are active on anything but the
441 /// CommandInterpreter thread till CancelInterruptRequest is called.
442 ///
443 /// Since the two checks are mutually exclusive, however, it's also convenient
444 /// to have just one function to check the interrupt state.
445
446 /// Bump the "interrupt requested" count on the debugger to support
447 /// cooperative interruption. If this is non-zero, InterruptRequested will
448 /// return true. Interruptible operations are expected to query the
449 /// InterruptRequested API periodically, and interrupt what they were doing
450 /// if it returns \b true.
451 ///
452 void RequestInterrupt();
453
454 /// Decrement the "interrupt requested" counter.
456
457 /// Redraw the statusline if enabled.
458 void RedrawStatusline(std::optional<ExecutionContextRef> exe_ctx_ref);
459
460 /// This is the correct way to query the state of Interruption.
461 /// If you are on the RunCommandInterpreter thread, it will check the
462 /// command interpreter state, and if it is on another thread it will
463 /// check the debugger Interrupt Request state.
464 /// \param[in] cur_func
465 /// For reporting if the interruption was requested. Don't provide this by
466 /// hand, use INTERRUPT_REQUESTED so this gets done consistently.
467 ///
468 /// \param[in] formatv
469 /// A formatv string for the interrupt message. If the elements of the
470 /// message are expensive to compute, you can use the no-argument form of
471 /// InterruptRequested, then make up the report using REPORT_INTERRUPTION.
472 ///
473 /// \return
474 /// A boolean value, if \b true an interruptible operation should interrupt
475 /// itself.
476 template <typename... Args>
477 bool InterruptRequested(const char *cur_func, const char *formatv,
478 Args &&...args) {
479 bool ret_val = InterruptRequested();
480 if (ret_val) {
481 if (!formatv)
482 formatv = "Unknown message";
483 if (!cur_func)
484 cur_func = "<UNKNOWN>";
486 cur_func, llvm::formatv(formatv, std::forward<Args>(args)...)));
487 }
488 return ret_val;
489 }
490
491 /// This handy define will keep you from having to generate a report for the
492 /// interruption by hand. Use this except in the case where the arguments to
493 /// the message description are expensive to compute.
494#define INTERRUPT_REQUESTED(debugger, ...) \
495 (debugger).InterruptRequested(__func__, __VA_ARGS__)
496
497 // This form just queries for whether to interrupt, and does no reporting:
498 bool InterruptRequested();
499
500 // FIXME: Do we want to capture a backtrace at the interruption point?
502 public:
503 InterruptionReport(std::string function_name, std::string description)
504 : m_function_name(std::move(function_name)),
505 m_description(std::move(description)),
506 m_interrupt_time(std::chrono::system_clock::now()),
507 m_thread_id(llvm::get_threadid()) {}
508
509 InterruptionReport(std::string function_name,
510 const llvm::formatv_object_base &payload);
511
512 template <typename... Args>
513 InterruptionReport(std::string function_name, const char *format,
514 Args &&...args)
516 function_name,
517 llvm::formatv(format, std::forward<Args>(args)...)) {}
518
519 std::string m_function_name;
520 std::string m_description;
521 const std::chrono::time_point<std::chrono::system_clock> m_interrupt_time;
522 const uint64_t m_thread_id;
523 };
524 void ReportInterruption(const InterruptionReport &report);
525#define REPORT_INTERRUPTION(debugger, ...) \
526 (debugger).ReportInterruption( \
527 Debugger::InterruptionReport(__func__, __VA_ARGS__))
528
530
531public:
532 // This is for use in the command interpreter, when you either want the
533 // selected target, or if no target is present you want to prime the dummy
534 // target with entities that will be copied over to new targets.
535 Target &GetSelectedOrDummyTarget(bool prefer_dummy = false);
537
541
542 /// Shared thread pool. Use only with ThreadPoolTaskGroup.
543 static llvm::ThreadPoolInterface &GetThreadPool();
544
545 /// Report warning events.
546 ///
547 /// Warning events will be delivered to any debuggers that have listeners
548 /// for the eBroadcastBitWarning.
549 ///
550 /// \param[in] message
551 /// The warning message to be reported.
552 ///
553 /// \param [in] debugger_id
554 /// If this optional parameter has a value, it indicates the unique
555 /// debugger identifier that this diagnostic should be delivered to. If
556 /// this optional parameter does not have a value, the diagnostic event
557 /// will be delivered to all debuggers.
558 ///
559 /// \param [in] once
560 /// If a pointer is passed to a std::once_flag, then it will be used to
561 /// ensure the given warning is only broadcast once.
562 static void
563 ReportWarning(std::string message,
564 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
565 std::once_flag *once = nullptr);
566
567 /// Report error events.
568 ///
569 /// Error events will be delivered to any debuggers that have listeners
570 /// for the eBroadcastBitError.
571 ///
572 /// \param[in] message
573 /// The error message to be reported.
574 ///
575 /// \param [in] debugger_id
576 /// If this optional parameter has a value, it indicates the unique
577 /// debugger identifier that this diagnostic should be delivered to. If
578 /// this optional parameter does not have a value, the diagnostic event
579 /// will be delivered to all debuggers.
580 ///
581 /// \param [in] once
582 /// If a pointer is passed to a std::once_flag, then it will be used to
583 /// ensure the given error is only broadcast once.
584 static void
585 ReportError(std::string message,
586 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
587 std::once_flag *once = nullptr);
588
589 /// Report info events.
590 ///
591 /// Unlike warning and error events, info events are not broadcast but are
592 /// logged for diagnostic purposes.
593 ///
594 /// \param[in] message
595 /// The info message to be reported.
596 ///
597 /// \param [in] debugger_id
598 /// If this optional parameter has a value, it indicates this diagnostic is
599 /// associated with a unique debugger instance.
600 ///
601 /// \param [in] once
602 /// If a pointer is passed to a std::once_flag, then it will be used to
603 /// ensure the given info is only logged once.
604 static void
605 ReportInfo(std::string message,
606 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
607 std::once_flag *once = nullptr);
608
609 static void ReportSymbolChange(const ModuleSpec &module_spec);
610
611 /// DEPRECATED: We used to only support one Destroy callback. Now that we
612 /// support Add and Remove, you should only remove callbacks that you added.
613 /// Use Add and Remove instead.
614 ///
615 /// Clear all previously added callbacks and only add the given one.
616 void
618 void *baton);
619
620 /// Add a callback for when the debugger is destroyed. Return a token, which
621 /// can be used to remove said callback. Multiple callbacks can be added by
622 /// calling this function multiple times, and will be invoked in FIFO order.
625 void *baton);
626
627 /// Remove the specified callback. Return true if successful.
629
630 /// Manually start the global event handler thread. It is useful to plugins
631 /// that directly use the \a lldb_private namespace and want to use the
632 /// debugger's default event handler thread instead of defining their own.
634
635 /// Manually stop the debugger's default event handler.
637
638 /// Force flushing the process's pending stdout and stderr to the debugger's
639 /// asynchronous stdout and stderr streams.
640 void FlushProcessOutput(Process &process, bool flush_stdout,
641 bool flush_stderr);
642
646
648 uint64_t id;
649 uint64_t completed;
650 uint64_t total;
651 std::string message;
652 };
653 std::optional<ProgressReport> GetCurrentProgressReport() const;
654
655protected:
656 friend class CommandInterpreter;
657 friend class REPL;
658 friend class Progress;
659 friend class ProgressManager;
660 friend class Statusline;
661
662 /// Report progress events.
663 ///
664 /// Progress events will be delivered to any debuggers that have listeners
665 /// for the eBroadcastBitProgress. This function is called by the
666 /// lldb_private::Progress class to deliver the events to any debuggers that
667 /// qualify.
668 ///
669 /// \param [in] progress_id
670 /// The unique integer identifier for the progress to report.
671 ///
672 /// \param[in] message
673 /// The title of the progress dialog to display in the UI.
674 ///
675 /// \param [in] completed
676 /// The amount of work completed. If \a completed is zero, then this event
677 /// is a progress started event. If \a completed is equal to \a total, then
678 /// this event is a progress end event. Otherwise completed indicates the
679 /// current progress compare to the total value.
680 ///
681 /// \param [in] total
682 /// The total amount of work units that need to be completed. If this value
683 /// is UINT64_MAX, then an indeterminate progress indicator should be
684 /// displayed.
685 ///
686 /// \param [in] debugger_id
687 /// If this optional parameter has a value, it indicates the unique
688 /// debugger identifier that this progress should be delivered to. If this
689 /// optional parameter does not have a value, the progress will be
690 /// delivered to all debuggers.
691 static void
692 ReportProgress(uint64_t progress_id, std::string title, std::string details,
693 uint64_t completed, uint64_t total,
694 std::optional<lldb::user_id_t> debugger_id,
695 uint32_t progress_category_bit = lldb::eBroadcastBitProgress);
696
697 static void ReportDiagnosticImpl(lldb::Severity severity, std::string message,
698 std::optional<lldb::user_id_t> debugger_id,
699 std::once_flag *once);
700
702
704
705 /// Except for Debugger and IOHandler, GetOutputStreamSP and GetErrorStreamSP
706 /// should not be used directly. Use GetAsyncOutputStream and
707 /// GetAsyncErrorStream instead.
708 /// @{
711 /// @}
712
714 bool StatuslineSupported();
715
716 void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
717 bool cancel_top_handler = true);
718
719 bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
720
721 bool HasIOHandlerThread() const;
722
724
725 void StopIOHandlerThread();
726
727 // Sets the IOHandler thread to the new_thread, and returns
728 // the previous IOHandler thread.
730
731 void JoinIOHandlerThread();
732
734
736
738
739 void HandleBreakpointEvent(const lldb::EventSP &event_sp);
740
742
744
745 void HandleProgressEvent(const lldb::EventSP &event_sp);
746
747 void HandleDiagnosticEvent(const lldb::EventSP &event_sp);
748
749 // Ensures two threads don't attempt to flush process output in parallel.
751
752 void InstanceInitialize();
753
754 // these should never be NULL
759
761 // broadcaster manager of
762 // last resort.
763 // It needs to get constructed before the target_list or any other member
764 // that might want to broadcast through the debugger.
765
768
771 std::unique_ptr<SourceManager> m_source_manager_up; // This is a scratch
772 // source manager that we
773 // return if we have no
774 // targets.
776 // for targets created in
777 // this debugger used this
778 // shared
779 // source file cache.
780 std::unique_ptr<CommandInterpreter> m_command_interpreter_up;
781
782 std::recursive_mutex m_script_interpreter_mutex;
783 std::array<lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown>
785
787 std::recursive_mutex m_io_handler_synchronous_mutex;
788
789 /// Mutex protecting the m_statusline member.
791 std::optional<Statusline> m_statusline;
792
793 llvm::StringMap<std::weak_ptr<LogHandler>> m_stream_handlers;
794 std::shared_ptr<CallbackLogHandler> m_callback_handler_sp;
795 const std::string m_instance_name;
797 typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
801 Broadcaster m_sync_broadcaster; ///< Private debugger synchronization.
802 Broadcaster m_broadcaster; ///< Public Debugger event broadcaster.
804 llvm::once_flag m_clear_once;
807
808 /// Bookkeeping for command line progress events.
809 /// @{
810 llvm::SmallVector<ProgressReport, 4> m_progress_reports;
811 mutable std::mutex m_progress_reports_mutex;
812 /// @}
813
826 llvm::SmallVector<DestroyCallbackInfo, 2> m_destroy_callbacks;
827
828 uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
830
831 // Events for m_sync_broadcaster
832 enum {
834 };
835
836private:
837 // Use Debugger::CreateInstance() to get a shared pointer to a new debugger
838 // object
839 Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
840
841 Debugger(const Debugger &) = delete;
842 const Debugger &operator=(const Debugger &) = delete;
843};
844
845} // namespace lldb_private
846
847#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.
const std::chrono::time_point< std::chrono::system_clock > m_interrupt_time
Definition Debugger.h:521
InterruptionReport(std::string function_name, std::string description)
Definition Debugger.h:503
InterruptionReport(std::string function_name, const char *format, Args &&...args)
Definition Debugger.h:513
static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace, llvm::StringRef prompt)
llvm::StringRef GetAutosuggestionAnsiPrefix() const
Definition Debugger.cpp:611
bool SetUseExternalEditor(bool use_external_editor_p)
Definition Debugger.cpp:508
PlatformList m_platform_list
Definition Debugger.h:769
HostThread m_event_handler_thread
Definition Debugger.h:799
FormatEntity::Entry GetDisassemblyFormat() const
Definition Debugger.cpp:370
uint64_t GetDisassemblyLineCount() const
Definition Debugger.cpp:713
lldb::TargetSP GetSelectedTarget()
Definition Debugger.h:206
llvm::StringRef GetDisabledAnsiSuffix() const
Definition Debugger.cpp:592
uint64_t GetTerminalHeight() const
Definition Debugger.cpp:480
lldb::LockableStreamFileSP m_output_stream_sp
Definition Debugger.h:756
bool SetExternalEditor(llvm::StringRef editor)
Definition Debugger.cpp:519
void RequestInterrupt()
Interruption in LLDB:
void ReportInterruption(const InterruptionReport &report)
ExecutionContext GetSelectedExecutionContext()
Get the execution context representing the selected entities in the selected target.
const std::string m_instance_name
Definition Debugger.h:795
static void Terminate()
Definition Debugger.cpp:800
lldb::ThreadSP HandleThreadEvent(const lldb::EventSP &event_sp)
void HandleProgressEvent(const lldb::EventSP &event_sp)
SourceManager & GetSourceManager()
bool SetShowProgress(bool show_progress)
Definition Debugger.cpp:545
bool StartEventHandlerThread()
Manually start the global event handler thread.
bool SetUseSourceCache(bool use_source_cache)
Definition Debugger.cpp:647
void StopEventHandlerThread()
Manually stop the debugger's default event handler.
static void ReportInfo(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report info events.
void SetAsyncExecution(bool async)
HostThread SetIOHandlerThread(HostThread &new_thread)
friend class Progress
Definition Debugger.h:658
SourceManager::SourceFileCache & GetSourceFileCache()
Definition Debugger.h:643
void CancelForwardEvents(const lldb::ListenerSP &listener_sp)
bool GetPrintDecls() const
Definition Debugger.cpp:742
lldb::FileSP GetInputFileSP()
Definition Debugger.h:162
bool GetHighlightSource() const
Definition Debugger.cpp:662
llvm::StringMap< std::weak_ptr< LogHandler > > m_stream_handlers
Definition Debugger.h:793
CommandInterpreter & GetCommandInterpreter()
Definition Debugger.h:189
FormatEntity::Entry GetStatuslineFormat() const
Definition Debugger.cpp:568
LoadedPluginsList m_loaded_plugins
Definition Debugger.h:798
bool GetShowInlineDiagnostics() const
Definition Debugger.cpp:771
std::vector< llvm::sys::DynamicLibrary > LoadedPluginsList
Definition Debugger.h:797
Debugger(const Debugger &)=delete
bool SetTabSize(uint64_t tab_size)
Definition Debugger.cpp:759
bool IsHandlingEvents() const
Definition Debugger.h:422
void HandleDiagnosticEvent(const lldb::EventSP &event_sp)
static lldb::DebuggerSP GetDebuggerAtIndex(size_t index)
llvm::StringRef GetAutosuggestionAnsiSuffix() const
Definition Debugger.cpp:617
lldb::ListenerSP m_listener_sp
Definition Debugger.h:770
void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
std::mutex m_destroy_callback_mutex
Definition Debugger.h:814
lldb::callback_token_t AddDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
Add a callback for when the debugger is destroyed.
lldb::thread_result_t IOHandlerThread()
FormatEntity::Entry GetFrameFormatUnique() const
Definition Debugger.cpp:380
std::optional< ProgressReport > GetCurrentProgressReport() const
llvm::StringRef GetDisabledAnsiPrefix() const
Definition Debugger.cpp:586
bool GetUseExternalEditor() const
Definition Debugger.cpp:502
TerminalState m_terminal_state
Definition Debugger.h:766
lldb::StreamUP GetAsyncErrorStream()
TargetList & GetTargetList()
Get accessor for the target list.
Definition Debugger.h:227
bool GetEscapeNonPrintables() const
Definition Debugger.cpp:725
lldb::TargetSP m_dummy_target_sp
Definition Debugger.h:805
llvm::SmallVector< DestroyCallbackInfo, 2 > m_destroy_callbacks
Definition Debugger.h:826
std::unique_ptr< CommandInterpreter > m_command_interpreter_up
Definition Debugger.h:780
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
static bool FormatDisassemblerAddress(const FormatEntity::Entry *format, const SymbolContext *sc, const SymbolContext *prev_sc, const ExecutionContext *exe_ctx, const Address *addr, Stream &s)
static void SettingsInitialize()
Definition Debugger.cpp:829
LockableStreamFile::Mutex m_output_mutex
Definition Debugger.h:758
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
llvm::StringRef GetShowProgressAnsiSuffix() const
Definition Debugger.cpp:556
bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp)
bool HasIOHandlerThread() const
llvm::SmallVector< ProgressReport, 4 > m_progress_reports
Bookkeeping for command line progress events.
Definition Debugger.h:810
bool IsIOHandlerThreadCurrentThread() const
void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry)
Definition Debugger.cpp:939
lldb::FileSP GetErrorFileSP()
Definition Debugger.h:169
std::mutex m_progress_reports_mutex
Definition Debugger.h:811
lldb::ProcessSP HandleProcessEvent(const lldb::EventSP &event_sp)
lldb::ListenerSP m_forward_listener_sp
Definition Debugger.h:803
std::array< lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown > m_script_interpreters
Definition Debugger.h:784
std::shared_ptr< CallbackLogHandler > m_callback_handler_sp
Definition Debugger.h:794
void SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
DEPRECATED: We used to only support one Destroy callback.
lldb::FileSP GetOutputFileSP()
Definition Debugger.h:165
Broadcaster m_broadcaster
Public Debugger event broadcaster.
Definition Debugger.h:802
static void Initialize(LoadPluginCallbackType load_plugin_callback)
Definition Debugger.cpp:791
static lldb::DebuggerSP FindDebuggerWithInstanceName(llvm::StringRef instance_name)
Definition Debugger.cpp:997
uint64_t GetTerminalWidth() const
Definition Debugger.cpp:458
std::mutex m_interrupt_mutex
Definition Debugger.h:829
std::recursive_mutex m_io_handler_synchronous_mutex
Definition Debugger.h:787
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:477
bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp)
Remove the given IO handler if it's currently active.
Diagnostics::CallbackID m_diagnostics_callback_id
Definition Debugger.h:806
void SetPrompt(const char *)=delete
bool GetAutoOneLineSummaries() const
Definition Debugger.cpp:719
const char * GetIOHandlerCommandPrefix()
friend class REPL
Definition Debugger.h:657
std::optional< Statusline > m_statusline
Definition Debugger.h:791
bool GetUseColor() const
Definition Debugger.cpp:524
lldb::BroadcasterManagerSP m_broadcaster_manager_sp
Definition Debugger.h:760
Status RunREPL(lldb::LanguageType language, const char *repl_options)
bool PopIOHandler(const lldb::IOHandlerSP &reader_sp)
static StructuredData::DictionarySP GetBuildConfiguration()
Get the build configuration as structured data.
bool RemoveDestroyCallback(lldb::callback_token_t token)
Remove the specified callback. Return true if successful.
static LoadPluginCallbackType g_load_plugin_callback
Definition Debugger.h:796
bool GetShowStatusline() const
Definition Debugger.cpp:562
std::recursive_mutex m_script_interpreter_mutex
Definition Debugger.h:782
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
void SetInputFile(lldb::FileSP file)
lldb::LockableStreamFileSP GetOutputStreamSP()
Except for Debugger and IOHandler, GetOutputStreamSP and GetErrorStreamSP should not be used directly...
Definition Debugger.h:709
void SetPrompt(llvm::StringRef p)
Definition Debugger.cpp:415
llvm::StringRef GetSeparator() const
Definition Debugger.cpp:580
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)
uint64_t GetStopDisassemblyMaxSize() const
Definition Debugger.cpp:385
bool SetTerminalHeight(uint64_t term_height)
Definition Debugger.cpp:486
Broadcaster m_sync_broadcaster
Private debugger synchronization.
Definition Debugger.h:801
friend class Statusline
Definition Debugger.h:660
bool GetUseSourceCache() const
Definition Debugger.cpp:641
HostThread m_io_handler_thread
Definition Debugger.h:800
llvm::StringRef GetRegexMatchAnsiSuffix() const
Definition Debugger.cpp:629
static llvm::StringRef GetStaticBroadcasterClass()
lldb::FileSP m_input_file_sp
Definition Debugger.h:755
const Broadcaster & GetBroadcaster() const
Definition Debugger.h:109
bool SetREPLLanguage(lldb::LanguageType repl_lang)
Definition Debugger.cpp:453
bool GetAutoIndent() const
Definition Debugger.cpp:731
llvm::StringRef GetStopShowColumnAnsiSuffix() const
Definition Debugger.cpp:681
Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value) override
Definition Debugger.cpp:278
llvm::StringRef GetPromptAnsiSuffix() const
Definition Debugger.cpp:409
FormatEntity::Entry GetThreadStopFormat() const
Definition Debugger.cpp:431
void SetErrorFile(lldb::FileSP file)
bool GetAutoConfirm() const
Definition Debugger.cpp:364
TargetList m_target_list
Definition Debugger.h:767
lldb::ScriptLanguage GetScriptLanguage() const
Definition Debugger.cpp:436
lldb::callback_token_t m_destroy_callback_next_token
Definition Debugger.h:815
std::unique_ptr< SourceManager > m_source_manager_up
Definition Debugger.h:771
static lldb::DebuggerSP CreateInstance(lldb::LogOutputCallback log_callback=nullptr, void *baton=nullptr)
Definition Debugger.cpp:921
static FileSpecList GetSafeAutoLoadPaths()
Get the list of paths that LLDB will consider automatically loading scripting resources from.
lldb::StopShowColumn GetStopShowColumn() const
Definition Debugger.cpp:668
static void ReportSymbolChange(const ModuleSpec &module_spec)
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
bool SetPrintDecls(bool b)
Definition Debugger.cpp:748
bool SetScriptLanguage(lldb::ScriptLanguage script_lang)
Definition Debugger.cpp:443
lldb::LockableStreamFileSP m_error_stream_sp
Definition Debugger.h:757
bool SetShowInlineDiagnostics(bool)
Definition Debugger.cpp:777
const std::string & GetInstanceName() const
Definition Debugger.h:406
bool LoadPlugin(const FileSpec &spec, Status &error)
Definition Debugger.cpp:833
void SetOutputFile(lldb::FileSP file)
uint64_t GetStopSourceLineCount(bool before) const
Definition Debugger.cpp:699
bool SetStatuslineFormat(const FormatEntity::Entry &format)
Definition Debugger.cpp:573
void EnableForwardEvents(const lldb::ListenerSP &listener_sp)
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id)
void HandleBreakpointEvent(const lldb::EventSP &event_sp)
bool CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
PlatformList & GetPlatformList()
Definition Debugger.h:229
Target & GetDummyTarget()
Definition Debugger.h:536
lldb::ListenerSP GetListener()
Definition Debugger.h:198
static void Destroy(lldb::DebuggerSP &debugger_sp)
Definition Debugger.cpp:965
SourceManager::SourceFileCache m_source_file_cache
Definition Debugger.h:775
ExecutionContextRef GetSelectedExecutionContextRef()
Similar to GetSelectedExecutionContext but returns a ExecutionContextRef, and will hold the dummy tar...
llvm::StringRef GetPromptAnsiPrefix() const
Definition Debugger.cpp:403
lldb::StreamUP GetAsyncOutputStream()
void RedrawStatusline(std::optional< ExecutionContextRef > exe_ctx_ref)
Redraw the statusline if enabled.
void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp)
Run the given IO handler and block until it's complete.
Broadcaster & GetBroadcaster()
Get the public broadcaster for this debugger.
Definition Debugger.h:108
llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const
Definition Debugger.cpp:687
bool GetShowDontUsePoHint() const
Definition Debugger.cpp:635
uint64_t GetTabSize() const
Definition Debugger.cpp:753
bool GetShowProgress() const
Definition Debugger.cpp:539
llvm::StringRef GetRegexMatchAnsiPrefix() const
Definition Debugger.cpp:623
std::mutex m_output_flush_mutex
Definition Debugger.h:750
llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const
Definition Debugger.cpp:693
void PrintProgress(const ProgressEventData &data)
bool SetSeparator(llvm::StringRef s)
Definition Debugger.cpp:598
bool SetUseColor(bool use_color)
Definition Debugger.cpp:530
std::mutex m_statusline_mutex
Mutex protecting the m_statusline member.
Definition Debugger.h:790
const char * GetIOHandlerHelpPrologue()
Status SetInputString(const char *data)
bool GetUseAutosuggestion() const
Definition Debugger.cpp:605
friend class ProgressManager
Definition Debugger.h:659
Target & GetSelectedOrDummyTarget(bool prefer_dummy=false)
IOHandlerStack m_io_handler_stack
Definition Debugger.h:786
llvm::once_flag m_clear_once
Definition Debugger.h:804
static void SettingsTerminate()
Definition Debugger.cpp:831
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.
lldb::LanguageType GetREPLLanguage() const
Definition Debugger.cpp:448
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton)
bool SetTerminalWidth(uint64_t term_width)
Definition Debugger.cpp:464
Debugger(lldb::LogOutputCallback m_log_callback, void *baton)
llvm::StringRef GetExternalEditor() const
Definition Debugger.cpp:513
static size_t GetNumDebuggers()
FormatEntity::Entry GetThreadFormat() const
Definition Debugger.cpp:426
uint32_t m_interrupt_requested
Tracks interrupt requests.
Definition Debugger.h:828
lldb::DWIMPrintVerbosity GetDWIMPrintVerbosity() const
Definition Debugger.cpp:764
bool GetMarkHiddenFrames() const
Definition Debugger.cpp:656
lldb::BroadcasterManagerSP GetBroadcasterManager()
Definition Debugger.h:538
lldb::thread_result_t DefaultEventHandler()
void PrintAsync(const char *s, size_t len, bool is_stdout)
lldb::LockableStreamFileSP GetErrorStreamSP()
Definition Debugger.h:710
llvm::StringRef GetPrompt() const
Definition Debugger.cpp:397
bool GetNotifyVoid() const
Definition Debugger.cpp:391
llvm::StringRef GetShowProgressAnsiPrefix() const
Definition Debugger.cpp:550
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::LockableStreamFileSP &out, lldb::LockableStreamFileSP &err)
FormatEntity::Entry GetFrameFormat() const
Definition Debugger.cpp:375
lldb::StopDisassemblyType GetStopDisassemblyDisplay() const
Definition Debugger.cpp:706
llvm::StringRef GetTopIOHandlerControlSequence(char ch)
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...
void CancelInterruptRequest()
Decrement the "interrupt requested" counter.
static void ReportDiagnosticImpl(lldb::Severity severity, std::string message, std::optional< lldb::user_id_t > debugger_id, std::once_flag *once)
std::vector< lldb::DebuggerSP > DebuggerList
Definition Debugger.h:103
bool SetAutoIndent(bool b)
Definition Debugger.cpp:737
const Debugger & operator=(const Debugger &)=delete
friend class CommandInterpreter
Definition Debugger.h:656
llvm::StringRef GetStopShowColumnAnsiPrefix() const
Definition Debugger.cpp:675
static DebuggerList DebuggersRequestingInterruption()
Execution context objects refer to objects in the execution of the program that is being debugged.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file collection class.
A file utility class.
Definition FileSpec.h:57
An abstract base class for files.
Definition File.h:36
std::recursive_mutex Mutex
Definition StreamFile.h:77
A plug-in interface definition class for debugging a process.
Definition Process.h:354
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
std::shared_ptr< Dictionary > DictionarySP
Defines a symbol context baton that can be handed other debug core functions.
A RAII-friendly terminal state saving/restoring class.
Definition Terminal.h:99
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
@ eBroadcastBitProgress
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
std::shared_ptr< lldb_private::Thread > ThreadSP
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::Process > ProcessSP
std::shared_ptr< lldb_private::Debugger > DebuggerSP
StopDisassemblyType
Used to determine when to show disassembly.
std::shared_ptr< lldb_private::Event > EventSP
std::shared_ptr< lldb_private::Listener > ListenerSP
int32_t callback_token_t
Definition lldb-types.h:81
uint64_t user_id_t
Definition lldb-types.h:82
std::shared_ptr< lldb_private::LockableStreamFile > LockableStreamFileSP
void(* LogOutputCallback)(const char *, void *baton)
Definition lldb-types.h:73
std::shared_ptr< lldb_private::Target > TargetSP
std::unique_ptr< lldb_private::Stream > StreamUP
std::shared_ptr< lldb_private::File > FileSP
DestroyCallbackInfo(lldb::callback_token_t token, lldb_private::DebuggerDestroyCallback callback, void *baton)
Definition Debugger.h:818
lldb_private::DebuggerDestroyCallback callback
Definition Debugger.h:823
void AppendSafeAutoLoadPaths(FileSpec path)
Appends a path to the testing.safe-auto-load-paths setting.
Definition Debugger.cpp:262
static TestingProperties & GetGlobalTestingProperties()
Definition Debugger.cpp:249
FileSpecList GetSafeAutoLoadPaths() const
Callers should use Debugger::GetSafeAutoLoadPaths since it accounts for default paths configured via ...
Definition Debugger.cpp:270
void SetSafeAutoLoadPaths(FileSpecList paths)
Overwrites the testing.safe-auto-load-paths settings.
Definition Debugger.cpp:254
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition UserID.h:33