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;
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
131
132 bool GetAsyncExecution();
133
134 void SetAsyncExecution(bool async);
135
138
140 return m_output_stream_sp->GetUnlockedFileSP();
141 }
142
144 return m_error_stream_sp->GetUnlockedFileSP();
145 }
146
147 Status SetInputString(const char *data);
148
149 void SetInputFile(lldb::FileSP file);
150
151 void SetOutputFile(lldb::FileSP file);
152
153 void SetErrorFile(lldb::FileSP file);
154
156
158
160
162
167
169 GetScriptInterpreter(bool can_create = true,
170 std::optional<lldb::ScriptLanguage> language = {});
171
173
174 // This returns the Debugger's scratch source manager. It won't be able to
175 // look up files in debug information, but it can look up files by absolute
176 // path and display them to you. To get the target's source manager, call
177 // GetSourceManager on the target instead.
179
181 return m_target_list.GetSelectedTarget();
182 }
183
185 /// Get accessor for the target list.
186 ///
187 /// The target list is part of the global debugger object. This the single
188 /// debugger shared instance to control where targets get created and to
189 /// allow for tracking and searching for targets based on certain criteria.
190 ///
191 /// \return
192 /// A global shared target list.
194
196
198
200
201 // If any of the streams are not set, set them to the in/out/err stream of
202 // the top most input reader to ensure they at least have something
206
207 /// Run the given IO handler and return immediately.
208 void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp,
209 bool cancel_top_handler = true);
210
211 /// Run the given IO handler and block until it's complete.
212 void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp);
213
214 /// Remove the given IO handler if it's currently active.
215 bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp);
216
217 bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp);
218
220 IOHandler::Type second_top_type);
221
222 void PrintAsync(const char *s, size_t len, bool is_stdout);
223
224 llvm::StringRef GetTopIOHandlerControlSequence(char ch);
225
226 const char *GetIOHandlerCommandPrefix();
227
228 const char *GetIOHandlerHelpPrologue();
229
230 void RefreshIOHandler();
231
232 void ClearIOHandlers();
233
234 bool EnableLog(llvm::StringRef channel,
235 llvm::ArrayRef<const char *> categories,
236 llvm::StringRef log_file, uint32_t log_options,
237 size_t buffer_size, LogHandlerKind log_handler_kind,
238 llvm::raw_ostream &error_stream);
239
240 void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
241
243 VarSetOperationType op, llvm::StringRef property_path,
244 llvm::StringRef value) override;
245
246 bool GetAutoConfirm() const;
247
249
251
253
254 uint64_t GetStopDisassemblyMaxSize() const;
255
257
259
261
262 bool SetScriptLanguage(lldb::ScriptLanguage script_lang);
263
265
266 bool SetREPLLanguage(lldb::LanguageType repl_lang);
267
268 uint64_t GetTerminalWidth() const;
269
270 bool SetTerminalWidth(uint64_t term_width);
271
272 uint64_t GetTerminalHeight() const;
273
274 bool SetTerminalHeight(uint64_t term_height);
275
276 llvm::StringRef GetPrompt() const;
277
278 llvm::StringRef GetPromptAnsiPrefix() const;
279
280 llvm::StringRef GetPromptAnsiSuffix() const;
281
282 void SetPrompt(llvm::StringRef p);
283 void SetPrompt(const char *) = delete;
284
285 bool GetUseExternalEditor() const;
286 bool SetUseExternalEditor(bool use_external_editor_p);
287
288 llvm::StringRef GetExternalEditor() const;
289
290 bool SetExternalEditor(llvm::StringRef editor);
291
292 bool GetUseColor() const;
293
294 bool SetUseColor(bool use_color);
295
296 bool GetShowProgress() const;
297
298 bool SetShowProgress(bool show_progress);
299
300 bool GetShowStatusline() const;
301
303 bool SetStatuslineFormat(const FormatEntity::Entry &format);
304
305 llvm::StringRef GetSeparator() const;
306 bool SetSeparator(llvm::StringRef s);
307
308 llvm::StringRef GetShowProgressAnsiPrefix() const;
309
310 llvm::StringRef GetShowProgressAnsiSuffix() const;
311
312 llvm::StringRef GetDisabledAnsiPrefix() const;
313
314 llvm::StringRef GetDisabledAnsiSuffix() const;
315
316 bool GetUseAutosuggestion() const;
317
318 llvm::StringRef GetAutosuggestionAnsiPrefix() const;
319
320 llvm::StringRef GetAutosuggestionAnsiSuffix() const;
321
322 llvm::StringRef GetRegexMatchAnsiPrefix() const;
323
324 llvm::StringRef GetRegexMatchAnsiSuffix() const;
325
326 bool GetShowDontUsePoHint() const;
327
328 bool GetUseSourceCache() const;
329
330 bool SetUseSourceCache(bool use_source_cache);
331
332 bool GetHighlightSource() const;
333
335
336 llvm::StringRef GetStopShowColumnAnsiPrefix() const;
337
338 llvm::StringRef GetStopShowColumnAnsiSuffix() const;
339
340 uint64_t GetStopSourceLineCount(bool before) const;
341
343
344 uint64_t GetDisassemblyLineCount() const;
345
346 llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const;
347
348 llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const;
349
350 bool GetAutoOneLineSummaries() const;
351
352 bool GetAutoIndent() const;
353
354 bool SetAutoIndent(bool b);
355
356 bool GetPrintDecls() const;
357
358 bool SetPrintDecls(bool b);
359
360 uint64_t GetTabSize() const;
361
362 bool SetTabSize(uint64_t tab_size);
363
365
366 bool GetEscapeNonPrintables() const;
367
368 bool GetNotifyVoid() const;
369
370 const std::string &GetInstanceName() const { return m_instance_name; }
371
372 bool GetShowInlineDiagnostics() const;
373
374 bool SetShowInlineDiagnostics(bool);
375
376 bool LoadPlugin(const FileSpec &spec, Status &error);
377
378 void RunIOHandlers();
379
380 bool IsForwardingEvents();
381
382 void EnableForwardEvents(const lldb::ListenerSP &listener_sp);
383
384 void CancelForwardEvents(const lldb::ListenerSP &listener_sp);
385
386 bool IsHandlingEvents() const { return m_event_handler_thread.IsJoinable(); }
387
388 Status RunREPL(lldb::LanguageType language, const char *repl_options);
389
390 /// Interruption in LLDB:
391 ///
392 /// This is a voluntary interruption mechanism, not preemptive. Parts of lldb
393 /// that do work that can be safely interrupted call
394 /// Debugger::InterruptRequested and if that returns true, they should return
395 /// at a safe point, shortcutting the rest of the work they were to do.
396 ///
397 /// lldb clients can both offer a CommandInterpreter (through
398 /// RunCommandInterpreter) and use the SB API's for their own purposes, so it
399 /// is convenient to separate "interrupting the CommandInterpreter execution"
400 /// and interrupting the work it is doing with the SB API's. So there are two
401 /// ways to cause an interrupt:
402 /// * CommandInterpreter::InterruptCommand: Interrupts the command currently
403 /// running in the command interpreter IOHandler thread
404 /// * Debugger::RequestInterrupt: Interrupts are active on anything but the
405 /// CommandInterpreter thread till CancelInterruptRequest is called.
406 ///
407 /// Since the two checks are mutually exclusive, however, it's also convenient
408 /// to have just one function to check the interrupt state.
409
410 /// Bump the "interrupt requested" count on the debugger to support
411 /// cooperative interruption. If this is non-zero, InterruptRequested will
412 /// return true. Interruptible operations are expected to query the
413 /// InterruptRequested API periodically, and interrupt what they were doing
414 /// if it returns \b true.
415 ///
416 void RequestInterrupt();
417
418 /// Decrement the "interrupt requested" counter.
420
421 /// Redraw the statusline if enabled.
422 void RedrawStatusline(bool update = true);
423
424 /// This is the correct way to query the state of Interruption.
425 /// If you are on the RunCommandInterpreter thread, it will check the
426 /// command interpreter state, and if it is on another thread it will
427 /// check the debugger Interrupt Request state.
428 /// \param[in] cur_func
429 /// For reporting if the interruption was requested. Don't provide this by
430 /// hand, use INTERRUPT_REQUESTED so this gets done consistently.
431 ///
432 /// \param[in] formatv
433 /// A formatv string for the interrupt message. If the elements of the
434 /// message are expensive to compute, you can use the no-argument form of
435 /// InterruptRequested, then make up the report using REPORT_INTERRUPTION.
436 ///
437 /// \return
438 /// A boolean value, if \b true an interruptible operation should interrupt
439 /// itself.
440 template <typename... Args>
441 bool InterruptRequested(const char *cur_func, const char *formatv,
442 Args &&...args) {
443 bool ret_val = InterruptRequested();
444 if (ret_val) {
445 if (!formatv)
446 formatv = "Unknown message";
447 if (!cur_func)
448 cur_func = "<UNKNOWN>";
450 cur_func, llvm::formatv(formatv, std::forward<Args>(args)...)));
451 }
452 return ret_val;
453 }
454
455 /// This handy define will keep you from having to generate a report for the
456 /// interruption by hand. Use this except in the case where the arguments to
457 /// the message description are expensive to compute.
458#define INTERRUPT_REQUESTED(debugger, ...) \
459 (debugger).InterruptRequested(__func__, __VA_ARGS__)
460
461 // This form just queries for whether to interrupt, and does no reporting:
462 bool InterruptRequested();
463
464 // FIXME: Do we want to capture a backtrace at the interruption point?
466 public:
467 InterruptionReport(std::string function_name, std::string description)
468 : m_function_name(std::move(function_name)),
469 m_description(std::move(description)),
470 m_interrupt_time(std::chrono::system_clock::now()),
471 m_thread_id(llvm::get_threadid()) {}
472
473 InterruptionReport(std::string function_name,
474 const llvm::formatv_object_base &payload);
475
476 template <typename... Args>
477 InterruptionReport(std::string function_name, const char *format,
478 Args &&...args)
480 function_name,
481 llvm::formatv(format, std::forward<Args>(args)...)) {}
482
483 std::string m_function_name;
484 std::string m_description;
485 const std::chrono::time_point<std::chrono::system_clock> m_interrupt_time;
486 const uint64_t m_thread_id;
487 };
488 void ReportInterruption(const InterruptionReport &report);
489#define REPORT_INTERRUPTION(debugger, ...) \
490 (debugger).ReportInterruption( \
491 Debugger::InterruptionReport(__func__, __VA_ARGS__))
492
494
495public:
496 // This is for use in the command interpreter, when you either want the
497 // selected target, or if no target is present you want to prime the dummy
498 // target with entities that will be copied over to new targets.
499 Target &GetSelectedOrDummyTarget(bool prefer_dummy = false);
501
505
506 /// Shared thread pool. Use only with ThreadPoolTaskGroup.
507 static llvm::ThreadPoolInterface &GetThreadPool();
508
509 /// Report warning events.
510 ///
511 /// Warning events will be delivered to any debuggers that have listeners
512 /// for the eBroadcastBitWarning.
513 ///
514 /// \param[in] message
515 /// The warning message to be reported.
516 ///
517 /// \param [in] debugger_id
518 /// If this optional parameter has a value, it indicates the unique
519 /// debugger identifier that this diagnostic should be delivered to. If
520 /// this optional parameter does not have a value, the diagnostic event
521 /// will be delivered to all debuggers.
522 ///
523 /// \param [in] once
524 /// If a pointer is passed to a std::once_flag, then it will be used to
525 /// ensure the given warning is only broadcast once.
526 static void
527 ReportWarning(std::string message,
528 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
529 std::once_flag *once = nullptr);
530
531 /// Report error events.
532 ///
533 /// Error events will be delivered to any debuggers that have listeners
534 /// for the eBroadcastBitError.
535 ///
536 /// \param[in] message
537 /// The error message to be reported.
538 ///
539 /// \param [in] debugger_id
540 /// If this optional parameter has a value, it indicates the unique
541 /// debugger identifier that this diagnostic should be delivered to. If
542 /// this optional parameter does not have a value, the diagnostic event
543 /// will be delivered to all debuggers.
544 ///
545 /// \param [in] once
546 /// If a pointer is passed to a std::once_flag, then it will be used to
547 /// ensure the given error is only broadcast once.
548 static void
549 ReportError(std::string message,
550 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
551 std::once_flag *once = nullptr);
552
553 /// Report info events.
554 ///
555 /// Unlike warning and error events, info events are not broadcast but are
556 /// logged for diagnostic purposes.
557 ///
558 /// \param[in] message
559 /// The info message to be reported.
560 ///
561 /// \param [in] debugger_id
562 /// If this optional parameter has a value, it indicates this diagnostic is
563 /// associated with a unique debugger instance.
564 ///
565 /// \param [in] once
566 /// If a pointer is passed to a std::once_flag, then it will be used to
567 /// ensure the given info is only logged once.
568 static void
569 ReportInfo(std::string message,
570 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
571 std::once_flag *once = nullptr);
572
573 static void ReportSymbolChange(const ModuleSpec &module_spec);
574
575 /// DEPRECATED: We used to only support one Destroy callback. Now that we
576 /// support Add and Remove, you should only remove callbacks that you added.
577 /// Use Add and Remove instead.
578 ///
579 /// Clear all previously added callbacks and only add the given one.
580 void
582 void *baton);
583
584 /// Add a callback for when the debugger is destroyed. Return a token, which
585 /// can be used to remove said callback. Multiple callbacks can be added by
586 /// calling this function multiple times, and will be invoked in FIFO order.
589 void *baton);
590
591 /// Remove the specified callback. Return true if successful.
593
594 /// Manually start the global event handler thread. It is useful to plugins
595 /// that directly use the \a lldb_private namespace and want to use the
596 /// debugger's default event handler thread instead of defining their own.
598
599 /// Manually stop the debugger's default event handler.
601
602 /// Force flushing the process's pending stdout and stderr to the debugger's
603 /// asynchronous stdout and stderr streams.
604 void FlushProcessOutput(Process &process, bool flush_stdout,
605 bool flush_stderr);
606
610
612 uint64_t id;
613 uint64_t completed;
614 uint64_t total;
615 std::string message;
616 };
617 std::optional<ProgressReport> GetCurrentProgressReport() const;
618
619protected:
620 friend class CommandInterpreter;
621 friend class REPL;
622 friend class Progress;
623 friend class ProgressManager;
624 friend class Statusline;
625
626 /// Report progress events.
627 ///
628 /// Progress events will be delivered to any debuggers that have listeners
629 /// for the eBroadcastBitProgress. This function is called by the
630 /// lldb_private::Progress class to deliver the events to any debuggers that
631 /// qualify.
632 ///
633 /// \param [in] progress_id
634 /// The unique integer identifier for the progress to report.
635 ///
636 /// \param[in] message
637 /// The title of the progress dialog to display in the UI.
638 ///
639 /// \param [in] completed
640 /// The amount of work completed. If \a completed is zero, then this event
641 /// is a progress started event. If \a completed is equal to \a total, then
642 /// this event is a progress end event. Otherwise completed indicates the
643 /// current progress compare to the total value.
644 ///
645 /// \param [in] total
646 /// The total amount of work units that need to be completed. If this value
647 /// is UINT64_MAX, then an indeterminate progress indicator should be
648 /// displayed.
649 ///
650 /// \param [in] debugger_id
651 /// If this optional parameter has a value, it indicates the unique
652 /// debugger identifier that this progress should be delivered to. If this
653 /// optional parameter does not have a value, the progress will be
654 /// delivered to all debuggers.
655 static void
656 ReportProgress(uint64_t progress_id, std::string title, std::string details,
657 uint64_t completed, uint64_t total,
658 std::optional<lldb::user_id_t> debugger_id,
659 uint32_t progress_category_bit = lldb::eBroadcastBitProgress);
660
661 static void ReportDiagnosticImpl(lldb::Severity severity, std::string message,
662 std::optional<lldb::user_id_t> debugger_id,
663 std::once_flag *once);
664
666
668
669 /// Except for Debugger and IOHandler, GetOutputStreamSP and GetErrorStreamSP
670 /// should not be used directly. Use GetAsyncOutputStream and
671 /// GetAsyncErrorStream instead.
672 /// @{
675 /// @}
676
677 bool StatuslineSupported();
678
679 void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
680 bool cancel_top_handler = true);
681
682 bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
683
684 bool HasIOHandlerThread() const;
685
687
688 void StopIOHandlerThread();
689
690 // Sets the IOHandler thread to the new_thread, and returns
691 // the previous IOHandler thread.
693
694 void JoinIOHandlerThread();
695
697
699
701
702 void HandleBreakpointEvent(const lldb::EventSP &event_sp);
703
704 void HandleProcessEvent(const lldb::EventSP &event_sp);
705
706 void HandleThreadEvent(const lldb::EventSP &event_sp);
707
708 void HandleProgressEvent(const lldb::EventSP &event_sp);
709
710 void HandleDiagnosticEvent(const lldb::EventSP &event_sp);
711
712 // Ensures two threads don't attempt to flush process output in parallel.
714
715 void InstanceInitialize();
716
717 // these should never be NULL
722
724 // broadcaster manager of
725 // last resort.
726 // It needs to get constructed before the target_list or any other member
727 // that might want to broadcast through the debugger.
728
731
734 std::unique_ptr<SourceManager> m_source_manager_up; // This is a scratch
735 // source manager that we
736 // return if we have no
737 // targets.
739 // for targets created in
740 // this debugger used this
741 // shared
742 // source file cache.
743 std::unique_ptr<CommandInterpreter> m_command_interpreter_up;
744
745 std::recursive_mutex m_script_interpreter_mutex;
746 std::array<lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown>
748
750 std::recursive_mutex m_io_handler_synchronous_mutex;
751
752 /// Mutex protecting the m_statusline member.
754 std::optional<Statusline> m_statusline;
755
756 llvm::StringMap<std::weak_ptr<LogHandler>> m_stream_handlers;
757 std::shared_ptr<CallbackLogHandler> m_callback_handler_sp;
758 const std::string m_instance_name;
760 typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
764 Broadcaster m_sync_broadcaster; ///< Private debugger synchronization.
765 Broadcaster m_broadcaster; ///< Public Debugger event broadcaster.
767 llvm::once_flag m_clear_once;
770
771 /// Bookkeeping for command line progress events.
772 /// @{
773 llvm::SmallVector<ProgressReport, 4> m_progress_reports;
774 mutable std::mutex m_progress_reports_mutex;
775 /// @}
776
789 llvm::SmallVector<DestroyCallbackInfo, 2> m_destroy_callbacks;
790
791 uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
793
794 // Events for m_sync_broadcaster
795 enum {
797 };
798
799private:
800 // Use Debugger::CreateInstance() to get a shared pointer to a new debugger
801 // object
802 Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
803
804 Debugger(const Debugger &) = delete;
805 const Debugger &operator=(const Debugger &) = delete;
806};
807
808} // namespace lldb_private
809
810#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:485
InterruptionReport(std::string function_name, std::string description)
Definition Debugger.h:467
InterruptionReport(std::string function_name, const char *format, Args &&...args)
Definition Debugger.h:477
static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace, llvm::StringRef prompt)
llvm::StringRef GetAutosuggestionAnsiPrefix() const
Definition Debugger.cpp:539
bool SetUseExternalEditor(bool use_external_editor_p)
Definition Debugger.cpp:436
PlatformList m_platform_list
Definition Debugger.h:732
HostThread m_event_handler_thread
Definition Debugger.h:762
static lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid)
Definition Debugger.cpp:930
FormatEntity::Entry GetDisassemblyFormat() const
Definition Debugger.cpp:298
uint64_t GetDisassemblyLineCount() const
Definition Debugger.cpp:634
lldb::TargetSP GetSelectedTarget()
Definition Debugger.h:180
llvm::StringRef GetDisabledAnsiSuffix() const
Definition Debugger.cpp:520
uint64_t GetTerminalHeight() const
Definition Debugger.cpp:408
lldb::LockableStreamFileSP m_output_stream_sp
Definition Debugger.h:719
bool SetExternalEditor(llvm::StringRef editor)
Definition Debugger.cpp:447
void RequestInterrupt()
Interruption in LLDB:
void ReportInterruption(const InterruptionReport &report)
ExecutionContext GetSelectedExecutionContext()
const std::string m_instance_name
Definition Debugger.h:758
static void Terminate()
Definition Debugger.cpp:721
void HandleProgressEvent(const lldb::EventSP &event_sp)
SourceManager & GetSourceManager()
bool SetShowProgress(bool show_progress)
Definition Debugger.cpp:473
bool StartEventHandlerThread()
Manually start the global event handler thread.
bool SetUseSourceCache(bool use_source_cache)
Definition Debugger.cpp:575
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:622
SourceManager::SourceFileCache & GetSourceFileCache()
Definition Debugger.h:607
void CancelForwardEvents(const lldb::ListenerSP &listener_sp)
bool GetPrintDecls() const
Definition Debugger.cpp:663
lldb::FileSP GetInputFileSP()
Definition Debugger.h:136
bool GetHighlightSource() const
Definition Debugger.cpp:583
llvm::StringMap< std::weak_ptr< LogHandler > > m_stream_handlers
Definition Debugger.h:756
CommandInterpreter & GetCommandInterpreter()
Definition Debugger.h:163
FormatEntity::Entry GetStatuslineFormat() const
Definition Debugger.cpp:496
LoadedPluginsList m_loaded_plugins
Definition Debugger.h:761
bool GetShowInlineDiagnostics() const
Definition Debugger.cpp:692
std::vector< llvm::sys::DynamicLibrary > LoadedPluginsList
Definition Debugger.h:760
Debugger(const Debugger &)=delete
bool SetTabSize(uint64_t tab_size)
Definition Debugger.cpp:680
bool IsHandlingEvents() const
Definition Debugger.h:386
void HandleDiagnosticEvent(const lldb::EventSP &event_sp)
static lldb::DebuggerSP GetDebuggerAtIndex(size_t index)
llvm::StringRef GetAutosuggestionAnsiSuffix() const
Definition Debugger.cpp:545
lldb::ListenerSP m_listener_sp
Definition Debugger.h:733
void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
std::mutex m_destroy_callback_mutex
Definition Debugger.h:777
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:308
std::optional< ProgressReport > GetCurrentProgressReport() const
static lldb::TargetSP FindTargetWithProcess(Process *process)
Definition Debugger.cpp:944
llvm::StringRef GetDisabledAnsiPrefix() const
Definition Debugger.cpp:514
bool GetUseExternalEditor() const
Definition Debugger.cpp:430
TerminalState m_terminal_state
Definition Debugger.h:729
lldb::StreamUP GetAsyncErrorStream()
TargetList & GetTargetList()
Get accessor for the target list.
Definition Debugger.h:193
bool GetEscapeNonPrintables() const
Definition Debugger.cpp:646
lldb::TargetSP m_dummy_target_sp
Definition Debugger.h:768
llvm::SmallVector< DestroyCallbackInfo, 2 > m_destroy_callbacks
Definition Debugger.h:789
std::unique_ptr< CommandInterpreter > m_command_interpreter_up
Definition Debugger.h:743
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:747
LockableStreamFile::Mutex m_output_mutex
Definition Debugger.h:721
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
llvm::StringRef GetShowProgressAnsiSuffix() const
Definition Debugger.cpp:484
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:773
bool IsIOHandlerThreadCurrentThread() const
void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry)
Definition Debugger.cpp:857
lldb::FileSP GetErrorFileSP()
Definition Debugger.h:143
std::mutex m_progress_reports_mutex
Definition Debugger.h:774
lldb::ListenerSP m_forward_listener_sp
Definition Debugger.h:766
std::array< lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown > m_script_interpreters
Definition Debugger.h:747
std::shared_ptr< CallbackLogHandler > m_callback_handler_sp
Definition Debugger.h:757
void SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
DEPRECATED: We used to only support one Destroy callback.
lldb::FileSP GetOutputFileSP()
Definition Debugger.h:139
Broadcaster m_broadcaster
Public Debugger event broadcaster.
Definition Debugger.h:765
static void Initialize(LoadPluginCallbackType load_plugin_callback)
Definition Debugger.cpp:712
static lldb::DebuggerSP FindDebuggerWithInstanceName(llvm::StringRef instance_name)
Definition Debugger.cpp:915
uint64_t GetTerminalWidth() const
Definition Debugger.cpp:386
std::mutex m_interrupt_mutex
Definition Debugger.h:792
std::recursive_mutex m_io_handler_synchronous_mutex
Definition Debugger.h:750
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:441
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:769
void SetPrompt(const char *)=delete
bool GetAutoOneLineSummaries() const
Definition Debugger.cpp:640
const char * GetIOHandlerCommandPrefix()
friend class REPL
Definition Debugger.h:621
std::optional< Statusline > m_statusline
Definition Debugger.h:754
bool GetUseColor() const
Definition Debugger.cpp:452
lldb::BroadcasterManagerSP m_broadcaster_manager_sp
Definition Debugger.h:723
Status RunREPL(lldb::LanguageType language, const char *repl_options)
bool PopIOHandler(const lldb::IOHandlerSP &reader_sp)
bool RemoveDestroyCallback(lldb::callback_token_t token)
Remove the specified callback. Return true if successful.
static LoadPluginCallbackType g_load_plugin_callback
Definition Debugger.h:759
bool GetShowStatusline() const
Definition Debugger.cpp:490
std::recursive_mutex m_script_interpreter_mutex
Definition Debugger.h:745
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:673
void SetPrompt(llvm::StringRef p)
Definition Debugger.cpp:343
llvm::StringRef GetSeparator() const
Definition Debugger.cpp:508
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:313
bool SetTerminalHeight(uint64_t term_height)
Definition Debugger.cpp:414
Broadcaster m_sync_broadcaster
Private debugger synchronization.
Definition Debugger.h:764
friend class Statusline
Definition Debugger.h:624
bool GetUseSourceCache() const
Definition Debugger.cpp:569
HostThread m_io_handler_thread
Definition Debugger.h:763
llvm::StringRef GetRegexMatchAnsiSuffix() const
Definition Debugger.cpp:557
static llvm::StringRef GetStaticBroadcasterClass()
Definition Debugger.cpp:958
lldb::FileSP m_input_file_sp
Definition Debugger.h:718
const Broadcaster & GetBroadcaster() const
Definition Debugger.h:88
bool SetREPLLanguage(lldb::LanguageType repl_lang)
Definition Debugger.cpp:381
bool GetAutoIndent() const
Definition Debugger.cpp:652
llvm::StringRef GetStopShowColumnAnsiSuffix() const
Definition Debugger.cpp:602
Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value) override
Definition Debugger.cpp:205
llvm::StringRef GetPromptAnsiSuffix() const
Definition Debugger.cpp:337
FormatEntity::Entry GetThreadStopFormat() const
Definition Debugger.cpp:359
void SetErrorFile(lldb::FileSP file)
bool GetAutoConfirm() const
Definition Debugger.cpp:292
TargetList m_target_list
Definition Debugger.h:730
lldb::ScriptLanguage GetScriptLanguage() const
Definition Debugger.cpp:364
lldb::callback_token_t m_destroy_callback_next_token
Definition Debugger.h:778
std::unique_ptr< SourceManager > m_source_manager_up
Definition Debugger.h:734
void RedrawStatusline(bool update=true)
Redraw the statusline if enabled.
static lldb::DebuggerSP CreateInstance(lldb::LogOutputCallback log_callback=nullptr, void *baton=nullptr)
Definition Debugger.cpp:839
lldb::StopShowColumn GetStopShowColumn() const
Definition Debugger.cpp:589
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:669
bool SetScriptLanguage(lldb::ScriptLanguage script_lang)
Definition Debugger.cpp:371
lldb::LockableStreamFileSP m_error_stream_sp
Definition Debugger.h:720
bool SetShowInlineDiagnostics(bool)
Definition Debugger.cpp:698
const std::string & GetInstanceName() const
Definition Debugger.h:370
bool LoadPlugin(const FileSpec &spec, Status &error)
Definition Debugger.cpp:751
void SetOutputFile(lldb::FileSP file)
uint64_t GetStopSourceLineCount(bool before) const
Definition Debugger.cpp:620
bool SetStatuslineFormat(const FormatEntity::Entry &format)
Definition Debugger.cpp:501
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:195
Target & GetDummyTarget()
Definition Debugger.h:500
lldb::ListenerSP GetListener()
Definition Debugger.h:172
static void Destroy(lldb::DebuggerSP &debugger_sp)
Definition Debugger.cpp:883
SourceManager::SourceFileCache m_source_file_cache
Definition Debugger.h:738
llvm::StringRef GetPromptAnsiPrefix() const
Definition Debugger.cpp:331
lldb::StreamUP GetAsyncOutputStream()
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:87
llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const
Definition Debugger.cpp:608
bool GetShowDontUsePoHint() const
Definition Debugger.cpp:563
uint64_t GetTabSize() const
Definition Debugger.cpp:674
bool GetShowProgress() const
Definition Debugger.cpp:467
llvm::StringRef GetRegexMatchAnsiPrefix() const
Definition Debugger.cpp:551
std::mutex m_output_flush_mutex
Definition Debugger.h:713
llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const
Definition Debugger.cpp:614
void PrintProgress(const ProgressEventData &data)
bool SetSeparator(llvm::StringRef s)
Definition Debugger.cpp:526
bool SetUseColor(bool use_color)
Definition Debugger.cpp:458
std::mutex m_statusline_mutex
Mutex protecting the m_statusline member.
Definition Debugger.h:753
const char * GetIOHandlerHelpPrologue()
Status SetInputString(const char *data)
bool GetUseAutosuggestion() const
Definition Debugger.cpp:533
friend class ProgressManager
Definition Debugger.h:623
Target & GetSelectedOrDummyTarget(bool prefer_dummy=false)
void HandleProcessEvent(const lldb::EventSP &event_sp)
IOHandlerStack m_io_handler_stack
Definition Debugger.h:749
llvm::once_flag m_clear_once
Definition Debugger.h:767
static void SettingsTerminate()
Definition Debugger.cpp:749
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:376
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:392
Debugger(lldb::LogOutputCallback m_log_callback, void *baton)
Definition Debugger.cpp:963
llvm::StringRef GetExternalEditor() const
Definition Debugger.cpp:441
void HandleThreadEvent(const lldb::EventSP &event_sp)
static size_t GetNumDebuggers()
FormatEntity::Entry GetThreadFormat() const
Definition Debugger.cpp:354
uint32_t m_interrupt_requested
Tracks interrupt requests.
Definition Debugger.h:791
lldb::DWIMPrintVerbosity GetDWIMPrintVerbosity() const
Definition Debugger.cpp:685
lldb::BroadcasterManagerSP GetBroadcasterManager()
Definition Debugger.h:502
lldb::thread_result_t DefaultEventHandler()
void PrintAsync(const char *s, size_t len, bool is_stdout)
lldb::LockableStreamFileSP GetErrorStreamSP()
Definition Debugger.h:674
llvm::StringRef GetPrompt() const
Definition Debugger.cpp:325
bool GetNotifyVoid() const
Definition Debugger.cpp:319
llvm::StringRef GetShowProgressAnsiPrefix() const
Definition Debugger.cpp:478
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::LockableStreamFileSP &out, lldb::LockableStreamFileSP &err)
FormatEntity::Entry GetFrameFormat() const
Definition Debugger.cpp:303
lldb::StopDisassemblyType GetStopDisassemblyDisplay() const
Definition Debugger.cpp:627
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:82
bool SetAutoIndent(bool b)
Definition Debugger.cpp:658
const Debugger & operator=(const Debugger &)=delete
friend class CommandInterpreter
Definition Debugger.h:620
llvm::StringRef GetStopShowColumnAnsiPrefix() const
Definition Debugger.cpp:596
static DebuggerList DebuggersRequestingInterruption()
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
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:357
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.
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
@ eBroadcastBitProgress
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
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::Debugger > DebuggerSP
StopDisassemblyType
Used to determine when to show disassembly.
std::shared_ptr< lldb_private::Event > EventSP
uint64_t pid_t
Definition lldb-types.h:83
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:781
lldb_private::DebuggerDestroyCallback callback
Definition Debugger.h:786
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition UserID.h:33