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 using DebuggerList = std::vector<lldb::DebuggerSP>;
82
83 static llvm::StringRef GetStaticBroadcasterClass();
84
85 /// Get the public broadcaster for this debugger.
87 const Broadcaster &GetBroadcaster() const { return m_broadcaster; }
88
89 ~Debugger() override;
90
91 static lldb::DebuggerSP
92 CreateInstance(lldb::LogOutputCallback log_callback = nullptr,
93 void *baton = nullptr);
94
96
98
99 static void Initialize(LoadPluginCallbackType load_plugin_callback);
100
101 static void Terminate();
102
103 static void SettingsInitialize();
104
105 static void SettingsTerminate();
106
107 static void Destroy(lldb::DebuggerSP &debugger_sp);
108
110
111 static lldb::DebuggerSP
112 FindDebuggerWithInstanceName(llvm::StringRef instance_name);
113
114 static size_t GetNumDebuggers();
115
116 static lldb::DebuggerSP GetDebuggerAtIndex(size_t index);
117
118 static bool FormatDisassemblerAddress(const FormatEntity::Entry *format,
119 const SymbolContext *sc,
120 const SymbolContext *prev_sc,
121 const ExecutionContext *exe_ctx,
122 const Address *addr, Stream &s);
123
124 static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace,
125 llvm::StringRef prompt);
126
127 void Clear();
128
129 bool GetAsyncExecution();
130
131 void SetAsyncExecution(bool async);
132
134
136
138
140
141 File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
142
143 File &GetErrorFile() { return m_error_stream_sp->GetFile(); }
144
146
148
149 repro::DataRecorder *GetInputRecorder();
150
151 Status SetInputString(const char *data);
152
153 void SetInputFile(lldb::FileSP file);
154
155 void SetOutputFile(lldb::FileSP file);
156
157 void SetErrorFile(lldb::FileSP file);
158
160
162
164
166
168 assert(m_command_interpreter_up.get());
170 }
171
173 GetScriptInterpreter(bool can_create = true,
174 std::optional<lldb::ScriptLanguage> language = {});
175
177
178 // This returns the Debugger's scratch source manager. It won't be able to
179 // look up files in debug information, but it can look up files by absolute
180 // path and display them to you. To get the target's source manager, call
181 // GetSourceManager on the target instead.
183
186 }
187
189 /// Get accessor for the target list.
190 ///
191 /// The target list is part of the global debugger object. This the single
192 /// debugger shared instance to control where targets get created and to
193 /// allow for tracking and searching for targets based on certain criteria.
194 ///
195 /// \return
196 /// A global shared target list.
198
200
202
204
205 // If any of the streams are not set, set them to the in/out/err stream of
206 // the top most input reader to ensure they at least have something
209 lldb::StreamFileSP &err);
210
211 /// Run the given IO handler and return immediately.
212 void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp,
213 bool cancel_top_handler = true);
214
215 /// Run the given IO handler and block until it's complete.
216 void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp);
217
218 /// Remove the given IO handler if it's currently active.
219 bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp);
220
221 bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp);
222
224 IOHandler::Type second_top_type);
225
226 void PrintAsync(const char *s, size_t len, bool is_stdout);
227
228 llvm::StringRef GetTopIOHandlerControlSequence(char ch);
229
230 const char *GetIOHandlerCommandPrefix();
231
232 const char *GetIOHandlerHelpPrologue();
233
234 void ClearIOHandlers();
235
236 bool EnableLog(llvm::StringRef channel,
237 llvm::ArrayRef<const char *> categories,
238 llvm::StringRef log_file, uint32_t log_options,
239 size_t buffer_size, LogHandlerKind log_handler_kind,
240 llvm::raw_ostream &error_stream);
241
242 void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
243
244 // Properties Functions
250 };
251
253 VarSetOperationType op, llvm::StringRef property_path,
254 llvm::StringRef value) override;
255
256 bool GetAutoConfirm() const;
257
259
260 const FormatEntity::Entry *GetFrameFormat() const;
261
263
264 uint64_t GetStopDisassemblyMaxSize() const;
265
267
269
271
272 bool SetScriptLanguage(lldb::ScriptLanguage script_lang);
273
275
276 bool SetREPLLanguage(lldb::LanguageType repl_lang);
277
278 uint64_t GetTerminalWidth() const;
279
280 bool SetTerminalWidth(uint64_t term_width);
281
282 llvm::StringRef GetPrompt() const;
283
284 llvm::StringRef GetPromptAnsiPrefix() const;
285
286 llvm::StringRef GetPromptAnsiSuffix() const;
287
288 void SetPrompt(llvm::StringRef p);
289 void SetPrompt(const char *) = delete;
290
291 bool GetUseExternalEditor() const;
292 bool SetUseExternalEditor(bool use_external_editor_p);
293
294 llvm::StringRef GetExternalEditor() const;
295
296 bool SetExternalEditor(llvm::StringRef editor);
297
298 bool GetUseColor() const;
299
300 bool SetUseColor(bool use_color);
301
302 bool GetShowProgress() const;
303
304 bool SetShowProgress(bool show_progress);
305
306 llvm::StringRef GetShowProgressAnsiPrefix() const;
307
308 llvm::StringRef GetShowProgressAnsiSuffix() const;
309
310 bool GetUseAutosuggestion() const;
311
312 llvm::StringRef GetAutosuggestionAnsiPrefix() const;
313
314 llvm::StringRef GetAutosuggestionAnsiSuffix() const;
315
316 llvm::StringRef GetRegexMatchAnsiPrefix() const;
317
318 llvm::StringRef GetRegexMatchAnsiSuffix() const;
319
320 bool GetShowDontUsePoHint() const;
321
322 bool GetUseSourceCache() const;
323
324 bool SetUseSourceCache(bool use_source_cache);
325
326 bool GetHighlightSource() const;
327
329
330 llvm::StringRef GetStopShowColumnAnsiPrefix() const;
331
332 llvm::StringRef GetStopShowColumnAnsiSuffix() const;
333
334 uint64_t GetStopSourceLineCount(bool before) const;
335
337
338 uint64_t GetDisassemblyLineCount() const;
339
340 llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const;
341
342 llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const;
343
344 bool GetAutoOneLineSummaries() const;
345
346 bool GetAutoIndent() const;
347
348 bool SetAutoIndent(bool b);
349
350 bool GetPrintDecls() const;
351
352 bool SetPrintDecls(bool b);
353
354 uint64_t GetTabSize() const;
355
356 bool SetTabSize(uint64_t tab_size);
357
359
360 bool GetEscapeNonPrintables() const;
361
362 bool GetNotifyVoid() const;
363
364 const std::string &GetInstanceName() { return m_instance_name; }
365
366 bool LoadPlugin(const FileSpec &spec, Status &error);
367
368 void RunIOHandlers();
369
370 bool IsForwardingEvents();
371
372 void EnableForwardEvents(const lldb::ListenerSP &listener_sp);
373
374 void CancelForwardEvents(const lldb::ListenerSP &listener_sp);
375
377
378 Status RunREPL(lldb::LanguageType language, const char *repl_options);
379
380 /// Interruption in LLDB:
381 ///
382 /// This is a voluntary interruption mechanism, not preemptive. Parts of lldb
383 /// that do work that can be safely interrupted call
384 /// Debugger::InterruptRequested and if that returns true, they should return
385 /// at a safe point, shortcutting the rest of the work they were to do.
386 ///
387 /// lldb clients can both offer a CommandInterpreter (through
388 /// RunCommandInterpreter) and use the SB API's for their own purposes, so it
389 /// is convenient to separate "interrupting the CommandInterpreter execution"
390 /// and interrupting the work it is doing with the SB API's. So there are two
391 /// ways to cause an interrupt:
392 /// * CommandInterpreter::InterruptCommand: Interrupts the command currently
393 /// running in the command interpreter IOHandler thread
394 /// * Debugger::RequestInterrupt: Interrupts are active on anything but the
395 /// CommandInterpreter thread till CancelInterruptRequest is called.
396 ///
397 /// Since the two checks are mutually exclusive, however, it's also convenient
398 /// to have just one function to check the interrupt state.
399
400 /// Bump the "interrupt requested" count on the debugger to support
401 /// cooperative interruption. If this is non-zero, InterruptRequested will
402 /// return true. Interruptible operations are expected to query the
403 /// InterruptRequested API periodically, and interrupt what they were doing
404 /// if it returns \b true.
405 ///
406 void RequestInterrupt();
407
408 /// Decrement the "interrupt requested" counter.
410
411 /// This is the correct way to query the state of Interruption.
412 /// If you are on the RunCommandInterpreter thread, it will check the
413 /// command interpreter state, and if it is on another thread it will
414 /// check the debugger Interrupt Request state.
415 /// \param[in] cur_func
416 /// For reporting if the interruption was requested. Don't provide this by
417 /// hand, use INTERRUPT_REQUESTED so this gets done consistently.
418 ///
419 /// \param[in] formatv
420 /// A formatv string for the interrupt message. If the elements of the
421 /// message are expensive to compute, you can use the no-argument form of
422 /// InterruptRequested, then make up the report using REPORT_INTERRUPTION.
423 ///
424 /// \return
425 /// A boolean value, if \b true an interruptible operation should interrupt
426 /// itself.
427 template <typename... Args>
428 bool InterruptRequested(const char *cur_func, const char *formatv,
429 Args &&...args) {
430 bool ret_val = InterruptRequested();
431 if (ret_val) {
432 if (!formatv)
433 formatv = "Unknown message";
434 if (!cur_func)
435 cur_func = "<UNKNOWN>";
437 cur_func, llvm::formatv(formatv, std::forward<Args>(args)...)));
438 }
439 return ret_val;
440 }
441
442 /// This handy define will keep you from having to generate a report for the
443 /// interruption by hand. Use this except in the case where the arguments to
444 /// the message description are expensive to compute.
445#define INTERRUPT_REQUESTED(debugger, ...) \
446 (debugger).InterruptRequested(__func__, __VA_ARGS__)
447
448 // This form just queries for whether to interrupt, and does no reporting:
449 bool InterruptRequested();
450
451 // FIXME: Do we want to capture a backtrace at the interruption point?
453 public:
454 InterruptionReport(std::string function_name, std::string description)
455 : m_function_name(std::move(function_name)),
456 m_description(std::move(description)),
457 m_interrupt_time(std::chrono::system_clock::now()),
458 m_thread_id(llvm::get_threadid()) {}
459
460 InterruptionReport(std::string function_name,
461 const llvm::formatv_object_base &payload);
462
463 template <typename... Args>
464 InterruptionReport(std::string function_name, const char *format,
465 Args &&...args)
467 function_name,
468 llvm::formatv(format, std::forward<Args>(args)...)) {}
469
470 std::string m_function_name;
471 std::string m_description;
472 const std::chrono::time_point<std::chrono::system_clock> m_interrupt_time;
473 const uint64_t m_thread_id;
474 };
475 void ReportInterruption(const InterruptionReport &report);
476#define REPORT_INTERRUPTION(debugger, ...) \
477 (debugger).ReportInterruption( \
478 Debugger::InterruptionReport(__func__, __VA_ARGS__))
479
481
482public:
483 // This is for use in the command interpreter, when you either want the
484 // selected target, or if no target is present you want to prime the dummy
485 // target with entities that will be copied over to new targets.
486 Target &GetSelectedOrDummyTarget(bool prefer_dummy = false);
488
491 }
492
493 /// Shared thread pool. Use only with ThreadPoolTaskGroup.
494 static llvm::ThreadPoolInterface &GetThreadPool();
495
496 /// Report warning events.
497 ///
498 /// Warning events will be delivered to any debuggers that have listeners
499 /// for the eBroadcastBitWarning.
500 ///
501 /// \param[in] message
502 /// The warning message to be reported.
503 ///
504 /// \param [in] debugger_id
505 /// If this optional parameter has a value, it indicates the unique
506 /// debugger identifier that this diagnostic should be delivered to. If
507 /// this optional parameter does not have a value, the diagnostic event
508 /// will be delivered to all debuggers.
509 ///
510 /// \param [in] once
511 /// If a pointer is passed to a std::once_flag, then it will be used to
512 /// ensure the given warning is only broadcast once.
513 static void
514 ReportWarning(std::string message,
515 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
516 std::once_flag *once = nullptr);
517
518 /// Report error events.
519 ///
520 /// Error events will be delivered to any debuggers that have listeners
521 /// for the eBroadcastBitError.
522 ///
523 /// \param[in] message
524 /// The error message to be reported.
525 ///
526 /// \param [in] debugger_id
527 /// If this optional parameter has a value, it indicates the unique
528 /// debugger identifier that this diagnostic should be delivered to. If
529 /// this optional parameter does not have a value, the diagnostic event
530 /// will be delivered to all debuggers.
531 ///
532 /// \param [in] once
533 /// If a pointer is passed to a std::once_flag, then it will be used to
534 /// ensure the given error is only broadcast once.
535 static void
536 ReportError(std::string message,
537 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
538 std::once_flag *once = nullptr);
539
540 /// Report info events.
541 ///
542 /// Unlike warning and error events, info events are not broadcast but are
543 /// logged for diagnostic purposes.
544 ///
545 /// \param[in] message
546 /// The info message to be reported.
547 ///
548 /// \param [in] debugger_id
549 /// If this optional parameter has a value, it indicates this diagnostic is
550 /// associated with a unique debugger instance.
551 ///
552 /// \param [in] once
553 /// If a pointer is passed to a std::once_flag, then it will be used to
554 /// ensure the given info is only logged once.
555 static void
556 ReportInfo(std::string message,
557 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
558 std::once_flag *once = nullptr);
559
560 static void ReportSymbolChange(const ModuleSpec &module_spec);
561
562 void
564 void *baton);
565
566 /// Manually start the global event handler thread. It is useful to plugins
567 /// that directly use the \a lldb_private namespace and want to use the
568 /// debugger's default event handler thread instead of defining their own.
570
571 /// Manually stop the debugger's default event handler.
573
574 /// Force flushing the process's pending stdout and stderr to the debugger's
575 /// asynchronous stdout and stderr streams.
576 void FlushProcessOutput(Process &process, bool flush_stdout,
577 bool flush_stderr);
578
580 return m_source_file_cache;
581 }
582
583protected:
584 friend class CommandInterpreter;
585 friend class REPL;
586 friend class Progress;
587 friend class ProgressManager;
588
589 /// Report progress events.
590 ///
591 /// Progress events will be delivered to any debuggers that have listeners
592 /// for the eBroadcastBitProgress. This function is called by the
593 /// lldb_private::Progress class to deliver the events to any debuggers that
594 /// qualify.
595 ///
596 /// \param [in] progress_id
597 /// The unique integer identifier for the progress to report.
598 ///
599 /// \param[in] message
600 /// The title of the progress dialog to display in the UI.
601 ///
602 /// \param [in] completed
603 /// The amount of work completed. If \a completed is zero, then this event
604 /// is a progress started event. If \a completed is equal to \a total, then
605 /// this event is a progress end event. Otherwise completed indicates the
606 /// current progress compare to the total value.
607 ///
608 /// \param [in] total
609 /// The total amount of work units that need to be completed. If this value
610 /// is UINT64_MAX, then an indeterminate progress indicator should be
611 /// displayed.
612 ///
613 /// \param [in] debugger_id
614 /// If this optional parameter has a value, it indicates the unique
615 /// debugger identifier that this progress should be delivered to. If this
616 /// optional parameter does not have a value, the progress will be
617 /// delivered to all debuggers.
618 static void
619 ReportProgress(uint64_t progress_id, std::string title, std::string details,
620 uint64_t completed, uint64_t total,
621 std::optional<lldb::user_id_t> debugger_id,
622 uint32_t progress_category_bit = lldb::eBroadcastBitProgress);
623
624 static void ReportDiagnosticImpl(lldb::Severity severity, std::string message,
625 std::optional<lldb::user_id_t> debugger_id,
626 std::once_flag *once);
627
629
631
632 void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
633 bool cancel_top_handler = true);
634
635 bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
636
637 bool HasIOHandlerThread() const;
638
640
641 void StopIOHandlerThread();
642
643 // Sets the IOHandler thread to the new_thread, and returns
644 // the previous IOHandler thread.
646
647 void JoinIOHandlerThread();
648
650
652
654
655 void HandleBreakpointEvent(const lldb::EventSP &event_sp);
656
657 void HandleProcessEvent(const lldb::EventSP &event_sp);
658
659 void HandleThreadEvent(const lldb::EventSP &event_sp);
660
661 void HandleProgressEvent(const lldb::EventSP &event_sp);
662
663 void HandleDiagnosticEvent(const lldb::EventSP &event_sp);
664
665 // Ensures two threads don't attempt to flush process output in parallel.
667
668 void InstanceInitialize();
669
670 // these should never be NULL
674
675 /// Used for shadowing the input file when capturing a reproducer.
676 repro::DataRecorder *m_input_recorder;
677
679 // broadcaster manager of
680 // last resort.
681 // It needs to get constructed before the target_list or any other member
682 // that might want to broadcast through the debugger.
683
686
689 std::unique_ptr<SourceManager> m_source_manager_up; // This is a scratch
690 // source manager that we
691 // return if we have no
692 // targets.
694 // for targets created in
695 // this debugger used this
696 // shared
697 // source file cache.
698 std::unique_ptr<CommandInterpreter> m_command_interpreter_up;
699
700 std::recursive_mutex m_script_interpreter_mutex;
701 std::array<lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown>
703
705 std::recursive_mutex m_io_handler_synchronous_mutex;
706
707 std::optional<uint64_t> m_current_event_id;
708
709 llvm::StringMap<std::weak_ptr<LogHandler>> m_stream_handlers;
710 std::shared_ptr<CallbackLogHandler> m_callback_handler_sp;
711 const std::string m_instance_name;
713 typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
717 Broadcaster m_sync_broadcaster; ///< Private debugger synchronization.
718 Broadcaster m_broadcaster; ///< Public Debugger event broadcaster.
720 llvm::once_flag m_clear_once;
723
726
727 uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
729
730 // Events for m_sync_broadcaster
731 enum {
733 };
734
735private:
736 // Use Debugger::CreateInstance() to get a shared pointer to a new debugger
737 // object
738 Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
739
740 Debugger(const Debugger &) = delete;
741 const Debugger &operator=(const Debugger &) = delete;
742};
743
744} // namespace lldb_private
745
746#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
const std::chrono::time_point< std::chrono::system_clock > m_interrupt_time
Definition: Debugger.h:472
InterruptionReport(std::string function_name, std::string description)
Definition: Debugger.h:454
InterruptionReport(std::string function_name, const char *format, Args &&...args)
Definition: Debugger.h:464
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:1412
llvm::StringRef GetAutosuggestionAnsiPrefix() const
Definition: Debugger.cpp:445
repro::DataRecorder * GetInputRecorder()
Definition: Debugger.cpp:975
lldb::StreamFileSP m_error_stream_sp
Definition: Debugger.h:673
@ eBroadcastBitEventThreadIsListening
Definition: Debugger.h:732
bool SetUseExternalEditor(bool use_external_editor_p)
Definition: Debugger.cpp:387
PlatformList m_platform_list
Definition: Debugger.h:687
HostThread m_event_handler_thread
Definition: Debugger.h:715
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:184
bool SetExternalEditor(llvm::StringRef editor)
Definition: Debugger.cpp:398
void RequestInterrupt()
Interruption in LLDB:
Definition: Debugger.cpp:1284
void ReportInterruption(const InterruptionReport &report)
Definition: Debugger.cpp:1316
StreamFile & GetOutputStream()
Definition: Debugger.h:145
ExecutionContext GetSelectedExecutionContext()
Definition: Debugger.cpp:1055
const std::string m_instance_name
Definition: Debugger.h:711
static void Terminate()
Definition: Debugger.cpp:616
void HandleProgressEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:2007
SourceManager & GetSourceManager()
Definition: Debugger.cpp:1665
bool SetShowProgress(bool show_progress)
Definition: Debugger.cpp:422
lldb::StreamSP GetAsyncOutputStream()
Definition: Debugger.cpp:1276
bool StartEventHandlerThread()
Manually start the global event handler thread.
Definition: Debugger.cpp:1953
bool SetUseSourceCache(bool use_source_cache)
Definition: Debugger.cpp:481
void StopEventHandlerThread()
Manually stop the debugger's default event handler.
Definition: Debugger.cpp:1993
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:1564
void SetAsyncExecution(bool async)
Definition: Debugger.cpp:971
HostThread SetIOHandlerThread(HostThread &new_thread)
Definition: Debugger.cpp:2105
SourceManager::SourceFileCache & GetSourceFileCache()
Definition: Debugger.h:579
void CancelForwardEvents(const lldb::ListenerSP &listener_sp)
Definition: Debugger.cpp:1848
bool GetPrintDecls() const
Definition: Debugger.cpp:569
lldb::FileSP GetInputFileSP()
Definition: Debugger.h:133
bool GetHighlightSource() const
Definition: Debugger.cpp:489
llvm::StringMap< std::weak_ptr< LogHandler > > m_stream_handlers
Definition: Debugger.h:709
CommandInterpreter & GetCommandInterpreter()
Definition: Debugger.h:167
LoadedPluginsList m_loaded_plugins
Definition: Debugger.h:714
std::vector< llvm::sys::DynamicLibrary > LoadedPluginsList
Definition: Debugger.h:713
Debugger(const Debugger &)=delete
bool SetTabSize(uint64_t tab_size)
Definition: Debugger.cpp:586
bool IsHandlingEvents() const
Definition: Debugger.h:376
void HandleDiagnosticEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:2092
static lldb::DebuggerSP GetDebuggerAtIndex(size_t index)
Definition: Debugger.cpp:1342
llvm::StringRef GetAutosuggestionAnsiSuffix() const
Definition: Debugger.cpp:451
StreamFile & GetErrorStream()
Definition: Debugger.h:147
lldb::ListenerSP m_listener_sp
Definition: Debugger.h:688
void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Definition: Debugger.cpp:1222
lldb::thread_result_t IOHandlerThread()
Definition: Debugger.cpp:2001
static lldb::TargetSP FindTargetWithProcess(Process *process)
Definition: Debugger.cpp:812
bool GetUseExternalEditor() const
Definition: Debugger.cpp:381
TerminalState m_terminal_state
Definition: Debugger.h:684
const FormatEntity::Entry * GetThreadStopFormat() const
Definition: Debugger.cpp:340
TargetList & GetTargetList()
Get accessor for the target list.
Definition: Debugger.h:197
bool GetEscapeNonPrintables() const
Definition: Debugger.cpp:552
lldb::TargetSP m_dummy_target_sp
Definition: Debugger.h:721
std::unique_ptr< CommandInterpreter > m_command_interpreter_up
Definition: Debugger.h:698
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:1370
static void SettingsInitialize()
Definition: Debugger.cpp:642
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
Definition: Debugger.cpp:2199
llvm::StringRef GetShowProgressAnsiSuffix() const
Definition: Debugger.cpp:433
bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp)
Definition: Debugger.cpp:1142
bool HasIOHandlerThread() const
Definition: Debugger.cpp:2101
bool IsIOHandlerThreadCurrentThread() const
Definition: Debugger.cpp:2141
lldb::ListenerSP m_forward_listener_sp
Definition: Debugger.h:719
std::array< lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown > m_script_interpreters
Definition: Debugger.h:702
std::shared_ptr< CallbackLogHandler > m_callback_handler_sp
Definition: Debugger.h:710
void SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
Definition: Debugger.cpp:1428
void * m_destroy_callback_baton
Definition: Debugger.h:725
StopDisassemblyType GetStopDisassemblyDisplay() const
Definition: Debugger.cpp:533
Broadcaster m_broadcaster
Public Debugger event broadcaster.
Definition: Debugger.h:718
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:728
std::recursive_mutex m_io_handler_synchronous_mutex
Definition: Debugger.h:705
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:428
bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp)
Remove the given IO handler if it's currently active.
Definition: Debugger.cpp:1172
Diagnostics::CallbackID m_diagnostics_callback_id
Definition: Debugger.h:722
void SetPrompt(const char *)=delete
bool GetAutoOneLineSummaries() const
Definition: Debugger.cpp:546
const char * GetIOHandlerCommandPrefix()
Definition: Debugger.cpp:1164
bool GetUseColor() const
Definition: Debugger.cpp:403
lldb::BroadcasterManagerSP m_broadcaster_manager_sp
Definition: Debugger.h:678
Status RunREPL(lldb::LanguageType language, const char *repl_options)
Definition: Debugger.cpp:2155
bool PopIOHandler(const lldb::IOHandlerSP &reader_sp)
Definition: Debugger.cpp:1249
static LoadPluginCallbackType g_load_plugin_callback
Definition: Debugger.h:712
std::recursive_mutex m_script_interpreter_mutex
Definition: Debugger.h:700
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
Definition: Debugger.cpp:1176
void SetInputFile(lldb::FileSP file)
Definition: Debugger.cpp:1029
lldb::StreamFileSP GetErrorStreamSP()
Definition: Debugger.h:137
void SetPrompt(llvm::StringRef p)
Definition: Debugger.cpp:324
lldb::StreamSP GetAsyncErrorStream()
Definition: Debugger.cpp:1280
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:1598
uint64_t GetStopDisassemblyMaxSize() const
Definition: Debugger.cpp:294
Broadcaster m_sync_broadcaster
Private debugger synchronization.
Definition: Debugger.h:717
void RestoreInputTerminalState()
Definition: Debugger.cpp:1053
bool GetUseSourceCache() const
Definition: Debugger.cpp:475
HostThread m_io_handler_thread
Definition: Debugger.h:716
llvm::StringRef GetRegexMatchAnsiSuffix() const
Definition: Debugger.cpp:463
static llvm::StringRef GetStaticBroadcasterClass()
Definition: Debugger.cpp:826
lldb::FileSP m_input_file_sp
Definition: Debugger.h:671
const Broadcaster & GetBroadcaster() const
Definition: Debugger.h:87
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:685
lldb::ScriptLanguage GetScriptLanguage() const
Definition: Debugger.cpp:345
std::unique_ptr< SourceManager > m_source_manager_up
Definition: Debugger.h:689
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:1570
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:1558
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:1844
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id)
Definition: Debugger.cpp:1354
void HandleBreakpointEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1672
bool CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
Definition: Debugger.cpp:1146
PlatformList & GetPlatformList()
Definition: Debugger.h:199
Target & GetDummyTarget()
Definition: Debugger.h:487
const FormatEntity::Entry * GetFrameFormat() const
Definition: Debugger.cpp:284
lldb::ListenerSP GetListener()
Definition: Debugger.h:176
static void Destroy(lldb::DebuggerSP &debugger_sp)
Definition: Debugger.cpp:752
SourceManager::SourceFileCache m_source_file_cache
Definition: Debugger.h:693
llvm::StringRef GetPromptAnsiPrefix() const
Definition: Debugger.cpp:312
std::optional< uint64_t > m_current_event_id
Definition: Debugger.h:707
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:86
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:672
bool GetShowProgress() const
Definition: Debugger.cpp:416
llvm::StringRef GetRegexMatchAnsiPrefix() const
Definition: Debugger.cpp:457
std::mutex m_output_flush_mutex
Definition: Debugger.h:666
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:724
const char * GetIOHandlerHelpPrologue()
Definition: Debugger.cpp:1168
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:2147
void HandleProcessEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1739
IOHandlerStack m_io_handler_stack
Definition: Debugger.h:704
repro::DataRecorder * m_input_recorder
Used for shadowing the input file when capturing a reproducer.
Definition: Debugger.h:676
lldb::StreamFileSP GetOutputStreamSP()
Definition: Debugger.h:135
llvm::once_flag m_clear_once
Definition: Debugger.h:720
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::StreamFileSP &out, lldb::StreamFileSP &err)
Definition: Debugger.cpp:1181
static void SettingsTerminate()
Definition: Debugger.cpp:644
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.
Definition: Debugger.cpp:1450
lldb::LanguageType GetREPLLanguage() const
Definition: Debugger.cpp:357
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1649
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton)
Definition: Debugger.cpp:1419
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:1826
static size_t GetNumDebuggers()
Definition: Debugger.cpp:1334
File & GetOutputFile()
Definition: Debugger.h:141
uint32_t m_interrupt_requested
Tracks interrupt requests.
Definition: Debugger.h:727
lldb::DWIMPrintVerbosity GetDWIMPrintVerbosity() const
Definition: Debugger.cpp:591
const std::string & GetInstanceName()
Definition: Debugger.h:364
lldb::BroadcasterManagerSP GetBroadcasterManager()
Definition: Debugger.h:489
lldb::thread_result_t DefaultEventHandler()
Definition: Debugger.cpp:1852
void PrintAsync(const char *s, size_t len, bool is_stdout)
Definition: Debugger.cpp:1151
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:1160
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:1719
void CancelInterruptRequest()
Decrement the "interrupt requested" counter.
Definition: Debugger.cpp:1289
static void ReportDiagnosticImpl(lldb::Severity severity, std::string message, std::optional< lldb::user_id_t > debugger_id, std::once_flag *once)
Definition: Debugger.cpp:1511
std::vector< lldb::DebuggerSP > DebuggerList
Definition: Debugger.h:81
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:1322
"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:341
A class used to group progress reports by category.
Definition: Progress.h:145
A Progress indicator helper class.
Definition: Progress.h:59
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.
Severity
Used for expressing severity in logs and diagnostics.
std::shared_ptr< lldb_private::BroadcasterManager > BroadcasterManagerSP
Definition: lldb-forward.h:322
@ eBroadcastBitProgress
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