[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
|
|
|
//===-- PlatformOpenBSD.cpp -----------------------------------------------===//
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +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
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "PlatformOpenBSD.h"
|
|
|
|
#include "lldb/Host/Config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2019-12-13 02:00:45 +08:00
|
|
|
#if LLDB_ENABLE_POSIX
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
#include <sys/utsname.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "lldb/Core/Debugger.h"
|
|
|
|
#include "lldb/Core/PluginManager.h"
|
|
|
|
#include "lldb/Host/HostInfo.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Utility/FileSpec.h"
|
|
|
|
#include "lldb/Utility/Log.h"
|
2018-08-07 19:07:21 +08:00
|
|
|
#include "lldb/Utility/State.h"
|
2017-05-12 12:51:55 +08:00
|
|
|
#include "lldb/Utility/Status.h"
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Define these constants from OpenBSD mman.h for use when targeting remote
|
|
|
|
// openbsd systems even when host has different values.
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
#define MAP_PRIVATE 0x0002
|
|
|
|
#define MAP_ANON 0x1000
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb_private::platform_openbsd;
|
|
|
|
|
2020-02-08 06:58:18 +08:00
|
|
|
LLDB_PLUGIN(PlatformOpenBSD);
|
|
|
|
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
static uint32_t g_initialize_count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
PlatformSP PlatformOpenBSD::CreateInstance(bool force, const ArchSpec *arch) {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
|
|
|
|
LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
|
|
|
|
arch ? arch->GetArchitectureName() : "<null>",
|
|
|
|
arch ? arch->GetTriple().getTriple() : "<null>");
|
|
|
|
|
|
|
|
bool create = force;
|
2018-12-15 08:15:33 +08:00
|
|
|
if (!create && arch && arch->IsValid()) {
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
const llvm::Triple &triple = arch->GetTriple();
|
|
|
|
switch (triple.getOS()) {
|
|
|
|
case llvm::Triple::OpenBSD:
|
|
|
|
create = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#if defined(__OpenBSD__)
|
2018-05-01 00:49:04 +08:00
|
|
|
// Only accept "unknown" for the OS if the host is BSD and it "unknown"
|
|
|
|
// wasn't specified (it was just returned because it was NOT specified)
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
case llvm::Triple::OSType::UnknownOS:
|
|
|
|
create = !arch->TripleOSWasSpecified();
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LLDB_LOG(log, "create = {0}", create);
|
|
|
|
if (create) {
|
|
|
|
return PlatformSP(new PlatformOpenBSD(false));
|
|
|
|
}
|
|
|
|
return PlatformSP();
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstString PlatformOpenBSD::GetPluginNameStatic(bool is_host) {
|
|
|
|
if (is_host) {
|
|
|
|
static ConstString g_host_name(Platform::GetHostPlatformName());
|
|
|
|
return g_host_name;
|
|
|
|
} else {
|
|
|
|
static ConstString g_remote_name("remote-openbsd");
|
|
|
|
return g_remote_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *PlatformOpenBSD::GetPluginDescriptionStatic(bool is_host) {
|
|
|
|
if (is_host)
|
|
|
|
return "Local OpenBSD user platform plug-in.";
|
|
|
|
else
|
|
|
|
return "Remote OpenBSD user platform plug-in.";
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstString PlatformOpenBSD::GetPluginName() {
|
|
|
|
return GetPluginNameStatic(IsHost());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformOpenBSD::Initialize() {
|
|
|
|
Platform::Initialize();
|
|
|
|
|
|
|
|
if (g_initialize_count++ == 0) {
|
|
|
|
#if defined(__OpenBSD__)
|
|
|
|
PlatformSP default_platform_sp(new PlatformOpenBSD(true));
|
|
|
|
default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
|
|
|
|
Platform::SetHostPlatform(default_platform_sp);
|
|
|
|
#endif
|
|
|
|
PluginManager::RegisterPlugin(
|
|
|
|
PlatformOpenBSD::GetPluginNameStatic(false),
|
|
|
|
PlatformOpenBSD::GetPluginDescriptionStatic(false),
|
|
|
|
PlatformOpenBSD::CreateInstance, nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformOpenBSD::Terminate() {
|
|
|
|
if (g_initialize_count > 0) {
|
|
|
|
if (--g_initialize_count == 0) {
|
|
|
|
PluginManager::UnregisterPlugin(PlatformOpenBSD::CreateInstance);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlatformPOSIX::Terminate();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Default Constructor
|
|
|
|
PlatformOpenBSD::PlatformOpenBSD(bool is_host)
|
|
|
|
: PlatformPOSIX(is_host) // This is the local host platform
|
|
|
|
{}
|
|
|
|
|
|
|
|
PlatformOpenBSD::~PlatformOpenBSD() = default;
|
|
|
|
|
|
|
|
bool PlatformOpenBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
|
2017-08-16 21:10:07 +08:00
|
|
|
ArchSpec &arch) {
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
if (IsHost()) {
|
|
|
|
ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
|
|
|
|
if (hostArch.GetTriple().isOSOpenBSD()) {
|
|
|
|
if (idx == 0) {
|
|
|
|
arch = hostArch;
|
|
|
|
return arch.IsValid();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (m_remote_platform_sp)
|
|
|
|
return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
|
|
|
|
|
|
|
|
llvm::Triple triple;
|
|
|
|
// Set the OS to OpenBSD
|
|
|
|
triple.setOS(llvm::Triple::OpenBSD);
|
|
|
|
// Set the architecture
|
|
|
|
switch (idx) {
|
|
|
|
case 0:
|
|
|
|
triple.setArchName("x86_64");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
triple.setArchName("i386");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
triple.setArchName("aarch64");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
triple.setArchName("arm");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the
|
2018-05-01 00:49:04 +08:00
|
|
|
// vendor by calling triple.SetVendorName("unknown") so that it is a
|
|
|
|
// "unspecified unknown". This means when someone calls
|
|
|
|
// triple.GetVendorName() it will return an empty string which indicates
|
|
|
|
// that the vendor can be set when two architectures are merged
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
|
|
|
|
// Now set the triple into "arch" and return true
|
|
|
|
arch.SetTriple(triple);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformOpenBSD::GetStatus(Stream &strm) {
|
|
|
|
Platform::GetStatus(strm);
|
|
|
|
|
2019-12-13 02:00:45 +08:00
|
|
|
#if LLDB_ENABLE_POSIX
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
// Display local kernel information only when we are running in host mode.
|
|
|
|
// Otherwise, we would end up printing non-OpenBSD information (when running
|
|
|
|
// on Mac OS for example).
|
|
|
|
if (IsHost()) {
|
|
|
|
struct utsname un;
|
|
|
|
|
|
|
|
if (uname(&un))
|
|
|
|
return;
|
|
|
|
|
|
|
|
strm.Printf(" Kernel: %s\n", un.sysname);
|
|
|
|
strm.Printf(" Release: %s\n", un.release);
|
|
|
|
strm.Printf(" Version: %s\n", un.version);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenBSD processes cannot yet be launched by spawning and attaching.
|
|
|
|
bool PlatformOpenBSD::CanDebugProcess() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformOpenBSD::CalculateTrapHandlerSymbolNames() {
|
|
|
|
m_trap_handlers.push_back(ConstString("_sigtramp"));
|
|
|
|
}
|
|
|
|
|
2017-08-16 20:55:02 +08:00
|
|
|
MmapArgList PlatformOpenBSD::GetMmapArgumentList(const ArchSpec &arch,
|
|
|
|
addr_t addr, addr_t length,
|
|
|
|
unsigned prot, unsigned flags,
|
|
|
|
addr_t fd, addr_t offset) {
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
uint64_t flags_platform = 0;
|
|
|
|
|
|
|
|
if (flags & eMmapFlagsPrivate)
|
|
|
|
flags_platform |= MAP_PRIVATE;
|
|
|
|
if (flags & eMmapFlagsAnon)
|
|
|
|
flags_platform |= MAP_ANON;
|
2017-08-16 20:55:02 +08:00
|
|
|
|
|
|
|
MmapArgList args({addr, length, prot, flags_platform, fd, offset});
|
|
|
|
return args;
|
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
2017-03-26 23:34:57 +08:00
|
|
|
}
|