LLDB mainline
SBCommandReturnObject.h
Go to the documentation of this file.
1//===-- SBCommandReturnObject.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_API_SBCOMMANDRETURNOBJECT_H
10#define LLDB_API_SBCOMMANDRETURNOBJECT_H
11
12#include <cstdio>
13
14#include <memory>
15
16#include "lldb/API/SBDefines.h"
17
18namespace lldb_private {
21namespace python {
22class SWIGBridge;
23}
24} // namespace lldb_private
25
26namespace lldb {
27
29public:
31
32 // rvalue ctor+assignment are incompatible with Reproducers.
33
35
37
40
41 explicit operator bool() const;
42
43 bool IsValid() const;
44
45 /// Get the command as the user typed it. Empty string if commands were run on
46 /// behalf of lldb.
47 const char *GetCommand();
48
49 const char *GetOutput();
50
51 const char *GetError();
53
54#ifndef SWIG
55 LLDB_DEPRECATED_FIXME("Use PutOutput(SBFile) or PutOutput(FileSP)",
56 "PutOutput(SBFile)")
57 size_t PutOutput(FILE *fh);
58#endif
59
60 size_t PutOutput(SBFile file);
61
62 size_t PutOutput(FileSP BORROWED);
63
64 size_t GetOutputSize();
65
66 size_t GetErrorSize();
67
68#ifndef SWIG
69 LLDB_DEPRECATED_FIXME("Use PutError(SBFile) or PutError(FileSP)",
70 "PutError(SBFile)")
71 size_t PutError(FILE *fh);
72#endif
73
74 size_t PutError(SBFile file);
75
76 size_t PutError(FileSP BORROWED);
77
78 void Clear();
79
81
82 void SetStatus(lldb::ReturnStatus status);
83
84 bool Succeeded();
85
86 bool HasResult();
87
88 void AppendMessage(const char *message);
89
90 void AppendWarning(const char *message);
91
92 bool GetDescription(lldb::SBStream &description);
93
94#ifndef SWIG
96 "Use SetImmediateOutputFile(SBFile) or SetImmediateOutputFile(FileSP)",
97 "SetImmediateOutputFile(SBFile)")
98 void SetImmediateOutputFile(FILE *fh);
99
101 "Use SetImmediateErrorFile(SBFile) or SetImmediateErrorFile(FileSP)",
102 "SetImmediateErrorFile(SBFile)")
103 void SetImmediateErrorFile(FILE *fh);
104
106 "Use SetImmediateOutputFile(SBFile) or SetImmediateOutputFile(FileSP)",
107 "SetImmediateOutputFile(SBFile)")
109
111 "Use SetImmediateErrorFile(SBFile) or SetImmediateErrorFile(FileSP)",
112 "SetImmediateErrorFile(SBFile)")
113 void SetImmediateErrorFile(FILE *fh, bool transfer_ownership);
114#endif
115
117
118 void SetImmediateErrorFile(SBFile file);
119
120 void SetImmediateOutputFile(FileSP BORROWED);
121
122 void SetImmediateErrorFile(FileSP BORROWED);
123
124 void PutCString(const char *string, int len = -1);
125
126#ifndef SWIG
127 __attribute__((format(printf, 2, 3))) size_t Printf(const char *format, ...);
128#endif
129
130 const char *GetOutput(bool only_if_no_immediate);
131
132 const char *GetError(bool only_if_no_immediate);
133
135 const char *fallback_error_cstr = nullptr);
136
137 void SetError(const char *error_cstr);
138
140
141protected:
143 friend class SBOptions;
144
146 friend class lldb_private::python::SWIGBridge;
147
149
151
153
155
156private:
158
159 std::unique_ptr<lldb_private::SBCommandReturnObjectImpl> m_opaque_up;
160};
161
162} // namespace lldb
163
164#endif // LLDB_API_SBCOMMANDRETURNOBJECT_H
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_API
Definition SBDefines.h:28
lldb_private::CommandReturnObject * get() const
lldb_private::CommandReturnObject & operator*() const
void SetStatus(lldb::ReturnStatus status)
bool GetDescription(lldb::SBStream &description)
LLDB_DEPRECATED_FIXME("Use PutOutput(SBFile) or PutOutput(FileSP)", "PutOutput(SBFile)") size_t PutOutput(FILE *fh)
lldb_private::CommandReturnObject * operator->() const
lldb::SBCommandReturnObject & operator=(const lldb::SBCommandReturnObject &rhs)
void SetError(lldb::SBError &error, const char *fallback_error_cstr=nullptr)
LLDB_DEPRECATED_FIXME("Use SetImmediateOutputFile(SBFile) or SetImmediateOutputFile(FileSP)", "SetImmediateOutputFile(SBFile)") void SetImmediateOutputFile(FILE *fh)
void AppendMessage(const char *message)
LLDB_DEPRECATED_FIXME("Use PutError(SBFile) or PutError(FileSP)", "PutError(SBFile)") size_t PutError(FILE *fh)
lldb_private::CommandReturnObject & ref() const
lldb::SBValueList GetValues(lldb::DynamicValueType use_dynamic)
const char * GetCommand()
Get the command as the user typed it.
void AppendWarning(const char *message)
void PutCString(const char *string, int len=-1)
std::unique_ptr< lldb_private::SBCommandReturnObjectImpl > m_opaque_up
__attribute__((format(printf, 2, 3))) size_t Printf(const char *format
A class that represents a running process on the host machine.
ReturnStatus
Command Return Status Types.
std::shared_ptr< lldb_private::File > FileSP