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"
25#include "lldb/Host/Terminal.h"
33#include "lldb/Utility/Status.h"
34#include "lldb/Utility/UserID.h"
35#include "lldb/lldb-defines.h"
37#include "lldb/lldb-forward.h"
40#include "lldb/lldb-types.h"
41
42#include "llvm/ADT/ArrayRef.h"
43#include "llvm/ADT/StringMap.h"
44#include "llvm/ADT/StringRef.h"
45#include "llvm/Support/DynamicLibrary.h"
46#include "llvm/Support/FormatVariadic.h"
47#include "llvm/Support/Threading.h"
48
49#include <cassert>
50#include <cstddef>
51#include <cstdio>
52
53namespace llvm {
54class raw_ostream;
55class ThreadPoolInterface;
56} // namespace llvm
57
58namespace lldb_private {
59class Address;
60class CallbackLogHandler;
61class CommandInterpreter;
62class LogHandler;
63class Process;
64class Stream;
65class SymbolContext;
66class Target;
67
68namespace repro {
69class DataRecorder;
70}
71
72/// \class Debugger Debugger.h "lldb/Core/Debugger.h"
73/// A class to manage flag bits.
74///
75/// Provides a global root objects for the debugger core.
76
77class Debugger : public std::enable_shared_from_this<Debugger>,
78 public UserID,
79 public Properties {
80public:
81 /// Broadcaster event bits definitions.
82 enum {
88 };
89
90 using DebuggerList = std::vector<lldb::DebuggerSP>;
91
93
94 /// Get the public broadcaster for this debugger.
96 const Broadcaster &GetBroadcaster() const { return m_broadcaster; }
97
98 ~Debugger() override;
99
100 static lldb::DebuggerSP
101 CreateInstance(lldb::LogOutputCallback log_callback = nullptr,
102 void *baton = nullptr);
103
105
107
108 static void Initialize(LoadPluginCallbackType load_plugin_callback);
109
110 static void Terminate();
111
112 static void SettingsInitialize();
113
114 static void SettingsTerminate();
115
116 static void Destroy(lldb::DebuggerSP &debugger_sp);
117
119
120 static lldb::DebuggerSP
121 FindDebuggerWithInstanceName(llvm::StringRef instance_name);
122
123 static size_t GetNumDebuggers();
124
125 static lldb::DebuggerSP GetDebuggerAtIndex(size_t index);
126
127 static bool FormatDisassemblerAddress(const FormatEntity::Entry *format,
128 const SymbolContext *sc,
129 const SymbolContext *prev_sc,
130 const ExecutionContext *exe_ctx,
131 const Address *addr, Stream &s);
132
133 static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace,
134 llvm::StringRef prompt);
135
136 void Clear();
137
138 bool GetAsyncExecution();
139
140 void SetAsyncExecution(bool async);
141
143
145
147
149
150 File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
151
152 File &GetErrorFile() { return m_error_stream_sp->GetFile(); }
153
155
157
158 repro::DataRecorder *GetInputRecorder();
159
160 Status SetInputString(const char *data);
161
162 void SetInputFile(lldb::FileSP file);
163
164 void SetOutputFile(lldb::FileSP file);
165
166 void SetErrorFile(lldb::FileSP file);
167
169
171
173
175
177 assert(m_command_interpreter_up.get());
179 }
180
182 GetScriptInterpreter(bool can_create = true,
183 std::optional<lldb::ScriptLanguage> language = {});
184
186
187 // This returns the Debugger's scratch source manager. It won't be able to
188 // look up files in debug information, but it can look up files by absolute
189 // path and display them to you. To get the target's source manager, call
190 // GetSourceManager on the target instead.
192
195 }
196
198 /// Get accessor for the target list.
199 ///
200 /// The target list is part of the global debugger object. This the single
201 /// debugger shared instance to control where targets get created and to
202 /// allow for tracking and searching for targets based on certain criteria.
203 ///
204 /// \return
205 /// A global shared target list.
207
209
211
213
214 // If any of the streams are not set, set them to the in/out/err stream of
215 // the top most input reader to ensure they at least have something
218 lldb::StreamFileSP &err);
219
220 /// Run the given IO handler and return immediately.
221 void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp,
222 bool cancel_top_handler = true);
223
224 /// Run the given IO handler and block until it's complete.
225 void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp);
226
227 /// Remove the given IO handler if it's currently active.
228 bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp);
229
230 bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp);
231
233 IOHandler::Type second_top_type);
234
235 void PrintAsync(const char *s, size_t len, bool is_stdout);
236
237 llvm::StringRef GetTopIOHandlerControlSequence(char ch);
238
239 const char *GetIOHandlerCommandPrefix();
240
241 const char *GetIOHandlerHelpPrologue();
242
243 void ClearIOHandlers();
244
245 bool EnableLog(llvm::StringRef channel,
246 llvm::ArrayRef<const char *> categories,
247 llvm::StringRef log_file, uint32_t log_options,
248 size_t buffer_size, LogHandlerKind log_handler_kind,
249 llvm::raw_ostream &error_stream);
250
251 void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
252
253 // Properties Functions
259 };
260
262 VarSetOperationType op, llvm::StringRef property_path,
263 llvm::StringRef value) override;
264
265 bool GetAutoConfirm() const;
266
268
269 const FormatEntity::Entry *GetFrameFormat() const;
270
272
273 uint64_t GetStopDisassemblyMaxSize() const;
274
276
278
280
281 bool SetScriptLanguage(lldb::ScriptLanguage script_lang);
282
284
285 bool SetREPLLanguage(lldb::LanguageType repl_lang);
286
287 uint64_t GetTerminalWidth() const;
288
289 bool SetTerminalWidth(uint64_t term_width);
290
291 llvm::StringRef GetPrompt() const;
292
293 llvm::StringRef GetPromptAnsiPrefix() const;
294
295 llvm::StringRef GetPromptAnsiSuffix() const;
296
297 void SetPrompt(llvm::StringRef p);
298 void SetPrompt(const char *) = delete;
299
300 bool GetUseExternalEditor() const;
301 bool SetUseExternalEditor(bool use_external_editor_p);
302
303 llvm::StringRef GetExternalEditor() const;
304
305 bool SetExternalEditor(llvm::StringRef editor);
306
307 bool GetUseColor() const;
308
309 bool SetUseColor(bool use_color);
310
311 bool GetShowProgress() const;
312
313 bool SetShowProgress(bool show_progress);
314
315 llvm::StringRef GetShowProgressAnsiPrefix() const;
316
317 llvm::StringRef GetShowProgressAnsiSuffix() const;
318
319 bool GetUseAutosuggestion() const;
320
321 llvm::StringRef GetAutosuggestionAnsiPrefix() const;
322
323 llvm::StringRef GetAutosuggestionAnsiSuffix() const;
324
325 llvm::StringRef GetRegexMatchAnsiPrefix() const;
326
327 llvm::StringRef GetRegexMatchAnsiSuffix() const;
328
329 bool GetShowDontUsePoHint() const;
330
331 bool GetUseSourceCache() const;
332
333 bool SetUseSourceCache(bool use_source_cache);
334
335 bool GetHighlightSource() const;
336
338
339 llvm::StringRef GetStopShowColumnAnsiPrefix() const;
340
341 llvm::StringRef GetStopShowColumnAnsiSuffix() const;
342
343 uint64_t GetStopSourceLineCount(bool before) const;
344
346
347 uint64_t GetDisassemblyLineCount() const;
348
349 llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const;
350
351 llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const;
352
353 bool GetAutoOneLineSummaries() const;
354
355 bool GetAutoIndent() const;
356
357 bool SetAutoIndent(bool b);
358
359 bool GetPrintDecls() const;
360
361 bool SetPrintDecls(bool b);
362
363 uint64_t GetTabSize() const;
364
365 bool SetTabSize(uint64_t tab_size);
366
368
369 bool GetEscapeNonPrintables() const;
370
371 bool GetNotifyVoid() const;
372
373 const std::string &GetInstanceName() { return m_instance_name; }
374
375 bool LoadPlugin(const FileSpec &spec, Status &error);
376
377 void RunIOHandlers();
378
379 bool IsForwardingEvents();
380
381 void EnableForwardEvents(const lldb::ListenerSP &listener_sp);
382
383 void CancelForwardEvents(const lldb::ListenerSP &listener_sp);
384
386
387 Status RunREPL(lldb::LanguageType language, const char *repl_options);
388
389 /// Interruption in LLDB:
390 ///
391 /// This is a voluntary interruption mechanism, not preemptive. Parts of lldb
392 /// that do work that can be safely interrupted call
393 /// Debugger::InterruptRequested and if that returns true, they should return
394 /// at a safe point, shortcutting the rest of the work they were to do.
395 ///
396 /// lldb clients can both offer a CommandInterpreter (through
397 /// RunCommandInterpreter) and use the SB API's for their own purposes, so it
398 /// is convenient to separate "interrupting the CommandInterpreter execution"
399 /// and interrupting the work it is doing with the SB API's. So there are two
400 /// ways to cause an interrupt:
401 /// * CommandInterpreter::InterruptCommand: Interrupts the command currently
402 /// running in the command interpreter IOHandler thread
403 /// * Debugger::RequestInterrupt: Interrupts are active on anything but the
404 /// CommandInterpreter thread till CancelInterruptRequest is called.
405 ///
406 /// Since the two checks are mutually exclusive, however, it's also convenient
407 /// to have just one function to check the interrupt state.
408
409 /// Bump the "interrupt requested" count on the debugger to support
410 /// cooperative interruption. If this is non-zero, InterruptRequested will
411 /// return true. Interruptible operations are expected to query the
412 /// InterruptRequested API periodically, and interrupt what they were doing
413 /// if it returns \b true.
414 ///
415 void RequestInterrupt();
416
417 /// Decrement the "interrupt requested" counter.
419
420 /// This is the correct way to query the state of Interruption.
421 /// If you are on the RunCommandInterpreter thread, it will check the
422 /// command interpreter state, and if it is on another thread it will
423 /// check the debugger Interrupt Request state.
424 /// \param[in] cur_func
425 /// For reporting if the interruption was requested. Don't provide this by
426 /// hand, use INTERRUPT_REQUESTED so this gets done consistently.
427 ///
428 /// \param[in] formatv
429 /// A formatv string for the interrupt message. If the elements of the
430 /// message are expensive to compute, you can use the no-argument form of
431 /// InterruptRequested, then make up the report using REPORT_INTERRUPTION.
432 ///
433 /// \return
434 /// A boolean value, if \b true an interruptible operation should interrupt
435 /// itself.
436 template <typename... Args>
437 bool InterruptRequested(const char *cur_func, const char *formatv,
438 Args &&...args) {
439 bool ret_val = InterruptRequested();
440 if (ret_val) {
441 if (!formatv)
442 formatv = "Unknown message";
443 if (!cur_func)
444 cur_func = "<UNKNOWN>";
446 cur_func, llvm::formatv(formatv, std::forward<Args>(args)...)));
447 }
448 return ret_val;
449 }
450
451 /// This handy define will keep you from having to generate a report for the
452 /// interruption by hand. Use this except in the case where the arguments to
453 /// the message description are expensive to compute.
454#define INTERRUPT_REQUESTED(debugger, ...) \
455 (debugger).InterruptRequested(__func__, __VA_ARGS__)
456
457 // This form just queries for whether to interrupt, and does no reporting:
458 bool InterruptRequested();
459
460 // FIXME: Do we want to capture a backtrace at the interruption point?
462 public:
463 InterruptionReport(std::string function_name, std::string description)
464 : m_function_name(std::move(function_name)),
465 m_description(std::move(description)),
466 m_interrupt_time(std::chrono::system_clock::now()),
467 m_thread_id(llvm::get_threadid()) {}
468
469 InterruptionReport(std::string function_name,
470 const llvm::formatv_object_base &payload);
471
472 template <typename... Args>
473 InterruptionReport(std::string function_name, const char *format,
474 Args &&...args)
476 function_name,
477 llvm::formatv(format, std::forward<Args>(args)...)) {}
478
479 std::string m_function_name;
480 std::string m_description;
481 const std::chrono::time_point<std::chrono::system_clock> m_interrupt_time;
482 const uint64_t m_thread_id;
483 };
484 void ReportInterruption(const InterruptionReport &report);
485#define REPORT_INTERRUPTION(debugger, ...) \
486 (debugger).ReportInterruption( \
487 Debugger::InterruptionReport(__func__, __VA_ARGS__))
488
490
491public:
492 // This is for use in the command interpreter, when you either want the
493 // selected target, or if no target is present you want to prime the dummy
494 // target with entities that will be copied over to new targets.
495 Target &GetSelectedOrDummyTarget(bool prefer_dummy = false);
497
500 }
501
502 /// Shared thread pool. Use only with ThreadPoolTaskGroup.
503 static llvm::ThreadPoolInterface &GetThreadPool();
504
505 /// Report warning events.
506 ///
507 /// Warning events will be delivered to any debuggers that have listeners
508 /// for the eBroadcastBitWarning.
509 ///
510 /// \param[in] message
511 /// The warning message to be reported.
512 ///
513 /// \param [in] debugger_id
514 /// If this optional parameter has a value, it indicates the unique
515 /// debugger identifier that this diagnostic should be delivered to. If
516 /// this optional parameter does not have a value, the diagnostic event
517 /// will be delivered to all debuggers.
518 ///
519 /// \param [in] once
520 /// If a pointer is passed to a std::once_flag, then it will be used to
521 /// ensure the given warning is only broadcast once.
522 static void
523 ReportWarning(std::string message,
524 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
525 std::once_flag *once = nullptr);
526
527 /// Report error events.
528 ///
529 /// Error events will be delivered to any debuggers that have listeners
530 /// for the eBroadcastBitError.
531 ///
532 /// \param[in] message
533 /// The error 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 error is only broadcast once.
544 static void
545 ReportError(std::string message,
546 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
547 std::once_flag *once = nullptr);
548
549 /// Report info events.
550 ///
551 /// Unlike warning and error events, info events are not broadcast but are
552 /// logged for diagnostic purposes.
553 ///
554 /// \param[in] message
555 /// The info message to be reported.
556 ///
557 /// \param [in] debugger_id
558 /// If this optional parameter has a value, it indicates this diagnostic is
559 /// associated with a unique debugger instance.
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 info is only logged once.
564 static void
565 ReportInfo(std::string message,
566 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
567 std::once_flag *once = nullptr);
568
569 static void ReportSymbolChange(const ModuleSpec &module_spec);
570
571 void
573 void *baton);
574
575 /// Manually start the global event handler thread. It is useful to plugins
576 /// that directly use the \a lldb_private namespace and want to use the
577 /// debugger's default event handler thread instead of defining their own.
579
580 /// Manually stop the debugger's default event handler.
582
583 /// Force flushing the process's pending stdout and stderr to the debugger's
584 /// asynchronous stdout and stderr streams.
585 void FlushProcessOutput(Process &process, bool flush_stdout,
586 bool flush_stderr);
587
589 return m_source_file_cache;
590 }
591
592protected:
593 friend class CommandInterpreter;
594 friend class REPL;
595 friend class Progress;
596 friend class ProgressManager;
597
598 /// Report progress events.
599 ///
600 /// Progress events will be delivered to any debuggers that have listeners
601 /// for the eBroadcastBitProgress. This function is called by the
602 /// lldb_private::Progress class to deliver the events to any debuggers that
603 /// qualify.
604 ///
605 /// \param [in] progress_id
606 /// The unique integer identifier for the progress to report.
607 ///
608 /// \param[in] message
609 /// The title of the progress dialog to display in the UI.
610 ///
611 /// \param [in] completed
612 /// The amount of work completed. If \a completed is zero, then this event
613 /// is a progress started event. If \a completed is equal to \a total, then
614 /// this event is a progress end event. Otherwise completed indicates the
615 /// current progress compare to the total value.
616 ///
617 /// \param [in] total
618 /// The total amount of work units that need to be completed. If this value
619 /// is UINT64_MAX, then an indeterminate progress indicator should be
620 /// displayed.
621 ///
622 /// \param [in] debugger_id
623 /// If this optional parameter has a value, it indicates the unique
624 /// debugger identifier that this progress should be delivered to. If this
625 /// optional parameter does not have a value, the progress will be
626 /// delivered to all debuggers.
627 static void
628 ReportProgress(uint64_t progress_id, std::string title, std::string details,
629 uint64_t completed, uint64_t total,
630 std::optional<lldb::user_id_t> debugger_id,
631 uint32_t progress_category_bit = eBroadcastBitProgress);
632
634 std::string message,
635 std::optional<lldb::user_id_t> debugger_id,
636 std::once_flag *once);
637
639
641
642 void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
643 bool cancel_top_handler = true);
644
645 bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
646
647 bool HasIOHandlerThread() const;
648
650
651 void StopIOHandlerThread();
652
653 // Sets the IOHandler thread to the new_thread, and returns
654 // the previous IOHandler thread.
656
657 void JoinIOHandlerThread();
658
660
662
664
665 void HandleBreakpointEvent(const lldb::EventSP &event_sp);
666
667 void HandleProcessEvent(const lldb::EventSP &event_sp);
668
669 void HandleThreadEvent(const lldb::EventSP &event_sp);
670
671 void HandleProgressEvent(const lldb::EventSP &event_sp);
672
673 void HandleDiagnosticEvent(const lldb::EventSP &event_sp);
674
675 // Ensures two threads don't attempt to flush process output in parallel.
677
678 void InstanceInitialize();
679
680 // these should never be NULL
684
685 /// Used for shadowing the input file when capturing a reproducer.
686 repro::DataRecorder *m_input_recorder;
687
689 // broadcaster manager of
690 // last resort.
691 // It needs to get constructed before the target_list or any other member
692 // that might want to broadcast through the debugger.
693
696
699 std::unique_ptr<SourceManager> m_source_manager_up; // This is a scratch
700 // source manager that we
701 // return if we have no
702 // targets.
704 // for targets created in
705 // this debugger used this
706 // shared
707 // source file cache.
708 std::unique_ptr<CommandInterpreter> m_command_interpreter_up;
709
710 std::recursive_mutex m_script_interpreter_mutex;
711 std::array<lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown>
713
715 std::recursive_mutex m_io_handler_synchronous_mutex;
716
717 std::optional<uint64_t> m_current_event_id;
718
719 llvm::StringMap<std::weak_ptr<LogHandler>> m_stream_handlers;
720 std::shared_ptr<CallbackLogHandler> m_callback_handler_sp;
721 const std::string m_instance_name;
723 typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
727 Broadcaster m_sync_broadcaster; ///< Private debugger synchronization.
728 Broadcaster m_broadcaster; ///< Public Debugger event broadcaster.
730 llvm::once_flag m_clear_once;
733
736
737 uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
739
740 // Events for m_sync_broadcaster
741 enum {
743 };
744
745private:
746 // Use Debugger::CreateInstance() to get a shared pointer to a new debugger
747 // object
748 Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
749
750 Debugger(const Debugger &) = delete;
751 const Debugger &operator=(const Debugger &) = delete;
752};
753
754} // namespace lldb_private
755
756#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.
Definition: Broadcaster.h:145
A uniqued constant string class.
Definition: ConstString.h:40
const std::chrono::time_point< std::chrono::system_clock > m_interrupt_time
Definition: Debugger.h:481
InterruptionReport(std::string function_name, std::string description)
Definition: Debugger.h:463
InterruptionReport(std::string function_name, const char *format, Args &&...args)
Definition: Debugger.h:473
A class to manage flag bits.
Definition: Debugger.h:79
static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace, llvm::StringRef prompt)
Definition: Debugger.cpp:1415
llvm::StringRef GetAutosuggestionAnsiPrefix() const
Definition: Debugger.cpp:445
repro::DataRecorder * GetInputRecorder()
Definition: Debugger.cpp:975
lldb::StreamFileSP m_error_stream_sp
Definition: Debugger.h:683
bool SetUseExternalEditor(bool use_external_editor_p)
Definition: Debugger.cpp:387
PlatformList m_platform_list
Definition: Debugger.h:697
HostThread m_event_handler_thread
Definition: Debugger.h:725
static lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid)
Definition: Debugger.cpp:798
uint64_t GetDisassemblyLineCount() const
Definition: Debugger.cpp:540
lldb::TargetSP GetSelectedTarget()
Definition: Debugger.h:193
bool SetExternalEditor(llvm::StringRef editor)
Definition: Debugger.cpp:398
void RequestInterrupt()
Interruption in LLDB:
Definition: Debugger.cpp:1287
void ReportInterruption(const InterruptionReport &report)
Definition: Debugger.cpp:1319
StreamFile & GetOutputStream()
Definition: Debugger.h:154
ExecutionContext GetSelectedExecutionContext()
Definition: Debugger.cpp:1055
const std::string m_instance_name
Definition: Debugger.h:721
static void Terminate()
Definition: Debugger.cpp:616
void HandleProgressEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:2009
SourceManager & GetSourceManager()
Definition: Debugger.cpp:1668
bool SetShowProgress(bool show_progress)
Definition: Debugger.cpp:422
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=eBroadcastBitProgress)
Report progress events.
Definition: Debugger.cpp:1453
lldb::StreamSP GetAsyncOutputStream()
Definition: Debugger.cpp:1279
bool StartEventHandlerThread()
Manually start the global event handler thread.
Definition: Debugger.cpp:1955
bool SetUseSourceCache(bool use_source_cache)
Definition: Debugger.cpp:481
void StopEventHandlerThread()
Manually stop the debugger's default event handler.
Definition: Debugger.cpp:1995
static void ReportInfo(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report info events.
Definition: Debugger.cpp:1566
void SetAsyncExecution(bool async)
Definition: Debugger.cpp:971
HostThread SetIOHandlerThread(HostThread &new_thread)
Definition: Debugger.cpp:2107
SourceManager::SourceFileCache & GetSourceFileCache()
Definition: Debugger.h:588
void CancelForwardEvents(const lldb::ListenerSP &listener_sp)
Definition: Debugger.cpp:1851
bool GetPrintDecls() const
Definition: Debugger.cpp:569
lldb::FileSP GetInputFileSP()
Definition: Debugger.h:142
bool GetHighlightSource() const
Definition: Debugger.cpp:489
llvm::StringMap< std::weak_ptr< LogHandler > > m_stream_handlers
Definition: Debugger.h:719
CommandInterpreter & GetCommandInterpreter()
Definition: Debugger.h:176
LoadedPluginsList m_loaded_plugins
Definition: Debugger.h:724
std::vector< llvm::sys::DynamicLibrary > LoadedPluginsList
Definition: Debugger.h:723
Debugger(const Debugger &)=delete
bool SetTabSize(uint64_t tab_size)
Definition: Debugger.cpp:586
bool IsHandlingEvents() const
Definition: Debugger.h:385
void HandleDiagnosticEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:2094
static lldb::DebuggerSP GetDebuggerAtIndex(size_t index)
Definition: Debugger.cpp:1345
llvm::StringRef GetAutosuggestionAnsiSuffix() const
Definition: Debugger.cpp:451
StreamFile & GetErrorStream()
Definition: Debugger.h:156
lldb::ListenerSP m_listener_sp
Definition: Debugger.h:698
void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Definition: Debugger.cpp:1225
lldb::thread_result_t IOHandlerThread()
Definition: Debugger.cpp:2003
static lldb::TargetSP FindTargetWithProcess(Process *process)
Definition: Debugger.cpp:812
bool GetUseExternalEditor() const
Definition: Debugger.cpp:381
TerminalState m_terminal_state
Definition: Debugger.h:694
static void ReportDiagnosticImpl(DiagnosticEventData::Type type, std::string message, std::optional< lldb::user_id_t > debugger_id, std::once_flag *once)
Definition: Debugger.cpp:1514
const FormatEntity::Entry * GetThreadStopFormat() const
Definition: Debugger.cpp:340
TargetList & GetTargetList()
Get accessor for the target list.
Definition: Debugger.h:206
bool GetEscapeNonPrintables() const
Definition: Debugger.cpp:552
lldb::TargetSP m_dummy_target_sp
Definition: Debugger.h:731
std::unique_ptr< CommandInterpreter > m_command_interpreter_up
Definition: Debugger.h:708
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
Definition: Debugger.cpp:1552
static bool FormatDisassemblerAddress(const FormatEntity::Entry *format, const SymbolContext *sc, const SymbolContext *prev_sc, const ExecutionContext *exe_ctx, const Address *addr, Stream &s)
Definition: Debugger.cpp:1373
static void SettingsInitialize()
Definition: Debugger.cpp:642
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
Definition: Debugger.cpp:2201
llvm::StringRef GetShowProgressAnsiSuffix() const
Definition: Debugger.cpp:433
bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp)
Definition: Debugger.cpp:1145
bool HasIOHandlerThread() const
Definition: Debugger.cpp:2103
bool IsIOHandlerThreadCurrentThread() const
Definition: Debugger.cpp:2143
lldb::ListenerSP m_forward_listener_sp
Definition: Debugger.h:729
std::array< lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown > m_script_interpreters
Definition: Debugger.h:712
std::shared_ptr< CallbackLogHandler > m_callback_handler_sp
Definition: Debugger.h:720
void SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
Definition: Debugger.cpp:1431
void * m_destroy_callback_baton
Definition: Debugger.h:735
StopDisassemblyType GetStopDisassemblyDisplay() const
Definition: Debugger.cpp:533
Broadcaster m_broadcaster
Public Debugger event broadcaster.
Definition: Debugger.h:728
static void Initialize(LoadPluginCallbackType load_plugin_callback)
Definition: Debugger.cpp:607
static lldb::DebuggerSP FindDebuggerWithInstanceName(llvm::StringRef instance_name)
Definition: Debugger.cpp:783
uint64_t GetTerminalWidth() const
Definition: Debugger.cpp:367
std::mutex m_interrupt_mutex
Definition: Debugger.h:738
std::recursive_mutex m_io_handler_synchronous_mutex
Definition: Debugger.h:715
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:437
bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp)
Remove the given IO handler if it's currently active.
Definition: Debugger.cpp:1175
Diagnostics::CallbackID m_diagnostics_callback_id
Definition: Debugger.h:732
void SetPrompt(const char *)=delete
bool GetAutoOneLineSummaries() const
Definition: Debugger.cpp:546
const char * GetIOHandlerCommandPrefix()
Definition: Debugger.cpp:1167
bool GetUseColor() const
Definition: Debugger.cpp:403
lldb::BroadcasterManagerSP m_broadcaster_manager_sp
Definition: Debugger.h:688
Status RunREPL(lldb::LanguageType language, const char *repl_options)
Definition: Debugger.cpp:2157
bool PopIOHandler(const lldb::IOHandlerSP &reader_sp)
Definition: Debugger.cpp:1252
static LoadPluginCallbackType g_load_plugin_callback
Definition: Debugger.h:722
std::recursive_mutex m_script_interpreter_mutex
Definition: Debugger.h:710
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
Definition: Debugger.cpp:1179
void SetInputFile(lldb::FileSP file)
Definition: Debugger.cpp:1029
lldb::StreamFileSP GetErrorStreamSP()
Definition: Debugger.h:146
void SetPrompt(llvm::StringRef p)
Definition: Debugger.cpp:324
lldb::StreamSP GetAsyncErrorStream()
Definition: Debugger.cpp:1283
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)
Definition: Debugger.cpp:1601
uint64_t GetStopDisassemblyMaxSize() const
Definition: Debugger.cpp:294
Broadcaster m_sync_broadcaster
Private debugger synchronization.
Definition: Debugger.h:727
void RestoreInputTerminalState()
Definition: Debugger.cpp:1053
bool GetUseSourceCache() const
Definition: Debugger.cpp:475
HostThread m_io_handler_thread
Definition: Debugger.h:726
llvm::StringRef GetRegexMatchAnsiSuffix() const
Definition: Debugger.cpp:463
lldb::FileSP m_input_file_sp
Definition: Debugger.h:681
const Broadcaster & GetBroadcaster() const
Definition: Debugger.h:96
bool SetREPLLanguage(lldb::LanguageType repl_lang)
Definition: Debugger.cpp:362
const FormatEntity::Entry * GetDisassemblyFormat() const
Definition: Debugger.cpp:279
bool GetAutoIndent() const
Definition: Debugger.cpp:558
llvm::StringRef GetStopShowColumnAnsiSuffix() const
Definition: Debugger.cpp:508
Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value) override
Definition: Debugger.cpp:200
llvm::StringRef GetPromptAnsiSuffix() const
Definition: Debugger.cpp:318
void SetErrorFile(lldb::FileSP file)
Definition: Debugger.cpp:1042
bool GetAutoConfirm() const
Definition: Debugger.cpp:273
TargetList m_target_list
Definition: Debugger.h:695
lldb::ScriptLanguage GetScriptLanguage() const
Definition: Debugger.cpp:345
std::unique_ptr< SourceManager > m_source_manager_up
Definition: Debugger.h:699
static lldb::DebuggerSP CreateInstance(lldb::LogOutputCallback log_callback=nullptr, void *baton=nullptr)
Definition: Debugger.cpp:734
lldb::StopShowColumn GetStopShowColumn() const
Definition: Debugger.cpp:495
static void ReportSymbolChange(const ModuleSpec &module_spec)
Definition: Debugger.cpp:1573
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
Definition: Debugger.cpp:1559
bool SetPrintDecls(bool b)
Definition: Debugger.cpp:575
bool SetScriptLanguage(lldb::ScriptLanguage script_lang)
Definition: Debugger.cpp:352
bool LoadPlugin(const FileSpec &spec, Status &error)
Definition: Debugger.cpp:646
void SetOutputFile(lldb::FileSP file)
Definition: Debugger.cpp:1037
uint64_t GetStopSourceLineCount(bool before) const
Definition: Debugger.cpp:526
void EnableForwardEvents(const lldb::ListenerSP &listener_sp)
Definition: Debugger.cpp:1847
@ eBroadcastBitEventThreadIsListening
Definition: Debugger.h:742
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id)
Definition: Debugger.cpp:1357
void HandleBreakpointEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1675
static ConstString GetStaticBroadcasterClass()
Definition: Debugger.cpp:826
bool CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
Definition: Debugger.cpp:1149
PlatformList & GetPlatformList()
Definition: Debugger.h:208
Target & GetDummyTarget()
Definition: Debugger.h:496
const FormatEntity::Entry * GetFrameFormat() const
Definition: Debugger.cpp:284
lldb::ListenerSP GetListener()
Definition: Debugger.h:185
static void Destroy(lldb::DebuggerSP &debugger_sp)
Definition: Debugger.cpp:752
SourceManager::SourceFileCache m_source_file_cache
Definition: Debugger.h:703
llvm::StringRef GetPromptAnsiPrefix() const
Definition: Debugger.cpp:312
std::optional< uint64_t > m_current_event_id
Definition: Debugger.h:717
void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp)
Run the given IO handler and block until it's complete.
Definition: Debugger.cpp:1111
const FormatEntity::Entry * GetThreadFormat() const
Definition: Debugger.cpp:335
Broadcaster & GetBroadcaster()
Get the public broadcaster for this debugger.
Definition: Debugger.h:95
llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const
Definition: Debugger.cpp:514
bool GetShowDontUsePoHint() const
Definition: Debugger.cpp:469
uint64_t GetTabSize() const
Definition: Debugger.cpp:580
lldb::StreamFileSP m_output_stream_sp
Definition: Debugger.h:682
bool GetShowProgress() const
Definition: Debugger.cpp:416
llvm::StringRef GetRegexMatchAnsiPrefix() const
Definition: Debugger.cpp:457
std::mutex m_output_flush_mutex
Definition: Debugger.h:676
llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const
Definition: Debugger.cpp:520
void PrintProgress(const ProgressEventData &data)
bool SetUseColor(bool use_color)
Definition: Debugger.cpp:409
lldb_private::DebuggerDestroyCallback m_destroy_callback
Definition: Debugger.h:734
const char * GetIOHandlerHelpPrologue()
Definition: Debugger.cpp:1171
Status SetInputString(const char *data)
Definition: Debugger.cpp:986
bool GetUseAutosuggestion() const
Definition: Debugger.cpp:439
Target & GetSelectedOrDummyTarget(bool prefer_dummy=false)
Definition: Debugger.cpp:2149
void HandleProcessEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1742
IOHandlerStack m_io_handler_stack
Definition: Debugger.h:714
repro::DataRecorder * m_input_recorder
Used for shadowing the input file when capturing a reproducer.
Definition: Debugger.h:686
lldb::StreamFileSP GetOutputStreamSP()
Definition: Debugger.h:144
llvm::once_flag m_clear_once
Definition: Debugger.h:730
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::StreamFileSP &out, lldb::StreamFileSP &err)
Definition: Debugger.cpp:1184
static void SettingsTerminate()
Definition: Debugger.cpp:644
lldb::LanguageType GetREPLLanguage() const
Definition: Debugger.cpp:357
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1652
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton)
Definition: Debugger.cpp:1422
bool SetTerminalWidth(uint64_t term_width)
Definition: Debugger.cpp:373
llvm::StringRef GetExternalEditor() const
Definition: Debugger.cpp:392
void HandleThreadEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1829
static size_t GetNumDebuggers()
Definition: Debugger.cpp:1337
File & GetOutputFile()
Definition: Debugger.h:150
uint32_t m_interrupt_requested
Tracks interrupt requests.
Definition: Debugger.h:737
lldb::DWIMPrintVerbosity GetDWIMPrintVerbosity() const
Definition: Debugger.cpp:591
const std::string & GetInstanceName()
Definition: Debugger.h:373
lldb::BroadcasterManagerSP GetBroadcasterManager()
Definition: Debugger.h:498
lldb::thread_result_t DefaultEventHandler()
Definition: Debugger.cpp:1855
void PrintAsync(const char *s, size_t len, bool is_stdout)
Definition: Debugger.cpp:1154
llvm::StringRef GetPrompt() const
Definition: Debugger.cpp:306
bool GetNotifyVoid() const
Definition: Debugger.cpp:300
llvm::StringRef GetShowProgressAnsiPrefix() const
Definition: Debugger.cpp:427
const FormatEntity::Entry * GetFrameFormatUnique() const
Definition: Debugger.cpp:289
llvm::StringRef GetTopIOHandlerControlSequence(char ch)
Definition: Debugger.cpp:1163
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...
Definition: Debugger.cpp:1722
void CancelInterruptRequest()
Decrement the "interrupt requested" counter.
Definition: Debugger.cpp:1292
std::vector< lldb::DebuggerSP > DebuggerList
Definition: Debugger.h:90
bool SetAutoIndent(bool b)
Definition: Debugger.cpp:564
const Debugger & operator=(const Debugger &)=delete
llvm::StringRef GetStopShowColumnAnsiPrefix() const
Definition: Debugger.cpp:502
static DebuggerList DebuggersRequestingInterruption()
Definition: Debugger.cpp:1325
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file utility class.
Definition: FileSpec.h:56
An abstract base class for files.
Definition: File.h:36
A plug-in interface definition class for debugging a process.
Definition: Process.h:340
A class used to group progress reports by category.
Definition: Progress.h:140
A Progress indicator helper class.
Definition: Progress.h:58
The SourceFileCache class separates the source manager from the cache of source files.
An error handling class.
Definition: Status.h:44
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.
Definition: SymbolContext.h:34
lldb::TargetSP GetSelectedTarget()
Definition: TargetList.cpp:544
A RAII-friendly terminal state saving/restoring class.
Definition: Terminal.h:87
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
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.
std::shared_ptr< lldb_private::BroadcasterManager > BroadcasterManagerSP
Definition: lldb-forward.h:322
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
Definition: lldb-forward.h:353
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::Stream > StreamSP
Definition: lldb-forward.h:420
std::shared_ptr< lldb_private::Debugger > DebuggerSP
Definition: lldb-forward.h:331
std::shared_ptr< lldb_private::Event > EventSP
Definition: lldb-forward.h:337
uint64_t pid_t
Definition: lldb-types.h:81
std::shared_ptr< lldb_private::Listener > ListenerSP
Definition: lldb-forward.h:360
std::shared_ptr< lldb_private::StreamFile > StreamFileSP
Definition: lldb-forward.h:421
uint64_t user_id_t
Definition: lldb-types.h:80
void(* LogOutputCallback)(const char *, void *baton)
Definition: lldb-types.h:72
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:436
std::shared_ptr< lldb_private::File > FileSP
Definition: lldb-forward.h:345
Definition: Debugger.h:53
A mix in class that contains a generic user ID.
Definition: UserID.h:31