[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- SBCommandReturnObject.cpp -----------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBCommandReturnObject.h"
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2019-03-06 08:05:55 +08:00
|
|
|
#include "Utils.h"
|
2013-07-10 04:14:26 +08:00
|
|
|
#include "lldb/API/SBError.h"
|
2019-10-10 05:50:49 +08:00
|
|
|
#include "lldb/API/SBFile.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
2017-02-27 20:21:16 +08:00
|
|
|
#include "lldb/Utility/ConstString.h"
|
2017-05-12 12:51:55 +08:00
|
|
|
#include "lldb/Utility/Status.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
2010-06-23 09:19:29 +08:00
|
|
|
using namespace lldb_private;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
class lldb_private::SBCommandReturnObjectImpl {
|
|
|
|
public:
|
2020-06-10 01:21:09 +08:00
|
|
|
SBCommandReturnObjectImpl() : m_ptr(new CommandReturnObject(false)) {}
|
2019-10-05 03:32:57 +08:00
|
|
|
SBCommandReturnObjectImpl(CommandReturnObject &ref)
|
|
|
|
: m_ptr(&ref), m_owned(false) {}
|
|
|
|
SBCommandReturnObjectImpl(const SBCommandReturnObjectImpl &rhs)
|
|
|
|
: m_ptr(new CommandReturnObject(*rhs.m_ptr)), m_owned(rhs.m_owned) {}
|
|
|
|
SBCommandReturnObjectImpl &operator=(const SBCommandReturnObjectImpl &rhs) {
|
|
|
|
SBCommandReturnObjectImpl copy(rhs);
|
|
|
|
std::swap(*this, copy);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
// rvalue ctor+assignment are not used by SBCommandReturnObject.
|
|
|
|
~SBCommandReturnObjectImpl() {
|
|
|
|
if (m_owned)
|
|
|
|
delete m_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
CommandReturnObject &operator*() const { return *m_ptr; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
CommandReturnObject *m_ptr;
|
|
|
|
bool m_owned = true;
|
|
|
|
};
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBCommandReturnObject::SBCommandReturnObject()
|
2019-10-05 03:32:57 +08:00
|
|
|
: m_opaque_up(new SBCommandReturnObjectImpl()) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandReturnObject);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
SBCommandReturnObject::SBCommandReturnObject(CommandReturnObject &ref)
|
|
|
|
: m_opaque_up(new SBCommandReturnObjectImpl(ref)) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject,
|
|
|
|
(lldb_private::CommandReturnObject &), ref);
|
|
|
|
}
|
|
|
|
|
2010-11-06 07:17:00 +08:00
|
|
|
SBCommandReturnObject::SBCommandReturnObject(const SBCommandReturnObject &rhs)
|
2019-02-13 14:25:41 +08:00
|
|
|
: m_opaque_up() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject,
|
|
|
|
(const lldb::SBCommandReturnObject &), rhs);
|
|
|
|
|
2019-03-06 08:05:55 +08:00
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2010-11-06 07:17:00 +08:00
|
|
|
}
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
SBCommandReturnObject &SBCommandReturnObject::
|
2010-11-06 07:17:00 +08:00
|
|
|
operator=(const SBCommandReturnObject &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(
|
2019-10-05 03:32:57 +08:00
|
|
|
lldb::SBCommandReturnObject &,
|
2019-03-06 08:06:00 +08:00
|
|
|
SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &),
|
|
|
|
rhs);
|
|
|
|
|
2019-03-06 08:05:55 +08:00
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2019-04-04 05:31:22 +08:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2010-11-06 07:17:00 +08:00
|
|
|
}
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
SBCommandReturnObject::~SBCommandReturnObject() = default;
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
bool SBCommandReturnObject::IsValid() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, IsValid);
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 21:58:46 +08:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBCommandReturnObject::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2019-09-26 21:31:59 +08:00
|
|
|
// This method is not useful but it needs to stay to keep SB API stable.
|
|
|
|
return true;
|
2019-03-06 08:06:00 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
const char *SBCommandReturnObject::GetOutput() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetOutput);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
ConstString output(ref().GetOutputData());
|
2019-09-26 21:31:59 +08:00
|
|
|
return output.AsCString(/*value_if_empty*/ "");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBCommandReturnObject::GetError() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetError);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
ConstString output(ref().GetErrorData());
|
2019-09-26 21:31:59 +08:00
|
|
|
return output.AsCString(/*value_if_empty*/ "");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
size_t SBCommandReturnObject::GetOutputSize() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetOutputSize);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
return ref().GetOutputData().size();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
size_t SBCommandReturnObject::GetErrorSize() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetErrorSize);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
return ref().GetErrorData().size();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t SBCommandReturnObject::PutOutput(FILE *fh) {
|
2019-10-17 09:28:07 +08:00
|
|
|
LLDB_RECORD_DUMMY(size_t, SBCommandReturnObject, PutOutput, (FILE *), fh);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (fh) {
|
|
|
|
size_t num_bytes = GetOutputSize();
|
|
|
|
if (num_bytes)
|
|
|
|
return ::fprintf(fh, "%s", GetOutput());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-10 05:50:49 +08:00
|
|
|
size_t SBCommandReturnObject::PutOutput(FileSP file_sp) {
|
|
|
|
LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (FileSP),
|
|
|
|
file_sp);
|
|
|
|
if (!file_sp)
|
|
|
|
return 0;
|
|
|
|
return file_sp->Printf("%s", GetOutput());
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SBCommandReturnObject::PutOutput(SBFile file) {
|
|
|
|
LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (SBFile), file);
|
|
|
|
if (!file.m_opaque_sp)
|
|
|
|
return 0;
|
|
|
|
return file.m_opaque_sp->Printf("%s", GetOutput());
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t SBCommandReturnObject::PutError(FILE *fh) {
|
2019-10-17 09:28:07 +08:00
|
|
|
LLDB_RECORD_DUMMY(size_t, SBCommandReturnObject, PutError, (FILE *), fh);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (fh) {
|
|
|
|
size_t num_bytes = GetErrorSize();
|
|
|
|
if (num_bytes)
|
|
|
|
return ::fprintf(fh, "%s", GetError());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-10 05:50:49 +08:00
|
|
|
size_t SBCommandReturnObject::PutError(FileSP file_sp) {
|
|
|
|
LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutError, (FileSP),
|
|
|
|
file_sp);
|
|
|
|
if (!file_sp)
|
|
|
|
return 0;
|
|
|
|
return file_sp->Printf("%s", GetError());
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SBCommandReturnObject::PutError(SBFile file) {
|
|
|
|
LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutError, (SBFile), file);
|
|
|
|
if (!file.m_opaque_sp)
|
|
|
|
return 0;
|
|
|
|
return file.m_opaque_sp->Printf("%s", GetError());
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void SBCommandReturnObject::Clear() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBCommandReturnObject, Clear);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
ref().Clear();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::ReturnStatus SBCommandReturnObject::GetStatus() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::ReturnStatus, SBCommandReturnObject,
|
|
|
|
GetStatus);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
return ref().GetStatus();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-06-28 01:25:36 +08:00
|
|
|
void SBCommandReturnObject::SetStatus(lldb::ReturnStatus status) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetStatus,
|
|
|
|
(lldb::ReturnStatus), status);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
ref().SetStatus(status);
|
2012-06-28 01:25:36 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
bool SBCommandReturnObject::Succeeded() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, Succeeded);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
return ref().Succeeded();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
bool SBCommandReturnObject::HasResult() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, HasResult);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
return ref().HasResult();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBCommandReturnObject::AppendMessage(const char *message) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendMessage, (const char *),
|
|
|
|
message);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
ref().AppendMessage(message);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-09-29 07:57:51 +08:00
|
|
|
void SBCommandReturnObject::AppendWarning(const char *message) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendWarning, (const char *),
|
|
|
|
message);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
ref().AppendWarning(message);
|
2012-09-29 07:57:51 +08:00
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
CommandReturnObject *SBCommandReturnObject::operator->() const {
|
2019-10-05 03:32:57 +08:00
|
|
|
return &**m_opaque_up;
|
2010-06-23 09:19:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CommandReturnObject *SBCommandReturnObject::get() const {
|
2019-10-05 03:32:57 +08:00
|
|
|
return &**m_opaque_up;
|
2010-06-23 09:19:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CommandReturnObject &SBCommandReturnObject::operator*() const {
|
2019-10-05 03:32:57 +08:00
|
|
|
return **m_opaque_up;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
CommandReturnObject &SBCommandReturnObject::ref() const {
|
2019-10-05 03:32:57 +08:00
|
|
|
return **m_opaque_up;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool SBCommandReturnObject::GetDescription(SBStream &description) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBCommandReturnObject, GetDescription,
|
|
|
|
(lldb::SBStream &), description);
|
|
|
|
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
|
|
|
|
2019-09-26 21:31:59 +08:00
|
|
|
description.Printf("Error: ");
|
2019-10-05 03:32:57 +08:00
|
|
|
lldb::ReturnStatus status = ref().GetStatus();
|
2019-09-26 21:31:59 +08:00
|
|
|
if (status == lldb::eReturnStatusStarted)
|
|
|
|
strm.PutCString("Started");
|
|
|
|
else if (status == lldb::eReturnStatusInvalid)
|
|
|
|
strm.PutCString("Invalid");
|
2019-10-05 03:32:57 +08:00
|
|
|
else if (ref().Succeeded())
|
2019-09-26 21:31:59 +08:00
|
|
|
strm.PutCString("Success");
|
|
|
|
else
|
|
|
|
strm.PutCString("Fail");
|
|
|
|
|
|
|
|
if (GetOutputSize() > 0)
|
|
|
|
strm.Printf("\nOutput Message:\n%s", GetOutput());
|
|
|
|
|
|
|
|
if (GetErrorSize() > 0)
|
|
|
|
strm.Printf("\nError Message:\n%s", GetError());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-26 07:40:32 +08:00
|
|
|
return true;
|
2012-12-15 10:40:54 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-17 04:57:12 +08:00
|
|
|
void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh) {
|
2019-10-17 09:28:07 +08:00
|
|
|
LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateOutputFile,
|
|
|
|
(FILE *), fh);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
SetImmediateOutputFile(fh, false);
|
2012-10-17 04:57:12 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh) {
|
2019-10-17 09:28:07 +08:00
|
|
|
LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateErrorFile,
|
|
|
|
(FILE *), fh);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2016-03-26 07:40:32 +08:00
|
|
|
SetImmediateErrorFile(fh, false);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-03-26 07:40:32 +08:00
|
|
|
void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh,
|
|
|
|
bool transfer_ownership) {
|
2019-10-17 09:28:07 +08:00
|
|
|
LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateOutputFile,
|
|
|
|
(FILE *, bool), fh, transfer_ownership);
|
2019-10-10 05:50:49 +08:00
|
|
|
FileSP file = std::make_shared<NativeFile>(fh, transfer_ownership);
|
|
|
|
ref().SetImmediateOutputFile(file);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh,
|
2016-03-26 07:40:32 +08:00
|
|
|
bool transfer_ownership) {
|
2019-10-17 09:28:07 +08:00
|
|
|
LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateErrorFile,
|
|
|
|
(FILE *, bool), fh, transfer_ownership);
|
2019-10-10 05:50:49 +08:00
|
|
|
FileSP file = std::make_shared<NativeFile>(fh, transfer_ownership);
|
|
|
|
ref().SetImmediateErrorFile(file);
|
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2019-10-10 05:50:49 +08:00
|
|
|
void SBCommandReturnObject::SetImmediateOutputFile(SBFile file) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
|
|
|
|
(SBFile), file);
|
|
|
|
ref().SetImmediateOutputFile(file.m_opaque_sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBCommandReturnObject::SetImmediateErrorFile(SBFile file) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
|
|
|
|
(SBFile), file);
|
|
|
|
ref().SetImmediateErrorFile(file.m_opaque_sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBCommandReturnObject::SetImmediateOutputFile(FileSP file_sp) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
|
|
|
|
(FileSP), file_sp);
|
|
|
|
SetImmediateOutputFile(SBFile(file_sp));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBCommandReturnObject::SetImmediateErrorFile(FileSP file_sp) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
|
|
|
|
(FileSP), file_sp);
|
|
|
|
SetImmediateErrorFile(SBFile(file_sp));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-10-17 04:57:12 +08:00
|
|
|
void SBCommandReturnObject::PutCString(const char *string, int len) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, PutCString,
|
|
|
|
(const char *, int), string, len);
|
|
|
|
|
2019-09-26 21:31:59 +08:00
|
|
|
if (len == 0 || string == nullptr || *string == 0) {
|
|
|
|
return;
|
|
|
|
} else if (len > 0) {
|
|
|
|
std::string buffer(string, len);
|
2019-10-05 03:32:57 +08:00
|
|
|
ref().AppendMessage(buffer.c_str());
|
2019-09-26 21:31:59 +08:00
|
|
|
} else
|
2019-10-05 03:32:57 +08:00
|
|
|
ref().AppendMessage(string);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-10-17 04:57:12 +08:00
|
|
|
const char *SBCommandReturnObject::GetOutput(bool only_if_no_immediate) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetOutput, (bool),
|
|
|
|
only_if_no_immediate);
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
if (!only_if_no_immediate ||
|
2019-10-05 03:32:57 +08:00
|
|
|
ref().GetImmediateOutputStream().get() == nullptr)
|
2012-10-17 04:57:12 +08:00
|
|
|
return GetOutput();
|
2015-10-31 09:22:59 +08:00
|
|
|
return nullptr;
|
2012-10-17 04:57:12 +08:00
|
|
|
}
|
|
|
|
|
2011-08-17 07:24:13 +08:00
|
|
|
const char *SBCommandReturnObject::GetError(bool only_if_no_immediate) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetError, (bool),
|
|
|
|
only_if_no_immediate);
|
|
|
|
|
2019-10-05 03:32:57 +08:00
|
|
|
if (!only_if_no_immediate || ref().GetImmediateErrorStream().get() == nullptr)
|
2012-10-17 04:57:12 +08:00
|
|
|
return GetError();
|
2015-10-31 09:22:59 +08:00
|
|
|
return nullptr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-08-17 07:24:13 +08:00
|
|
|
size_t SBCommandReturnObject::Printf(const char *format, ...) {
|
2019-09-26 21:31:59 +08:00
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
2019-10-05 03:32:57 +08:00
|
|
|
size_t result = ref().GetOutputStream().PrintfVarArg(format, args);
|
2019-09-26 21:31:59 +08:00
|
|
|
va_end(args);
|
|
|
|
return result;
|
2011-08-17 07:24:13 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-07-10 04:14:26 +08:00
|
|
|
void SBCommandReturnObject::SetError(lldb::SBError &error,
|
|
|
|
const char *fallback_error_cstr) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError,
|
|
|
|
(lldb::SBError &, const char *), error,
|
|
|
|
fallback_error_cstr);
|
|
|
|
|
2019-09-26 21:31:59 +08:00
|
|
|
if (error.IsValid())
|
2019-10-05 03:32:57 +08:00
|
|
|
ref().SetError(error.ref(), fallback_error_cstr);
|
2019-09-26 21:31:59 +08:00
|
|
|
else if (fallback_error_cstr)
|
2019-10-05 03:32:57 +08:00
|
|
|
ref().SetError(Status(), fallback_error_cstr);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-07-10 04:14:26 +08:00
|
|
|
void SBCommandReturnObject::SetError(const char *error_cstr) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError, (const char *),
|
|
|
|
error_cstr);
|
|
|
|
|
2019-09-26 21:31:59 +08:00
|
|
|
if (error_cstr)
|
2021-06-23 00:12:56 +08:00
|
|
|
ref().AppendError(error_cstr);
|
2013-07-10 04:14:26 +08:00
|
|
|
}
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBCommandReturnObject>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject,
|
2019-10-05 03:32:57 +08:00
|
|
|
(lldb_private::CommandReturnObject &));
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject,
|
2019-10-05 03:32:57 +08:00
|
|
|
(const lldb::SBCommandReturnObject &));
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_METHOD(
|
2019-10-05 03:32:57 +08:00
|
|
|
lldb::SBCommandReturnObject &,
|
2019-03-20 01:13:13 +08:00
|
|
|
SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetOutput, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetError, ());
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, GetOutputSize, ());
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, GetErrorSize, ());
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *));
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (FILE *));
|
2019-10-10 05:50:49 +08:00
|
|
|
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (SBFile));
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (SBFile));
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (FileSP));
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (FileSP));
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, Clear, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandReturnObject, GetStatus,
|
|
|
|
());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetStatus,
|
|
|
|
(lldb::ReturnStatus));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, Succeeded, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, HasResult, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, AppendMessage,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, AppendWarning,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, GetDescription,
|
|
|
|
(lldb::SBStream &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
|
|
|
|
(FILE *));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
|
|
|
|
(FILE *));
|
2019-10-10 05:50:49 +08:00
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
|
|
|
|
(SBFile));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
|
|
|
|
(SBFile));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
|
|
|
|
(FileSP));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
|
|
|
|
(FileSP));
|
2019-03-20 01:13:13 +08:00
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
|
|
|
|
(FILE *, bool));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
|
|
|
|
(FILE *, bool));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, PutCString,
|
|
|
|
(const char *, int));
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetOutput,
|
|
|
|
(bool));
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetError, (bool));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetError,
|
|
|
|
(lldb::SBError &, const char *));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetError, (const char *));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|