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