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