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