10 #include "lldb/Host/Config.h"
14 #include <sys/utsname.h>
47 LLDB_LOG(log,
"force = {0}, arch=({1}, {2})", force,
48 arch ? arch->GetArchitectureName() :
"<null>",
49 arch ? arch->GetTriple().getTriple() :
"<null>");
52 if (!create && arch && arch->IsValid()) {
53 const llvm::Triple &triple = arch->GetTriple();
54 switch (triple.getOS()) {
55 case llvm::Triple::Linux:
59 #if defined(__linux__)
62 case llvm::Triple::OSType::UnknownOS:
63 create = !arch->TripleOSWasSpecified();
71 LLDB_LOG(log,
"create = {0}", create);
78 llvm::StringRef PlatformLinux::GetPluginDescriptionStatic(
bool is_host) {
80 return "Local Linux user platform plug-in.";
81 return "Remote Linux user platform plug-in.";
84 void PlatformLinux::Initialize() {
88 #if defined(__linux__) && !defined(__ANDROID__)
90 default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
91 Platform::SetHostPlatform(default_platform_sp);
93 PluginManager::RegisterPlugin(
94 PlatformLinux::GetPluginNameStatic(
false),
95 PlatformLinux::GetPluginDescriptionStatic(
false),
96 PlatformLinux::CreateInstance,
nullptr);
100 void PlatformLinux::Terminate() {
103 PluginManager::UnregisterPlugin(PlatformLinux::CreateInstance);
111 PlatformLinux::PlatformLinux(
bool is_host)
115 ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
117 if (hostArch.
GetTriple().isArch64Bit()) {
119 HostInfo::GetArchitecture(HostInfo::eArchKind32));
123 {llvm::Triple::x86_64, llvm::Triple::x86, llvm::Triple::arm,
124 llvm::Triple::aarch64, llvm::Triple::mips64, llvm::Triple::mips64,
125 llvm::Triple::hexagon, llvm::Triple::mips, llvm::Triple::mips64el,
126 llvm::Triple::mipsel, llvm::Triple::systemz},
127 llvm::Triple::Linux);
131 std::vector<ArchSpec>
141 #if LLDB_ENABLE_POSIX
151 strm.
Printf(
" Kernel: %s\n", un.sysname);
152 strm.
Printf(
" Release: %s\n", un.release);
153 strm.
Printf(
" Version: %s\n", un.version);
178 const char *shell_name = strrchr(shell_string.c_str(),
'/');
179 if (shell_name ==
nullptr)
180 shell_name = shell_string.c_str();
184 if (strcmp(shell_name,
"csh") == 0 || strcmp(shell_name,
"tcsh") == 0 ||
185 strcmp(shell_name,
"zsh") == 0 || strcmp(shell_name,
"sh") == 0) {
209 UnwindPlanSP unwind_plan_sp;
210 if (name !=
"__kernel_rt_sigreturn")
211 return unwind_plan_sp;
227 int32_t offset = 128 + 8 + 8 + 24 + 128 + 8;
240 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x0, 0 * 8,
false);
241 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x1, 1 * 8,
false);
242 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x2, 2 * 8,
false);
243 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x3, 3 * 8,
false);
244 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x4, 4 * 8,
false);
245 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x5, 5 * 8,
false);
246 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x6, 6 * 8,
false);
247 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x7, 7 * 8,
false);
248 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x8, 8 * 8,
false);
249 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::x9, 9 * 8,
false);
269 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::fp, 29 * 8,
false);
271 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::sp, 31 * 8,
false);
272 row->SetRegisterLocationToAtCFAPlusOffset(
arm64_dwarf::pc, 32 * 8,
false);
279 unwind_plan_sp->AppendRow(row);
280 unwind_plan_sp->SetSourceName(
"AArch64 Linux sigcontext");
283 unwind_plan_sp->SetUnwindPlanValidAtAllInstructions(
eLazyBoolYes);
284 unwind_plan_sp->SetUnwindPlanForSignalTrap(
eLazyBoolYes);
286 return unwind_plan_sp;
292 if (triple.isAArch64())
300 unsigned prot,
unsigned flags,
302 uint64_t flags_platform = 0;
308 flags_platform |= map_anon;
310 MmapArgList args({addr, length, prot, flags_platform, fd, offset});
319 bool si_errno_then_code =
true;
321 switch (triple.getArch()) {
322 case llvm::Triple::mips:
323 case llvm::Triple::mipsel:
324 case llvm::Triple::mips64:
325 case llvm::Triple::mips64el:
327 si_errno_then_code =
false;
363 {
"_lower", voidp_type},
364 {
"_upper", voidp_type},
379 if (si_errno_then_code) {
392 if (triple.isArch64Bit())
406 {
"si_pid", pid_type},
407 {
"si_uid", uid_type},
412 union_type,
"_timer",
415 {
"si_tid", int_type},
416 {
"si_overrun", int_type},
417 {
"si_sigval", sigval_type},
425 {
"si_pid", pid_type},
426 {
"si_uid", uid_type},
427 {
"si_sigval", sigval_type},
432 union_type,
"_sigchld",
435 {
"si_pid", pid_type},
436 {
"si_uid", uid_type},
437 {
"si_status", int_type},
438 {
"si_utime", clock_type},
439 {
"si_stime", clock_type},
444 union_type,
"_sigfault",
447 {
"si_addr", voidp_type},
448 {
"si_addr_lsb", short_type},
449 {
"_bounds", sigfault_bounds_type},
454 union_type,
"_sigpoll",
457 {
"si_band", band_type},
464 union_type,
"_sigsys",
467 {
"_call_addr", voidp_type},
468 {
"_syscall", int_type},
469 {
"_arch", uint_type},