1 //===-- CommandReturnObject.h -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_CommandReturnObject_h_
11 #define liblldb_CommandReturnObject_h_
15 // Other libraries and framework includes
17 #include "lldb/lldb-private.h"
18 #include "lldb/Core/STLUtils.h"
19 #include "lldb/Core/StreamFile.h"
20 #include "lldb/Core/StreamString.h"
21 #include "lldb/Core/StreamTee.h"
23 namespace lldb_private {
25 class CommandReturnObject
28 CommandReturnObject ();
30 ~CommandReturnObject ();
35 lldb::StreamSP stream_sp (m_out_stream.GetStreamAtIndex (eStreamStringIndex));
37 return static_cast<StreamString *>(stream_sp.get())->GetData();
44 lldb::StreamSP stream_sp (m_err_stream.GetStreamAtIndex (eStreamStringIndex));
46 return static_cast<StreamString *>(stream_sp.get())->GetData();
54 // Make sure we at least have our normal string stream output stream
55 lldb::StreamSP stream_sp (m_out_stream.GetStreamAtIndex (eStreamStringIndex));
58 stream_sp.reset (new StreamString());
59 m_out_stream.SetStreamAtIndex (eStreamStringIndex, stream_sp);
67 // Make sure we at least have our normal string stream output stream
68 lldb::StreamSP stream_sp (m_err_stream.GetStreamAtIndex (eStreamStringIndex));
71 stream_sp.reset (new StreamString());
72 m_err_stream.SetStreamAtIndex (eStreamStringIndex, stream_sp);
78 SetImmediateOutputFile (FILE *fh, bool transfer_fh_ownership = false)
80 lldb::StreamSP stream_sp (new StreamFile (fh, transfer_fh_ownership));
81 m_out_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp);
85 SetImmediateErrorFile (FILE *fh, bool transfer_fh_ownership = false)
87 lldb::StreamSP stream_sp (new StreamFile (fh, transfer_fh_ownership));
88 m_err_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp);
92 SetImmediateOutputStream (const lldb::StreamSP &stream_sp)
94 m_out_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp);
98 SetImmediateErrorStream (const lldb::StreamSP &stream_sp)
100 m_err_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp);
104 GetImmediateOutputStream ()
106 return m_out_stream.GetStreamAtIndex (eImmediateStreamIndex);
110 GetImmediateErrorStream ()
112 return m_err_stream.GetStreamAtIndex (eImmediateStreamIndex);
119 AppendMessage (const char *in_string);
122 AppendMessageWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
125 AppendRawWarning (const char *in_string);
128 AppendWarning (const char *in_string);
131 AppendWarningWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
134 AppendError (const char *in_string);
137 AppendRawError (const char *in_string);
140 AppendErrorWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
143 SetError(const Error &error,
144 const char *fallback_error_cstr = nullptr);
147 SetError (const char *error_cstr);
153 SetStatus (lldb::ReturnStatus status);
162 GetDidChangeProcessState ();
165 SetDidChangeProcessState (bool b);
168 GetInteractive () const;
171 SetInteractive (bool b);
174 GetAbnormalStopWasExpected() const
176 return m_abnormal_stop_was_expected;
180 SetAbnormalStopWasExpected(bool signal_was_expected)
182 m_abnormal_stop_was_expected = signal_was_expected;
188 eStreamStringIndex = 0,
189 eImmediateStreamIndex = 1
192 StreamTee m_out_stream;
193 StreamTee m_err_stream;
195 lldb::ReturnStatus m_status;
196 bool m_did_change_process_state;
197 bool m_interactive; // If true, then the input handle from the debugger will be hooked up
198 bool m_abnormal_stop_was_expected; // This is to support eHandleCommandFlagStopOnCrash vrs. attach.
199 // The attach command often ends up with the process stopped due to a signal.
200 // Normally that would mean stop on crash should halt batch execution, but we
201 // obviously don't want that for attach. Using this flag, the attach command
202 // (and anything else for which this is relevant) can say that the signal is
203 // expected, and batch command execution can continue.
206 } // namespace lldb_private
208 #endif // liblldb_CommandReturnObject_h_