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 {
22namespace python {
23class SWIGBridge;
24}
25} // namespace lldb_private
26
27namespace lldb {
28
30public:
32
33 // rvalue ctor+assignment are incompatible with Reproducers.
34
36
38
41
42 explicit operator bool() const;
43
44 bool IsValid() const;
45
46 /// Get the command as the user typed it. Empty string if commands were run on
47 /// behalf of lldb.
48 const char *GetCommand();
49
50 const char *GetOutput();
51
52 const char *GetError();
54
55#ifndef SWIG
56 LLDB_DEPRECATED_FIXME("Use PutOutput(SBFile) or PutOutput(FileSP)",
57 "PutOutput(SBFile)")
58 size_t PutOutput(FILE *fh);
59#endif
60
61 size_t PutOutput(SBFile file);
62
63 size_t PutOutput(FileSP BORROWED);
64
65 size_t GetOutputSize();
66
67 size_t GetErrorSize();
68
69#ifndef SWIG
70 LLDB_DEPRECATED_FIXME("Use PutError(SBFile) or PutError(FileSP)",
71 "PutError(SBFile)")
72 size_t PutError(FILE *fh);
73#endif
74
75 size_t PutError(SBFile file);
76
77 size_t PutError(FileSP BORROWED);
78
79 void Clear();
80
82
83 void SetStatus(lldb::ReturnStatus status);
84
85 bool Succeeded();
86
87 bool HasResult();
88
89 void AppendMessage(const char *message);
90
91 void AppendWarning(const char *message);
92
93 bool GetDescription(lldb::SBStream &description);
94
95#ifndef SWIG
97 "Use SetImmediateOutputFile(SBFile) or SetImmediateOutputFile(FileSP)",
98 "SetImmediateOutputFile(SBFile)")
99 void SetImmediateOutputFile(FILE *fh);
100
102 "Use SetImmediateErrorFile(SBFile) or SetImmediateErrorFile(FileSP)",
103 "SetImmediateErrorFile(SBFile)")
104 void SetImmediateErrorFile(FILE *fh);
105
107 "Use SetImmediateOutputFile(SBFile) or SetImmediateOutputFile(FileSP)",
108 "SetImmediateOutputFile(SBFile)")
110
112 "Use SetImmediateErrorFile(SBFile) or SetImmediateErrorFile(FileSP)",
113 "SetImmediateErrorFile(SBFile)")
114 void SetImmediateErrorFile(FILE *fh, bool transfer_ownership);
115#endif
116
118
119 void SetImmediateErrorFile(SBFile file);
120
121 void SetImmediateOutputFile(FileSP BORROWED);
122
123 void SetImmediateErrorFile(FileSP BORROWED);
124
125 void PutCString(const char *string, int len = -1);
126
127#ifndef SWIG
128 __attribute__((format(printf, 2, 3))) size_t Printf(const char *format, ...);
129#endif
130
131 const char *GetOutput(bool only_if_no_immediate);
132
133 const char *GetError(bool only_if_no_immediate);
134
136 const char *fallback_error_cstr = nullptr);
137
138 void SetError(const char *error_cstr);
139
141
142protected:
144 friend class SBOptions;
145
149
151
153
155
157
158private:
160
161 std::unique_ptr<lldb_private::SBCommandReturnObjectImpl> m_opaque_up;
162};
163
164} // namespace lldb
165
166#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