[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
|
|
|
//===-- SBQueueItem.cpp ---------------------------------------------------===//
|
2013-12-13 08:29:16 +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
|
2013-12-13 08:29:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/lldb-forward.h"
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2013-12-13 08:29:16 +08:00
|
|
|
#include "lldb/API/SBAddress.h"
|
|
|
|
#include "lldb/API/SBQueueItem.h"
|
|
|
|
#include "lldb/API/SBThread.h"
|
|
|
|
#include "lldb/Core/Address.h"
|
2014-03-06 14:31:18 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
2013-12-13 08:29:16 +08:00
|
|
|
#include "lldb/Target/QueueItem.h"
|
2014-02-05 13:44:54 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
2013-12-13 08:29:16 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
// Constructors
|
2019-03-06 08:06:00 +08:00
|
|
|
SBQueueItem::SBQueueItem() : m_queue_item_sp() {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBQueueItem);
|
|
|
|
}
|
2013-12-13 08:29:16 +08:00
|
|
|
|
|
|
|
SBQueueItem::SBQueueItem(const QueueItemSP &queue_item_sp)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_queue_item_sp(queue_item_sp) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &),
|
|
|
|
queue_item_sp);
|
|
|
|
}
|
2013-12-13 08:29:16 +08:00
|
|
|
|
|
|
|
// Destructor
|
|
|
|
SBQueueItem::~SBQueueItem() { m_queue_item_sp.reset(); }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-12-13 08:29:16 +08:00
|
|
|
bool SBQueueItem::IsValid() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueueItem, 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();
|
|
|
|
}
|
|
|
|
SBQueueItem::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueueItem, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return m_queue_item_sp.get() != nullptr;
|
2013-12-13 08:29:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBQueueItem::Clear() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBQueueItem, Clear);
|
|
|
|
|
2013-12-13 08:29:16 +08:00
|
|
|
m_queue_item_sp.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBQueueItem::SetQueueItem(const QueueItemSP &queue_item_sp) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBQueueItem, SetQueueItem,
|
|
|
|
(const lldb::QueueItemSP &), queue_item_sp);
|
|
|
|
|
2013-12-13 08:29:16 +08:00
|
|
|
m_queue_item_sp = queue_item_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::QueueItemKind SBQueueItem::GetKind() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::QueueItemKind, SBQueueItem, GetKind);
|
|
|
|
|
2013-12-13 08:29:16 +08:00
|
|
|
QueueItemKind result = eQueueItemKindUnknown;
|
|
|
|
if (m_queue_item_sp) {
|
|
|
|
result = m_queue_item_sp->GetKind();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBQueueItem::SetKind(lldb::QueueItemKind kind) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBQueueItem, SetKind, (lldb::QueueItemKind), kind);
|
|
|
|
|
2013-12-13 08:29:16 +08:00
|
|
|
if (m_queue_item_sp) {
|
|
|
|
m_queue_item_sp->SetKind(kind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SBAddress SBQueueItem::GetAddress() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBQueueItem, GetAddress);
|
|
|
|
|
2013-12-13 08:29:16 +08:00
|
|
|
SBAddress result;
|
|
|
|
if (m_queue_item_sp) {
|
2020-09-26 02:15:44 +08:00
|
|
|
result.SetAddress(m_queue_item_sp->GetAddress());
|
2013-12-13 08:29:16 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(result);
|
2013-12-13 08:29:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBQueueItem::SetAddress(SBAddress addr) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBQueueItem, SetAddress, (lldb::SBAddress), addr);
|
|
|
|
|
2013-12-13 08:29:16 +08:00
|
|
|
if (m_queue_item_sp) {
|
|
|
|
m_queue_item_sp->SetAddress(addr.ref());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBThread, SBQueueItem, GetExtendedBacktraceThread,
|
|
|
|
(const char *), type);
|
|
|
|
|
2013-12-13 08:29:16 +08:00
|
|
|
SBThread result;
|
|
|
|
if (m_queue_item_sp) {
|
2014-03-06 14:31:18 +08:00
|
|
|
ProcessSP process_sp = m_queue_item_sp->GetProcessSP();
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
|
|
|
|
ThreadSP thread_sp;
|
|
|
|
ConstString type_const(type);
|
|
|
|
thread_sp = m_queue_item_sp->GetExtendedBacktraceThread(type_const);
|
|
|
|
if (thread_sp) {
|
|
|
|
// Save this in the Process' ExtendedThreadList so a strong pointer
|
2018-05-01 00:49:04 +08:00
|
|
|
// retains the object
|
2014-03-06 14:31:18 +08:00
|
|
|
process_sp->GetExtendedThreadList().AddThread(thread_sp);
|
|
|
|
result.SetThread(thread_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-12-13 08:29:16 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(result);
|
2013-12-13 08:29:16 +08:00
|
|
|
}
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBQueueItem>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBQueueItem, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBQueueItem, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBQueueItem, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBQueueItem, Clear, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBQueueItem, SetQueueItem,
|
|
|
|
(const lldb::QueueItemSP &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::QueueItemKind, SBQueueItem, GetKind, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBQueueItem, SetKind, (lldb::QueueItemKind));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBQueueItem, GetAddress, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBQueueItem, SetAddress, (lldb::SBAddress));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBThread, SBQueueItem,
|
|
|
|
GetExtendedBacktraceThread, (const char *));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|