[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 08:23:27 +01:00
|
|
|
//===-- LibCxxAtomic.cpp --------------------------------------------------===//
|
2016-02-12 22:18:24 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00: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
|
2016-02-12 22:18:24 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "LibCxxAtomic.h"
|
2020-02-18 11:19:02 +01:00
|
|
|
#include "lldb/DataFormatters/FormattersHelpers.h"
|
2016-02-12 22:18:24 +00:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb_private::formatters;
|
|
|
|
|
2019-03-05 18:34:35 +00:00
|
|
|
//
|
|
|
|
// We are supporting two versions of libc++ std::atomic
|
|
|
|
//
|
|
|
|
// Given std::atomic<int> i;
|
|
|
|
//
|
|
|
|
// The previous version of std::atomic was laid out like this
|
|
|
|
//
|
|
|
|
// (lldb) frame var -L -R i
|
|
|
|
// 0x00007ffeefbff9a0: (std::__1::atomic<int>) i = {
|
|
|
|
// 0x00007ffeefbff9a0: std::__1::__atomic_base<int, true> = {
|
|
|
|
// 0x00007ffeefbff9a0: std::__1::__atomic_base<int, false> = {
|
|
|
|
// 0x00007ffeefbff9a0: __a_ = 5
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// In this case we need to obtain __a_ and the current version is laid out as so
|
|
|
|
//
|
|
|
|
// (lldb) frame var -L -R i
|
|
|
|
// 0x00007ffeefbff9b0: (std::__1::atomic<int>) i = {
|
|
|
|
// 0x00007ffeefbff9b0: std::__1::__atomic_base<int, true> = {
|
|
|
|
// 0x00007ffeefbff9b0: std::__1::__atomic_base<int, false> = {
|
|
|
|
// 0x00007ffeefbff9b0: __a_ = {
|
|
|
|
// 0x00007ffeefbff9b0: std::__1::__cxx_atomic_base_impl<int> = {
|
|
|
|
// 0x00007ffeefbff9b0: __a_value = 5
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
// In this case we need to obtain __a_value
|
|
|
|
//
|
|
|
|
// The below method covers both cases and returns the relevant member as a
|
|
|
|
// ValueObjectSP
|
|
|
|
//
|
|
|
|
ValueObjectSP
|
|
|
|
lldb_private::formatters::GetLibCxxAtomicValue(ValueObject &valobj) {
|
|
|
|
ValueObjectSP non_sythetic = valobj.GetNonSyntheticValue();
|
|
|
|
if (!non_sythetic)
|
|
|
|
return {};
|
|
|
|
|
2023-05-28 18:48:32 -07:00
|
|
|
ValueObjectSP member__a_ = non_sythetic->GetChildMemberWithName("__a_");
|
2019-03-05 18:34:35 +00:00
|
|
|
if (!member__a_)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
ValueObjectSP member__a_value =
|
2023-05-28 18:48:32 -07:00
|
|
|
member__a_->GetChildMemberWithName("__a_value");
|
2019-03-05 18:34:35 +00:00
|
|
|
if (!member__a_value)
|
|
|
|
return member__a_;
|
|
|
|
|
|
|
|
return member__a_value;
|
|
|
|
}
|
|
|
|
|
2016-02-12 22:18:24 +00:00
|
|
|
bool lldb_private::formatters::LibCxxAtomicSummaryProvider(
|
|
|
|
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-03-05 18:34:35 +00:00
|
|
|
if (ValueObjectSP atomic_value = GetLibCxxAtomicValue(valobj)) {
|
2016-02-12 22:18:24 +00:00
|
|
|
std::string summary;
|
2019-03-05 18:34:35 +00:00
|
|
|
if (atomic_value->GetSummaryAsCString(summary, options) &&
|
|
|
|
summary.size() > 0) {
|
2016-02-12 22:18:24 +00:00
|
|
|
stream.Printf("%s", summary.c_str());
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
2016-02-12 22:18:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace formatters {
|
|
|
|
class LibcxxStdAtomicSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
|
|
|
|
public:
|
|
|
|
LibcxxStdAtomicSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-02-12 22:18:24 +00:00
|
|
|
~LibcxxStdAtomicSyntheticFrontEnd() override = default;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-02-12 22:18:24 +00:00
|
|
|
size_t CalculateNumChildren() override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-02-12 22:18:24 +00:00
|
|
|
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-02-12 22:18:24 +00:00
|
|
|
bool Update() override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-02-12 22:18:24 +00:00
|
|
|
bool MightHaveChildren() override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-03-06 21:22:25 +00:00
|
|
|
size_t GetIndexOfChildWithName(ConstString name) override;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-02-12 22:18:24 +00:00
|
|
|
private:
|
2022-03-14 13:32:03 -07:00
|
|
|
ValueObject *m_real_child = nullptr;
|
2016-02-12 22:18:24 +00:00
|
|
|
};
|
|
|
|
} // namespace formatters
|
|
|
|
} // namespace lldb_private
|
|
|
|
|
|
|
|
lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
|
|
|
|
LibcxxStdAtomicSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
|
2022-03-14 13:32:03 -07:00
|
|
|
: SyntheticChildrenFrontEnd(*valobj_sp) {}
|
2016-02-12 22:18:24 +00:00
|
|
|
|
|
|
|
bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::Update() {
|
2019-03-05 18:34:35 +00:00
|
|
|
ValueObjectSP atomic_value = GetLibCxxAtomicValue(m_backend);
|
|
|
|
if (atomic_value)
|
|
|
|
m_real_child = GetLibCxxAtomicValue(m_backend).get();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-02-12 22:18:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
|
|
|
|
MightHaveChildren() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
|
|
|
|
CalculateNumChildren() {
|
2020-02-18 11:19:02 +01:00
|
|
|
return m_real_child ? 1 : 0;
|
2016-02-12 22:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::ValueObjectSP
|
|
|
|
lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
|
|
|
|
size_t idx) {
|
2020-02-18 11:19:02 +01:00
|
|
|
if (idx == 0)
|
|
|
|
return m_real_child->GetSP()->Clone(ConstString("Value"));
|
|
|
|
return nullptr;
|
2016-02-12 22:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
|
2019-03-06 21:22:25 +00:00
|
|
|
GetIndexOfChildWithName(ConstString name) {
|
2023-01-25 10:39:50 +03:00
|
|
|
return name == "Value" ? 0 : UINT32_MAX;
|
2016-02-12 22:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SyntheticChildrenFrontEnd *
|
|
|
|
lldb_private::formatters::LibcxxAtomicSyntheticFrontEndCreator(
|
|
|
|
CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
|
|
|
|
if (valobj_sp)
|
|
|
|
return new LibcxxStdAtomicSyntheticFrontEnd(valobj_sp);
|
|
|
|
return nullptr;
|
|
|
|
}
|