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/Threading.h"
47
48#include <cassert>
49#include <cstddef>
50#include <cstdio>
51
52namespace llvm {
53class raw_ostream;
54class ThreadPool;
55}
56
57namespace lldb_private {
58class Address;
59class CallbackLogHandler;
60class CommandInterpreter;
61class LogHandler;
62class Process;
63class Stream;
64class SymbolContext;
65class Target;
66
67namespace repro {
68class DataRecorder;
69}
70
71/// \class Debugger Debugger.h "lldb/Core/Debugger.h"
72/// A class to manage flag bits.
73///
74/// Provides a global root objects for the debugger core.
75
76class Debugger : public std::enable_shared_from_this<Debugger>,
77 public UserID,
78 public Properties {
79 friend class SourceManager; // For GetSourceFileCache.
80
81public:
82 /// Broadcaster event bits definitions.
83 enum {
88 };
89
91
92 /// Get the public broadcaster for this debugger.
94 const Broadcaster &GetBroadcaster() const { return m_broadcaster; }
95
96 ~Debugger() override;
97
98 static lldb::DebuggerSP
99 CreateInstance(lldb::LogOutputCallback log_callback = nullptr,
100 void *baton = nullptr);
101
102 static lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid);
103
104 static lldb::TargetSP FindTargetWithProcess(Process *process);
105
106 static void Initialize(LoadPluginCallbackType load_plugin_callback);
107
108 static void Terminate();
109
110 static void SettingsInitialize();
111
112 static void SettingsTerminate();
113
114 static void Destroy(lldb::DebuggerSP &debugger_sp);
115
116 static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id);
117
118 static lldb::DebuggerSP
119 FindDebuggerWithInstanceName(llvm::StringRef instance_name);
120
121 static size_t GetNumDebuggers();
122
123 static lldb::DebuggerSP GetDebuggerAtIndex(size_t index);
124
125 static bool FormatDisassemblerAddress(const FormatEntity::Entry *format,
126 const SymbolContext *sc,
127 const SymbolContext *prev_sc,
128 const ExecutionContext *exe_ctx,
129 const Address *addr, Stream &s);
130
131 void Clear();
132
133 bool GetAsyncExecution();
134
135 void SetAsyncExecution(bool async);
136
137 lldb::FileSP GetInputFileSP() { return m_input_file_sp; }
138
139 lldb::StreamFileSP GetOutputStreamSP() { return m_output_stream_sp; }
140
141 lldb::StreamFileSP GetErrorStreamSP() { return m_error_stream_sp; }
142
144
145 File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
146
147 File &GetErrorFile() { return m_error_stream_sp->GetFile(); }
148
150
152
153 repro::DataRecorder *GetInputRecorder();
154
155 Status SetInputString(const char *data);
156
157 void SetInputFile(lldb::FileSP file);
158
159 void SetOutputFile(lldb::FileSP file);
160
161 void SetErrorFile(lldb::FileSP file);
162
164
166
167 lldb::StreamSP GetAsyncOutputStream();
168
169 lldb::StreamSP GetAsyncErrorStream();
170
172 assert(m_command_interpreter_up.get());
174 }
175
177 GetScriptInterpreter(bool can_create = true,
178 std::optional<lldb::ScriptLanguage> language = {});
179
180 lldb::ListenerSP GetListener() { return m_listener_sp; }
181
182 // This returns the Debugger's scratch source manager. It won't be able to
183 // look up files in debug information, but it can look up files by absolute
184 // path and display them to you. To get the target's source manager, call
185 // GetSourceManager on the target instead.
187
188 lldb::TargetSP GetSelectedTarget() {
190 }
191
193 /// Get accessor for the target list.
194 ///
195 /// The target list is part of the global debugger object. This the single
196 /// debugger shared instance to control where targets get created and to
197 /// allow for tracking and searching for targets based on certain criteria.
198 ///
199 /// \return
200 /// A global shared target list.
202
204
206
208
209 // If any of the streams are not set, set them to the in/out/err stream of
210 // the top most input reader to ensure they at least have something
211 void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in,
212 lldb::StreamFileSP &out,
213 lldb::StreamFileSP &err);
214
215 /// Run the given IO handler and return immediately.
216 void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp,
217 bool cancel_top_handler = true);
218
219 /// Run the given IO handler and block until it's complete.
220 void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp);
221
222 /// Remove the given IO handler if it's currently active.
223 bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp);
224
225 bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp);
226
228 IOHandler::Type second_top_type);
229
230 void PrintAsync(const char *s, size_t len, bool is_stdout);
231
233
234 const char *GetIOHandlerCommandPrefix();
235
236 const char *GetIOHandlerHelpPrologue();
237
238 void ClearIOHandlers();
239
240 bool GetCloseInputOnEOF() const;
241
242 void SetCloseInputOnEOF(bool b);
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 void SetPrompt(llvm::StringRef p);
293 void SetPrompt(const char *) = delete;
294
295 bool GetUseExternalEditor() const;
296 bool SetUseExternalEditor(bool use_external_editor_p);
297
298 llvm::StringRef GetExternalEditor() const;
299
300 bool SetExternalEditor(llvm::StringRef editor);
301
302 bool GetUseColor() const;
303
304 bool SetUseColor(bool use_color);
305
306 bool GetShowProgress() const;
307
308 bool SetShowProgress(bool show_progress);
309
310 llvm::StringRef GetShowProgressAnsiPrefix() const;
311
312 llvm::StringRef GetShowProgressAnsiSuffix() const;
313
314 bool GetUseAutosuggestion() const;
315
316 llvm::StringRef GetAutosuggestionAnsiPrefix() const;
317
318 llvm::StringRef GetAutosuggestionAnsiSuffix() const;
319
320 bool GetUseSourceCache() const;
321
322 bool SetUseSourceCache(bool use_source_cache);
323
324 bool GetHighlightSource() const;
325
327
328 llvm::StringRef GetStopShowColumnAnsiPrefix() const;
329
330 llvm::StringRef GetStopShowColumnAnsiSuffix() const;
331
332 uint64_t GetStopSourceLineCount(bool before) const;
333
335
336 uint64_t GetDisassemblyLineCount() const;
337
338 llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const;
339
340 llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const;
341
342 bool GetAutoOneLineSummaries() const;
343
344 bool GetAutoIndent() const;
345
346 bool SetAutoIndent(bool b);
347
348 bool GetPrintDecls() const;
349
350 bool SetPrintDecls(bool b);
351
352 uint64_t GetTabSize() const;
353
354 bool SetTabSize(uint64_t tab_size);
355
357
358 bool GetEscapeNonPrintables() const;
359
360 bool GetNotifyVoid() const;
361
362 const std::string &GetInstanceName() { return m_instance_name; }
363
364 bool LoadPlugin(const FileSpec &spec, Status &error);
365
366 void RunIOHandlers();
367
368 bool IsForwardingEvents();
369
370 void EnableForwardEvents(const lldb::ListenerSP &listener_sp);
371
372 void CancelForwardEvents(const lldb::ListenerSP &listener_sp);
373
375
376 Status RunREPL(lldb::LanguageType language, const char *repl_options);
377
378 /// Interruption in LLDB:
379 ///
380 /// This is a voluntary interruption mechanism, not preemptive. Parts of lldb
381 /// that do work that can be safely interrupted call
382 /// Debugger::InterruptRequested and if that returns true, they should return
383 /// at a safe point, shortcutting the rest of the work they were to do.
384 ///
385 /// lldb clients can both offer a CommandInterpreter (through
386 /// RunCommandInterpreter) and use the SB API's for their own purposes, so it
387 /// is convenient to separate "interrupting the CommandInterpreter execution"
388 /// and interrupting the work it is doing with the SB API's. So there are two
389 /// ways to cause an interrupt:
390 /// * CommandInterpreter::InterruptCommand: Interrupts the command currently
391 /// running in the command interpreter IOHandler thread
392 /// * Debugger::RequestInterrupt: Interrupts are active on anything but the
393 /// CommandInterpreter thread till CancelInterruptRequest is called.
394 ///
395 /// Since the two checks are mutually exclusive, however, it's also convenient
396 /// to have just one function to check the interrupt state.
397
398
399 /// Bump the "interrupt requested" count on the debugger to support
400 /// cooperative interruption. If this is non-zero, InterruptRequested will
401 /// return true. Interruptible operations are expected to query the
402 /// InterruptRequested API periodically, and interrupt what they were doing
403 /// if it returns \b true.
404 ///
405 void RequestInterrupt();
406
407 /// Decrement the "interrupt requested" counter.
409
410 /// This is the correct way to query the state of Interruption.
411 /// If you are on the RunCommandInterpreter thread, it will check the
412 /// command interpreter state, and if it is on another thread it will
413 /// check the debugger Interrupt Request state.
414 ///
415 /// \return
416 /// A boolean value, if \b true an interruptible operation should interrupt
417 /// itself.
418 bool InterruptRequested();
419
420 // This is for use in the command interpreter, when you either want the
421 // selected target, or if no target is present you want to prime the dummy
422 // target with entities that will be copied over to new targets.
423 Target &GetSelectedOrDummyTarget(bool prefer_dummy = false);
425
426 lldb::BroadcasterManagerSP GetBroadcasterManager() {
428 }
429
430 /// Shared thread poll. Use only with ThreadPoolTaskGroup.
431 static llvm::ThreadPool &GetThreadPool();
432
433 /// Report warning events.
434 ///
435 /// Warning events will be delivered to any debuggers that have listeners
436 /// for the eBroadcastBitWarning.
437 ///
438 /// \param[in] message
439 /// The warning message to be reported.
440 ///
441 /// \param [in] debugger_id
442 /// If this optional parameter has a value, it indicates the unique
443 /// debugger identifier that this diagnostic should be delivered to. If
444 /// this optional parameter does not have a value, the diagnostic event
445 /// will be delivered to all debuggers.
446 ///
447 /// \param [in] once
448 /// If a pointer is passed to a std::once_flag, then it will be used to
449 /// ensure the given warning is only broadcast once.
450 static void
451 ReportWarning(std::string message,
452 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
453 std::once_flag *once = nullptr);
454
455 /// Report error events.
456 ///
457 /// Error events will be delivered to any debuggers that have listeners
458 /// for the eBroadcastBitError.
459 ///
460 /// \param[in] message
461 /// The error message to be reported.
462 ///
463 /// \param [in] debugger_id
464 /// If this optional parameter has a value, it indicates the unique
465 /// debugger identifier that this diagnostic should be delivered to. If
466 /// this optional parameter does not have a value, the diagnostic event
467 /// will be delivered to all debuggers.
468 ///
469 /// \param [in] once
470 /// If a pointer is passed to a std::once_flag, then it will be used to
471 /// ensure the given error is only broadcast once.
472 static void
473 ReportError(std::string message,
474 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
475 std::once_flag *once = nullptr);
476
477 /// Report info events.
478 ///
479 /// Unlike warning and error events, info events are not broadcast but are
480 /// logged for diagnostic purposes.
481 ///
482 /// \param[in] message
483 /// The info message to be reported.
484 ///
485 /// \param [in] debugger_id
486 /// If this optional parameter has a value, it indicates this diagnostic is
487 /// associated with a unique debugger instance.
488 ///
489 /// \param [in] once
490 /// If a pointer is passed to a std::once_flag, then it will be used to
491 /// ensure the given info is only logged once.
492 static void
493 ReportInfo(std::string message,
494 std::optional<lldb::user_id_t> debugger_id = std::nullopt,
495 std::once_flag *once = nullptr);
496
497 static void ReportSymbolChange(const ModuleSpec &module_spec);
498
499 void
500 SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
501 void *baton);
502
503 /// Manually start the global event handler thread. It is useful to plugins
504 /// that directly use the \a lldb_private namespace and want to use the
505 /// debugger's default event handler thread instead of defining their own.
507
508 /// Manually stop the debugger's default event handler.
510
511 /// Force flushing the process's pending stdout and stderr to the debugger's
512 /// asynchronous stdout and stderr streams.
513 void FlushProcessOutput(Process &process, bool flush_stdout,
514 bool flush_stderr);
515
516protected:
517 friend class CommandInterpreter;
518 friend class REPL;
519 friend class Progress;
520
521 /// Report progress events.
522 ///
523 /// Progress events will be delivered to any debuggers that have listeners
524 /// for the eBroadcastBitProgress. This function is called by the
525 /// lldb_private::Progress class to deliver the events to any debuggers that
526 /// qualify.
527 ///
528 /// \param [in] progress_id
529 /// The unique integer identifier for the progress to report.
530 ///
531 /// \param[in] message
532 /// The title of the progress dialog to display in the UI.
533 ///
534 /// \param [in] completed
535 /// The amount of work completed. If \a completed is zero, then this event
536 /// is a progress started event. If \a completed is equal to \a total, then
537 /// this event is a progress end event. Otherwise completed indicates the
538 /// current progress compare to the total value.
539 ///
540 /// \param [in] total
541 /// The total amount of work units that need to be completed. If this value
542 /// is UINT64_MAX, then an indeterminate progress indicator should be
543 /// displayed.
544 ///
545 /// \param [in] debugger_id
546 /// If this optional parameter has a value, it indicates the unique
547 /// debugger identifier that this progress should be delivered to. If this
548 /// optional parameter does not have a value, the progress will be
549 /// delivered to all debuggers.
550 static void ReportProgress(uint64_t progress_id, std::string title,
551 std::string details, uint64_t completed,
552 uint64_t total,
553 std::optional<lldb::user_id_t> debugger_id);
554
556 std::string message,
557 std::optional<lldb::user_id_t> debugger_id,
558 std::once_flag *once);
559
561
563
564 void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
565 bool cancel_top_handler = true);
566
567 bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
568
569 bool HasIOHandlerThread() const;
570
572
573 void StopIOHandlerThread();
574
575 // Sets the IOHandler thread to the new_thread, and returns
576 // the previous IOHandler thread.
578
579 void JoinIOHandlerThread();
580
582
584
586
587 void HandleBreakpointEvent(const lldb::EventSP &event_sp);
588
589 void HandleProcessEvent(const lldb::EventSP &event_sp);
590
591 void HandleThreadEvent(const lldb::EventSP &event_sp);
592
593 void HandleProgressEvent(const lldb::EventSP &event_sp);
594
595 void HandleDiagnosticEvent(const lldb::EventSP &event_sp);
596
597 // Ensures two threads don't attempt to flush process output in parallel.
599
601 return m_source_file_cache;
602 }
603
604 void InstanceInitialize();
605
606 // these should never be NULL
607 lldb::FileSP m_input_file_sp;
608 lldb::StreamFileSP m_output_stream_sp;
609 lldb::StreamFileSP m_error_stream_sp;
610
611 /// Used for shadowing the input file when capturing a reproducer.
612 repro::DataRecorder *m_input_recorder;
613
614 lldb::BroadcasterManagerSP m_broadcaster_manager_sp; // The debugger acts as a
615 // broadcaster manager of
616 // last resort.
617 // It needs to get constructed before the target_list or any other member
618 // that might want to broadcast through the debugger.
619
620 TerminalState m_terminal_state;
622
624 lldb::ListenerSP m_listener_sp;
625 std::unique_ptr<SourceManager> m_source_manager_up; // This is a scratch
626 // source manager that we
627 // return if we have no
628 // targets.
630 // for targets created in
631 // this debugger used this
632 // shared
633 // source file cache.
634 std::unique_ptr<CommandInterpreter> m_command_interpreter_up;
635
636 std::recursive_mutex m_script_interpreter_mutex;
637 std::array<lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown>
639
641 std::recursive_mutex m_io_handler_synchronous_mutex;
642
643 std::optional<uint64_t> m_current_event_id;
644
645 llvm::StringMap<std::weak_ptr<LogHandler>> m_stream_handlers;
646 std::shared_ptr<CallbackLogHandler> m_callback_handler_sp;
647 const std::string m_instance_name;
648 static LoadPluginCallbackType g_load_plugin_callback;
649 typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
653 Broadcaster m_sync_broadcaster; ///< Private debugger synchronization.
654 Broadcaster m_broadcaster; ///< Public Debugger event broadcaster.
655 lldb::ListenerSP m_forward_listener_sp;
656 llvm::once_flag m_clear_once;
657 lldb::TargetSP m_dummy_target_sp;
659
660 lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr;
662
663 uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
665
666 // Events for m_sync_broadcaster
667 enum {
669 };
670
671private:
672 // Use Debugger::CreateInstance() to get a shared pointer to a new debugger
673 // object
674 Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
675
676 Debugger(const Debugger &) = delete;
677 const Debugger &operator=(const Debugger &) = delete;
678};
679
680} // namespace lldb_private
681
682#endif // LLDB_CORE_DEBUGGER_H
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address class.
Definition: Address.h:59
An event broadcasting class.
Definition: Broadcaster.h:145
A uniqued constant string class.
Definition: ConstString.h:40
A class to manage flag bits.
Definition: Debugger.h:78
llvm::StringRef GetAutosuggestionAnsiPrefix() const
Definition: Debugger.cpp:424
repro::DataRecorder * GetInputRecorder()
Definition: Debugger.cpp:942
lldb::StreamFileSP m_error_stream_sp
Definition: Debugger.h:609
bool SetUseExternalEditor(bool use_external_editor_p)
Definition: Debugger.cpp:366
PlatformList m_platform_list
Definition: Debugger.h:623
HostThread m_event_handler_thread
Definition: Debugger.h:651
static lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid)
Definition: Debugger.cpp:759
static llvm::ThreadPool & GetThreadPool()
Shared thread poll. Use only with ThreadPoolTaskGroup.
Definition: Debugger.cpp:2130
uint64_t GetDisassemblyLineCount() const
Definition: Debugger.cpp:501
lldb::TargetSP GetSelectedTarget()
Definition: Debugger.h:188
bool SetExternalEditor(llvm::StringRef editor)
Definition: Debugger.cpp:377
void RequestInterrupt()
Interruption in LLDB:
Definition: Debugger.cpp:1254
StreamFile & GetOutputStream()
Definition: Debugger.h:149
ExecutionContext GetSelectedExecutionContext()
Definition: Debugger.cpp:1022
const std::string m_instance_name
Definition: Debugger.h:647
static void Terminate()
Definition: Debugger.cpp:577
void HandleProgressEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1938
SourceManager & GetSourceManager()
Definition: Debugger.cpp:1597
bool SetShowProgress(bool show_progress)
Definition: Debugger.cpp:401
lldb::StreamSP GetAsyncOutputStream()
Definition: Debugger.cpp:1246
bool StartEventHandlerThread()
Manually start the global event handler thread.
Definition: Debugger.cpp:1884
bool SetUseSourceCache(bool use_source_cache)
Definition: Debugger.cpp:442
void StopEventHandlerThread()
Manually stop the debugger's default event handler.
Definition: Debugger.cpp:1924
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:1495
void SetAsyncExecution(bool async)
Definition: Debugger.cpp:938
HostThread SetIOHandlerThread(HostThread &new_thread)
Definition: Debugger.cpp:2036
SourceManager::SourceFileCache & GetSourceFileCache()
Definition: Debugger.h:600
void CancelForwardEvents(const lldb::ListenerSP &listener_sp)
Definition: Debugger.cpp:1780
bool GetPrintDecls() const
Definition: Debugger.cpp:530
lldb::FileSP GetInputFileSP()
Definition: Debugger.h:137
bool GetHighlightSource() const
Definition: Debugger.cpp:450
llvm::StringMap< std::weak_ptr< LogHandler > > m_stream_handlers
Definition: Debugger.h:645
CommandInterpreter & GetCommandInterpreter()
Definition: Debugger.h:171
LoadedPluginsList m_loaded_plugins
Definition: Debugger.h:650
std::vector< llvm::sys::DynamicLibrary > LoadedPluginsList
Definition: Debugger.h:649
Debugger(const Debugger &)=delete
bool SetTabSize(uint64_t tab_size)
Definition: Debugger.cpp:547
bool IsHandlingEvents() const
Definition: Debugger.h:374
void HandleDiagnosticEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:2023
static lldb::DebuggerSP GetDebuggerAtIndex(size_t index)
Definition: Debugger.cpp:1285
llvm::StringRef GetAutosuggestionAnsiSuffix() const
Definition: Debugger.cpp:430
StreamFile & GetErrorStream()
Definition: Debugger.h:151
lldb::ListenerSP m_listener_sp
Definition: Debugger.h:624
void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Definition: Debugger.cpp:1192
lldb::thread_result_t IOHandlerThread()
Definition: Debugger.cpp:1932
static lldb::TargetSP FindTargetWithProcess(Process *process)
Definition: Debugger.cpp:773
bool GetUseExternalEditor() const
Definition: Debugger.cpp:360
TerminalState m_terminal_state
Definition: Debugger.h:620
static void ReportDiagnosticImpl(DiagnosticEventData::Type type, std::string message, std::optional< lldb::user_id_t > debugger_id, std::once_flag *once)
Definition: Debugger.cpp:1443
const FormatEntity::Entry * GetThreadStopFormat() const
Definition: Debugger.cpp:319
TargetList & GetTargetList()
Get accessor for the target list.
Definition: Debugger.h:201
bool InterruptRequested()
This is the correct way to query the state of Interruption.
Definition: Debugger.cpp:1265
bool GetEscapeNonPrintables() const
Definition: Debugger.cpp:513
lldb::TargetSP m_dummy_target_sp
Definition: Debugger.h:657
std::unique_ptr< CommandInterpreter > m_command_interpreter_up
Definition: Debugger.h:634
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:1481
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:1313
static void SettingsInitialize()
Definition: Debugger.cpp:603
llvm::StringRef GetShowProgressAnsiSuffix() const
Definition: Debugger.cpp:412
bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp)
Definition: Debugger.cpp:1112
bool HasIOHandlerThread() const
Definition: Debugger.cpp:2032
bool IsIOHandlerThreadCurrentThread() const
Definition: Debugger.cpp:2072
lldb::ListenerSP m_forward_listener_sp
Definition: Debugger.h:655
std::array< lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown > m_script_interpreters
Definition: Debugger.h:638
std::shared_ptr< CallbackLogHandler > m_callback_handler_sp
Definition: Debugger.h:646
void SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
Definition: Debugger.cpp:1364
void * m_destroy_callback_baton
Definition: Debugger.h:661
StopDisassemblyType GetStopDisassemblyDisplay() const
Definition: Debugger.cpp:494
Broadcaster m_broadcaster
Public Debugger event broadcaster.
Definition: Debugger.h:654
static void Initialize(LoadPluginCallbackType load_plugin_callback)
Definition: Debugger.cpp:568
static lldb::DebuggerSP FindDebuggerWithInstanceName(llvm::StringRef instance_name)
Definition: Debugger.cpp:744
uint64_t GetTerminalWidth() const
Definition: Debugger.cpp:346
std::mutex m_interrupt_mutex
Definition: Debugger.h:664
std::recursive_mutex m_io_handler_synchronous_mutex
Definition: Debugger.h:641
bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp)
Remove the given IO handler if it's currently active.
Definition: Debugger.cpp:1142
Diagnostics::CallbackID m_diagnostics_callback_id
Definition: Debugger.h:658
void SetPrompt(const char *)=delete
bool GetAutoOneLineSummaries() const
Definition: Debugger.cpp:507
const char * GetIOHandlerCommandPrefix()
Definition: Debugger.cpp:1134
bool GetUseColor() const
Definition: Debugger.cpp:382
lldb::BroadcasterManagerSP m_broadcaster_manager_sp
Definition: Debugger.h:614
void SetCloseInputOnEOF(bool b)
Definition: Debugger.cpp:930
bool GetCloseInputOnEOF() const
Definition: Debugger.cpp:925
Status RunREPL(lldb::LanguageType language, const char *repl_options)
Definition: Debugger.cpp:2086
bool PopIOHandler(const lldb::IOHandlerSP &reader_sp)
Definition: Debugger.cpp:1219
static LoadPluginCallbackType g_load_plugin_callback
Definition: Debugger.h:648
std::recursive_mutex m_script_interpreter_mutex
Definition: Debugger.h:636
ConstString GetTopIOHandlerControlSequence(char ch)
Definition: Debugger.cpp:1130
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
Definition: Debugger.cpp:1146
void SetInputFile(lldb::FileSP file)
Definition: Debugger.cpp:996
lldb::StreamFileSP GetErrorStreamSP()
Definition: Debugger.h:141
void SetPrompt(llvm::StringRef p)
Definition: Debugger.cpp:303
lldb::StreamSP GetAsyncErrorStream()
Definition: Debugger.cpp:1250
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:1530
uint64_t GetStopDisassemblyMaxSize() const
Definition: Debugger.cpp:285
Broadcaster m_sync_broadcaster
Private debugger synchronization.
Definition: Debugger.h:653
void RestoreInputTerminalState()
Definition: Debugger.cpp:1020
bool GetUseSourceCache() const
Definition: Debugger.cpp:436
HostThread m_io_handler_thread
Definition: Debugger.h:652
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:1385
lldb::FileSP m_input_file_sp
Definition: Debugger.h:607
const Broadcaster & GetBroadcaster() const
Definition: Debugger.h:94
bool SetREPLLanguage(lldb::LanguageType repl_lang)
Definition: Debugger.cpp:341
const FormatEntity::Entry * GetDisassemblyFormat() const
Definition: Debugger.cpp:270
bool GetAutoIndent() const
Definition: Debugger.cpp:519
llvm::StringRef GetStopShowColumnAnsiSuffix() const
Definition: Debugger.cpp:469
Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value) override
Definition: Debugger.cpp:200
void SetErrorFile(lldb::FileSP file)
Definition: Debugger.cpp:1009
bool GetAutoConfirm() const
Definition: Debugger.cpp:264
TargetList m_target_list
Definition: Debugger.h:621
lldb::ScriptLanguage GetScriptLanguage() const
Definition: Debugger.cpp:324
std::unique_ptr< SourceManager > m_source_manager_up
Definition: Debugger.h:625
static lldb::DebuggerSP CreateInstance(lldb::LogOutputCallback log_callback=nullptr, void *baton=nullptr)
Definition: Debugger.cpp:695
lldb::StopShowColumn GetStopShowColumn() const
Definition: Debugger.cpp:456
static void ReportSymbolChange(const ModuleSpec &module_spec)
Definition: Debugger.cpp:1502
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:1488
bool SetPrintDecls(bool b)
Definition: Debugger.cpp:536
bool SetScriptLanguage(lldb::ScriptLanguage script_lang)
Definition: Debugger.cpp:331
bool LoadPlugin(const FileSpec &spec, Status &error)
Definition: Debugger.cpp:607
void SetOutputFile(lldb::FileSP file)
Definition: Debugger.cpp:1004
uint64_t GetStopSourceLineCount(bool before) const
Definition: Debugger.cpp:487
void EnableForwardEvents(const lldb::ListenerSP &listener_sp)
Definition: Debugger.cpp:1776
@ eBroadcastBitEventThreadIsListening
Definition: Debugger.h:668
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id)
Definition: Debugger.cpp:1297
void HandleBreakpointEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1604
static ConstString GetStaticBroadcasterClass()
Definition: Debugger.cpp:787
bool CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
Definition: Debugger.cpp:1116
PlatformList & GetPlatformList()
Definition: Debugger.h:203
Target & GetDummyTarget()
Definition: Debugger.h:424
const FormatEntity::Entry * GetFrameFormat() const
Definition: Debugger.cpp:275
lldb::ListenerSP GetListener()
Definition: Debugger.h:180
static void Destroy(lldb::DebuggerSP &debugger_sp)
Definition: Debugger.cpp:713
SourceManager::SourceFileCache m_source_file_cache
Definition: Debugger.h:629
std::optional< uint64_t > m_current_event_id
Definition: Debugger.h:643
void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp)
Run the given IO handler and block until it's complete.
Definition: Debugger.cpp:1078
const FormatEntity::Entry * GetThreadFormat() const
Definition: Debugger.cpp:314
Broadcaster & GetBroadcaster()
Get the public broadcaster for this debugger.
Definition: Debugger.h:93
llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const
Definition: Debugger.cpp:475
uint64_t GetTabSize() const
Definition: Debugger.cpp:541
lldb::StreamFileSP m_output_stream_sp
Definition: Debugger.h:608
bool GetShowProgress() const
Definition: Debugger.cpp:395
std::mutex m_output_flush_mutex
Definition: Debugger.h:598
llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const
Definition: Debugger.cpp:481
void PrintProgress(const ProgressEventData &data)
bool SetUseColor(bool use_color)
Definition: Debugger.cpp:388
lldb_private::DebuggerDestroyCallback m_destroy_callback
Definition: Debugger.h:660
const char * GetIOHandlerHelpPrologue()
Definition: Debugger.cpp:1138
Status SetInputString(const char *data)
Definition: Debugger.cpp:953
bool GetUseAutosuggestion() const
Definition: Debugger.cpp:418
Target & GetSelectedOrDummyTarget(bool prefer_dummy=false)
Definition: Debugger.cpp:2078
void HandleProcessEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1671
IOHandlerStack m_io_handler_stack
Definition: Debugger.h:640
repro::DataRecorder * m_input_recorder
Used for shadowing the input file when capturing a reproducer.
Definition: Debugger.h:612
lldb::StreamFileSP GetOutputStreamSP()
Definition: Debugger.h:139
llvm::once_flag m_clear_once
Definition: Debugger.h:656
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::StreamFileSP &out, lldb::StreamFileSP &err)
Definition: Debugger.cpp:1151
static void SettingsTerminate()
Definition: Debugger.cpp:605
lldb::LanguageType GetREPLLanguage() const
Definition: Debugger.cpp:336
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1581
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton)
Definition: Debugger.cpp:1355
bool SetTerminalWidth(uint64_t term_width)
Definition: Debugger.cpp:352
llvm::StringRef GetExternalEditor() const
Definition: Debugger.cpp:371
void HandleThreadEvent(const lldb::EventSP &event_sp)
Definition: Debugger.cpp:1758
static size_t GetNumDebuggers()
Definition: Debugger.cpp:1277
File & GetOutputFile()
Definition: Debugger.h:145
uint32_t m_interrupt_requested
Tracks interrupt requests.
Definition: Debugger.h:663
lldb::DWIMPrintVerbosity GetDWIMPrintVerbosity() const
Definition: Debugger.cpp:552
const std::string & GetInstanceName()
Definition: Debugger.h:362
lldb::BroadcasterManagerSP GetBroadcasterManager()
Definition: Debugger.h:426
lldb::thread_result_t DefaultEventHandler()
Definition: Debugger.cpp:1784
void PrintAsync(const char *s, size_t len, bool is_stdout)
Definition: Debugger.cpp:1121
llvm::StringRef GetPrompt() const
Definition: Debugger.cpp:297
bool GetNotifyVoid() const
Definition: Debugger.cpp:291
llvm::StringRef GetShowProgressAnsiPrefix() const
Definition: Debugger.cpp:406
const FormatEntity::Entry * GetFrameFormatUnique() const
Definition: Debugger.cpp:280
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:1651
void CancelInterruptRequest()
Decrement the "interrupt requested" counter.
Definition: Debugger.cpp:1259
bool SetAutoIndent(bool b)
Definition: Debugger.cpp:525
const Debugger & operator=(const Debugger &)=delete
llvm::StringRef GetStopShowColumnAnsiPrefix() const
Definition: Debugger.cpp:463
"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:335
A Progress indicator helper class.
Definition: Progress.h:56
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:537
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
VarSetOperationType
Settable state variable types.
ScriptLanguage
Script interpreter types.
void * thread_result_t
Definition: lldb-types.h:62
DWIMPrintVerbosity
Enum to control the verbosity level of dwim-print execution.
LanguageType
Programming language type.
uint64_t pid_t
Definition: lldb-types.h:81
uint64_t user_id_t
Definition: lldb-types.h:80
void(* LogOutputCallback)(const char *, void *baton)
Definition: lldb-types.h:72
Definition: Debugger.h:52
A mix in class that contains a generic user ID.
Definition: UserID.h:31