1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
//===-- PlatformAIX.cpp -------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "PlatformAIX.h"
#include "lldb/Host/Config.h"
#include <cstdio>
#if LLDB_ENABLE_POSIX
#include <sys/utsname.h>
#endif
#include "Utility/ARM64_DWARF_Registers.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
// Use defined constants from AIX mman.h for use when targeting remote aix
// systems even when host has different values.
// For remotely cross debugging aix
constexpr int MapVariable = 0x0;
constexpr int MapPrivate = 0x2;
constexpr int MapAnonymous = 0x10;
#if defined(_AIX)
#include <sys/mman.h>
static_assert(MapVariable == MAP_VARIABLE);
static_assert(MapPrivate == MAP_PRIVATE);
static_assert(MapAnonymous == MAP_ANONYMOUS);
#endif
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_aix;
LLDB_PLUGIN_DEFINE(PlatformAIX)
static uint32_t g_initialize_count = 0;
PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) {
Log *log = GetLog(LLDBLog::Platform);
LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
arch ? arch->GetArchitectureName() : "<null>",
arch ? arch->GetTriple().getTriple() : "<null>");
bool create = force || (arch && arch->IsValid() &&
arch->GetTriple().getOS() == llvm::Triple::AIX);
LLDB_LOG(log, "create = {0}", create);
if (create) {
return PlatformSP(new PlatformAIX(false));
}
return PlatformSP();
}
llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) {
if (is_host)
return "Local AIX user platform plug-in.";
return "Remote AIX user platform plug-in.";
}
void PlatformAIX::Initialize() {
PlatformPOSIX::Initialize();
if (g_initialize_count++ == 0) {
#ifdef _AIX
PlatformSP default_platform_sp(new PlatformAIX(true));
default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
Platform::SetHostPlatform(default_platform_sp);
#endif
PluginManager::RegisterPlugin(
PlatformAIX::GetPluginNameStatic(false),
PlatformAIX::GetPluginDescriptionStatic(false),
PlatformAIX::CreateInstance, nullptr);
}
}
void PlatformAIX::Terminate() {
if (g_initialize_count > 0)
if (--g_initialize_count == 0)
PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance);
PlatformPOSIX::Terminate();
}
PlatformAIX::PlatformAIX(bool is_host) : PlatformPOSIX(is_host) {
if (is_host) {
ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
m_supported_architectures.push_back(hostArch);
} else {
m_supported_architectures =
CreateArchList({llvm::Triple::ppc64}, llvm::Triple::AIX);
}
}
std::vector<ArchSpec>
PlatformAIX::GetSupportedArchitectures(const ArchSpec &process_host_arch) {
if (m_remote_platform_sp)
return m_remote_platform_sp->GetSupportedArchitectures(process_host_arch);
return m_supported_architectures;
}
void PlatformAIX::GetStatus(Stream &strm) {
Platform::GetStatus(strm);
#if LLDB_ENABLE_POSIX
// Display local kernel information only when we are running in host mode.
// Otherwise, we would end up printing non-AIX 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
}
void PlatformAIX::CalculateTrapHandlerSymbolNames() {}
lldb::UnwindPlanSP
PlatformAIX::GetTrapHandlerUnwindPlan(const llvm::Triple &triple,
ConstString name) {
return {};
}
MmapArgList PlatformAIX::GetMmapArgumentList(const ArchSpec &arch, addr_t addr,
addr_t length, unsigned prot,
unsigned flags, addr_t fd,
addr_t offset) {
unsigned flags_platform = MapVariable;
if (flags & eMmapFlagsPrivate)
flags_platform |= MapPrivate;
if (flags & eMmapFlagsAnon)
flags_platform |= MapAnonymous;
MmapArgList args({addr, length, prot, flags_platform, fd, offset});
return args;
}
CompilerType PlatformAIX::GetSiginfoType(const llvm::Triple &triple) {
return CompilerType();
}
|