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