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