LLDB mainline
CommandReturnObject.h
Go to the documentation of this file.
1//===-- CommandReturnObject.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_INTERPRETER_COMMANDRETURNOBJECT_H
10#define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
11
15#include "lldb/lldb-private.h"
16
17#include "llvm/ADT/StringRef.h"
18#include "llvm/Support/Error.h"
19#include "llvm/Support/FormatVariadic.h"
20#include "llvm/Support/WithColor.h"
21
22#include <memory>
23
24namespace lldb_private {
25
27public:
28 CommandReturnObject(bool colors);
29
31
32 llvm::StringRef GetOutputData() {
34 if (stream_sp)
35 return std::static_pointer_cast<StreamString>(stream_sp)->GetString();
36 return llvm::StringRef();
37 }
38
39 llvm::StringRef GetErrorData() {
41 if (stream_sp)
42 return std::static_pointer_cast<StreamString>(stream_sp)->GetString();
43 return llvm::StringRef();
44 }
45
47 // Make sure we at least have our normal string stream output stream
49 if (!stream_sp) {
50 stream_sp = std::make_shared<StreamString>();
52 }
53 return m_out_stream;
54 }
55
57 // Make sure we at least have our normal string stream output stream
59 if (!stream_sp) {
60 stream_sp = std::make_shared<StreamString>();
62 }
63 return m_err_stream;
64 }
65
68 return;
69 lldb::StreamSP stream_sp(new StreamFile(file_sp));
71 }
72
75 return;
76 lldb::StreamSP stream_sp(new StreamFile(file_sp));
78 }
79
82 return;
84 }
85
86 void SetImmediateErrorStream(const lldb::StreamSP &stream_sp) {
88 return;
90 }
91
94 }
95
98 }
99
100 void Clear();
101
102 void AppendMessage(llvm::StringRef in_string);
103
104 void AppendMessageWithFormat(const char *format, ...)
105 __attribute__((format(printf, 2, 3)));
106
107 void AppendWarning(llvm::StringRef in_string);
108
109 void AppendWarningWithFormat(const char *format, ...)
110 __attribute__((format(printf, 2, 3)));
111
112 void AppendError(llvm::StringRef in_string);
113
114 void AppendRawError(llvm::StringRef in_string);
115
116 void AppendErrorWithFormat(const char *format, ...)
117 __attribute__((format(printf, 2, 3)));
118
119 template <typename... Args>
120 void AppendMessageWithFormatv(const char *format, Args &&... args) {
121 AppendMessage(llvm::formatv(format, std::forward<Args>(args)...).str());
122 }
123
124 template <typename... Args>
125 void AppendWarningWithFormatv(const char *format, Args &&... args) {
126 AppendWarning(llvm::formatv(format, std::forward<Args>(args)...).str());
127 }
128
129 template <typename... Args>
130 void AppendErrorWithFormatv(const char *format, Args &&... args) {
131 AppendError(llvm::formatv(format, std::forward<Args>(args)...).str());
132 }
133
134 void SetError(const Status &error, const char *fallback_error_cstr = nullptr);
135
136 void SetError(llvm::Error error);
137
139
140 void SetStatus(lldb::ReturnStatus status);
141
142 bool Succeeded() const;
143
144 bool HasResult() const;
145
146 bool GetDidChangeProcessState() const;
147
148 void SetDidChangeProcessState(bool b);
149
150 bool GetInteractive() const;
151
152 void SetInteractive(bool b);
153
154 bool GetSuppressImmediateOutput() const;
155
156 void SetSuppressImmediateOutput(bool b);
157
158private:
160
163
165
168
169 /// If true, then the input handle from the debugger will be hooked up.
170 bool m_interactive = true;
171};
172
173} // namespace lldb_private
174
175#endif // LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
static llvm::raw_ostream & error(Stream &strm)
A command line argument class.
Definition: Args.h:33
void AppendErrorWithFormatv(const char *format, Args &&... args)
void AppendMessage(llvm::StringRef in_string)
void SetImmediateErrorStream(const lldb::StreamSP &stream_sp)
void SetImmediateErrorFile(lldb::FileSP file_sp)
void void AppendError(llvm::StringRef in_string)
void AppendWarningWithFormat(const char *format,...) __attribute__((format(printf
bool m_interactive
If true, then the input handle from the debugger will be hooked up.
void AppendWarningWithFormatv(const char *format, Args &&... args)
void AppendRawError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
void void AppendMessageWithFormatv(const char *format, Args &&... args)
void SetImmediateOutputStream(const lldb::StreamSP &stream_sp)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
lldb::ReturnStatus GetStatus() const
void SetImmediateOutputFile(lldb::FileSP file_sp)
void void AppendWarning(llvm::StringRef in_string)
void SetError(const Status &error, const char *fallback_error_cstr=nullptr)
An error handling class.
Definition: Status.h:44
void SetStreamAtIndex(uint32_t idx, const lldb::StreamSP &stream_sp)
Definition: StreamTee.h:96
lldb::StreamSP GetStreamAtIndex(uint32_t idx)
Definition: StreamTee.h:88
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
std::shared_ptr< lldb_private::Stream > StreamSP
Definition: lldb-forward.h:420
ReturnStatus
Command Return Status Types.
@ eReturnStatusStarted
std::shared_ptr< lldb_private::File > FileSP
Definition: lldb-forward.h:345
Definition: Debugger.h:53