[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
|
|
|
//===-- CXXFunctionPointer.cpp---------------------------------------------===//
|
2015-09-04 08:33:51 +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
|
2015-09-04 08:33:51 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-09-05 05:22:54 +08:00
|
|
|
#include "lldb/DataFormatters/CXXFunctionPointer.h"
|
|
|
|
|
2015-10-20 12:50:09 +08:00
|
|
|
#include "lldb/Core/ValueObject.h"
|
2021-12-10 14:43:39 +08:00
|
|
|
#include "lldb/Target/ABI.h"
|
2015-09-04 08:33:51 +08:00
|
|
|
#include "lldb/Target/SectionLoadList.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2015-09-04 08:33:51 +08:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb_private::formatters;
|
|
|
|
|
|
|
|
bool lldb_private::formatters::CXXFunctionPointerSummaryProvider(
|
|
|
|
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
|
|
|
|
std::string destination;
|
|
|
|
StreamString sstr;
|
|
|
|
AddressType func_ptr_address_type = eAddressTypeInvalid;
|
|
|
|
addr_t func_ptr_address = valobj.GetPointerValue(&func_ptr_address_type);
|
|
|
|
if (func_ptr_address != 0 && func_ptr_address != LLDB_INVALID_ADDRESS) {
|
|
|
|
switch (func_ptr_address_type) {
|
|
|
|
case eAddressTypeInvalid:
|
|
|
|
case eAddressTypeFile:
|
|
|
|
case eAddressTypeHost:
|
|
|
|
break;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-09-04 08:33:51 +08:00
|
|
|
case eAddressTypeLoad: {
|
|
|
|
ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-09-04 08:33:51 +08:00
|
|
|
Address so_addr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
2018-12-15 08:15:33 +08:00
|
|
|
if (target && !target->GetSectionLoadList().IsEmpty()) {
|
2021-12-10 14:43:39 +08:00
|
|
|
target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address,
|
|
|
|
so_addr);
|
|
|
|
if (so_addr.GetSection() == nullptr) {
|
|
|
|
// If we have an address that doesn't correspond to any symbol,
|
|
|
|
// it might have authentication bits. Strip them & see if it
|
|
|
|
// now points to a symbol -- if so, do the SymbolContext lookup
|
|
|
|
// based on the stripped address.
|
|
|
|
// If we find a symbol with the ptrauth bits stripped, print the
|
|
|
|
// raw value into the stream, and replace the Address with the
|
|
|
|
// one that points to a symbol for a fuller description.
|
|
|
|
if (Process *process = exe_ctx.GetProcessPtr()) {
|
|
|
|
if (ABISP abi_sp = process->GetABI()) {
|
|
|
|
addr_t fixed_addr = abi_sp->FixCodeAddress(func_ptr_address);
|
|
|
|
if (fixed_addr != func_ptr_address) {
|
|
|
|
Address test_address;
|
|
|
|
test_address.SetLoadAddress(fixed_addr, target);
|
|
|
|
if (test_address.GetSection() != nullptr) {
|
|
|
|
int addrsize = target->GetArchitecture().GetAddressByteSize();
|
|
|
|
sstr.Printf("actual=0x%*.*" PRIx64 " ", addrsize * 2,
|
|
|
|
addrsize * 2, fixed_addr);
|
|
|
|
so_addr = test_address;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (so_addr.IsValid()) {
|
2015-09-04 08:33:51 +08:00
|
|
|
so_addr.Dump(&sstr, exe_ctx.GetBestExecutionContextScope(),
|
|
|
|
Address::DumpStyleResolvedDescription,
|
|
|
|
Address::DumpStyleSectionNameOffset);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} break;
|
2015-09-04 08:33:51 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2015-09-04 08:33:51 +08:00
|
|
|
if (sstr.GetSize() > 0) {
|
|
|
|
stream.Printf("(%s)", sstr.GetData());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|