[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
|
|
|
//===-- SBTraceOptions.cpp ------------------------------------------------===//
|
2017-04-26 16:48:50 +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
|
2017-04-26 16:48:50 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBTraceOptions.h"
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2017-04-26 16:48:50 +08:00
|
|
|
#include "lldb/API/SBError.h"
|
|
|
|
#include "lldb/API/SBStructuredData.h"
|
|
|
|
#include "lldb/Core/StructuredDataImpl.h"
|
2017-06-29 22:32:17 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
|
|
|
#include "lldb/Utility/TraceOptions.h"
|
2017-04-26 16:48:50 +08:00
|
|
|
|
2019-02-12 07:13:08 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
SBTraceOptions::SBTraceOptions() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTraceOptions);
|
|
|
|
|
2019-02-12 07:13:08 +08:00
|
|
|
m_traceoptions_sp = std::make_shared<TraceOptions>();
|
2017-04-26 16:48:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::TraceType SBTraceOptions::getType() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::TraceType, SBTraceOptions, getType);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp)
|
|
|
|
return m_traceoptions_sp->getType();
|
|
|
|
return lldb::TraceType::eTraceTypeNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t SBTraceOptions::getTraceBufferSize() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions,
|
|
|
|
getTraceBufferSize);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp)
|
|
|
|
return m_traceoptions_sp->getTraceBufferSize();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams,
|
|
|
|
(lldb::SBError &), error);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
error.Clear();
|
|
|
|
const lldb_private::StructuredData::DictionarySP dict_obj =
|
|
|
|
m_traceoptions_sp->getTraceParams();
|
|
|
|
lldb::SBStructuredData structData;
|
|
|
|
if (dict_obj && structData.m_impl_up)
|
|
|
|
structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this());
|
|
|
|
else
|
|
|
|
error.SetErrorString("Empty trace params");
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(structData);
|
2017-04-26 16:48:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t SBTraceOptions::getMetaDataBufferSize() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions,
|
|
|
|
getMetaDataBufferSize);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp)
|
|
|
|
return m_traceoptions_sp->getTraceBufferSize();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBTraceOptions::setTraceParams(lldb::SBStructuredData ¶ms) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceParams,
|
|
|
|
(lldb::SBStructuredData &), params);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp && params.m_impl_up) {
|
|
|
|
StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP();
|
|
|
|
if (obj_sp && obj_sp->GetAsDictionary() != nullptr)
|
|
|
|
m_traceoptions_sp->setTraceParams(
|
|
|
|
std::static_pointer_cast<StructuredData::Dictionary>(obj_sp));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBTraceOptions::setType(lldb::TraceType type) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBTraceOptions, setType, (lldb::TraceType), type);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp)
|
|
|
|
m_traceoptions_sp->setType(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBTraceOptions::setTraceBufferSize(uint64_t size) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t),
|
|
|
|
size);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp)
|
|
|
|
m_traceoptions_sp->setTraceBufferSize(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBTraceOptions::setMetaDataBufferSize(uint64_t size) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBTraceOptions, setMetaDataBufferSize, (uint64_t),
|
|
|
|
size);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp)
|
|
|
|
m_traceoptions_sp->setMetaDataBufferSize(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBTraceOptions::IsValid() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTraceOptions, 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();
|
|
|
|
}
|
|
|
|
SBTraceOptions::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTraceOptions, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBTraceOptions::setThreadID(lldb::tid_t thread_id) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t),
|
|
|
|
thread_id);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp)
|
|
|
|
m_traceoptions_sp->setThreadID(thread_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::tid_t SBTraceOptions::getThreadID() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBTraceOptions, getThreadID);
|
|
|
|
|
2017-04-26 16:48:50 +08:00
|
|
|
if (m_traceoptions_sp)
|
|
|
|
return m_traceoptions_sp->getThreadID();
|
|
|
|
return LLDB_INVALID_THREAD_ID;
|
|
|
|
}
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBTraceOptions>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBTraceOptions, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::TraceType, SBTraceOptions, getType, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getTraceBufferSize,
|
|
|
|
());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams,
|
|
|
|
(lldb::SBError &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getMetaDataBufferSize,
|
|
|
|
());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceParams,
|
|
|
|
(lldb::SBStructuredData &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTraceOptions, setType, (lldb::TraceType));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTraceOptions, setMetaDataBufferSize,
|
|
|
|
(uint64_t));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTraceOptions, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBTraceOptions, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::tid_t, SBTraceOptions, getThreadID, ());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|