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:
62 case llvm::Triple::OSType::UnknownOS:
63 create = !arch->TripleOSWasSpecified();
71 LLDB_LOG(log,
"create = {0}", create);
80 return "Local Linux user platform plug-in.";
81 return "Remote Linux user platform plug-in.";
88#if defined(__linux__) && !defined(__ANDROID__)
90 default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
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::msp430, llvm::Triple::systemz},
127 llvm::Triple::Linux);
151 strm.
Printf(
" Kernel: %s\n", un.sysname);
152 strm.
Printf(
" Release: %s\n", un.release);
153 strm.
Printf(
" Version: %s\n", un.version);
160 uint32_t resume_count = 0;
173 std::string shell_string = shell.
GetPath();
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) {
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});
316 std::lock_guard<std::mutex> guard(
m_mutex);
318 m_type_system = std::make_shared<TypeSystemClang>(
"siginfo", triple);
322 bool si_errno_then_code =
true;
324 switch (triple.getArch()) {
325 case llvm::Triple::mips:
326 case llvm::Triple::mipsel:
327 case llvm::Triple::mips64:
328 case llvm::Triple::mips64el:
330 si_errno_then_code =
false;
364 sigfault_bounds_type,
"_addr_bnd",
367 {
"_lower", voidp_type},
368 {
"_upper", voidp_type},
371 ast->AddFieldToRecordType(sigfault_bounds_type,
"_pkey", uint_type,
373 ast->CompleteTagDeclarationDefinition(sigfault_bounds_type);
379 ast->StartTagDeclarationDefinition(siginfo_type);
380 ast->AddFieldToRecordType(siginfo_type,
"si_signo", int_type,
383 if (si_errno_then_code) {
384 ast->AddFieldToRecordType(siginfo_type,
"si_errno", int_type,
386 ast->AddFieldToRecordType(siginfo_type,
"si_code", int_type,
389 ast->AddFieldToRecordType(siginfo_type,
"si_code", int_type,
391 ast->AddFieldToRecordType(siginfo_type,
"si_errno", int_type,
396 if (triple.isArch64Bit())
397 ast->AddFieldToRecordType(siginfo_type,
"__pad0", int_type,
404 ast->StartTagDeclarationDefinition(union_type);
406 ast->AddFieldToRecordType(
408 ast->CreateStructForIdentifier(llvm::StringRef(),
410 {
"si_pid", pid_type},
411 {
"si_uid", uid_type},
415 ast->AddFieldToRecordType(
416 union_type,
"_timer",
417 ast->CreateStructForIdentifier(llvm::StringRef(),
419 {
"si_tid", int_type},
420 {
"si_overrun", int_type},
421 {
"si_sigval", sigval_type},
425 ast->AddFieldToRecordType(
427 ast->CreateStructForIdentifier(llvm::StringRef(),
429 {
"si_pid", pid_type},
430 {
"si_uid", uid_type},
431 {
"si_sigval", sigval_type},
435 ast->AddFieldToRecordType(
436 union_type,
"_sigchld",
437 ast->CreateStructForIdentifier(llvm::StringRef(),
439 {
"si_pid", pid_type},
440 {
"si_uid", uid_type},
441 {
"si_status", int_type},
442 {
"si_utime", clock_type},
443 {
"si_stime", clock_type},
447 ast->AddFieldToRecordType(
448 union_type,
"_sigfault",
449 ast->CreateStructForIdentifier(llvm::StringRef(),
451 {
"si_addr", voidp_type},
452 {
"si_addr_lsb", short_type},
453 {
"_bounds", sigfault_bounds_type},
457 ast->AddFieldToRecordType(
458 union_type,
"_sigpoll",
459 ast->CreateStructForIdentifier(llvm::StringRef(),
461 {
"si_band", band_type},
467 ast->AddFieldToRecordType(
468 union_type,
"_sigsys",
469 ast->CreateStructForIdentifier(llvm::StringRef(),
471 {
"_call_addr", voidp_type},
472 {
"_syscall", int_type},
473 {
"_arch", uint_type},
477 ast->CompleteTagDeclarationDefinition(union_type);
478 ast->AddFieldToRecordType(siginfo_type,
"_sifields", union_type,
481 ast->CompleteTagDeclarationDefinition(siginfo_type);
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_PLUGIN_DEFINE(PluginName)
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool IsMIPS() const
if MIPS architecture return true.
Generic representation of a type in a programming language.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
A uniqued constant string class.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
bool Test(ValueType bit) const
Test a single flag bit.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
const FileSpec & GetShell() const
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
A TypeSystem implementation based on Clang.
CompilerType GetBasicType(lldb::BasicType type)
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
CompilerType CreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
static bool StartTagDeclarationDefinition(const CompilerType &type)
std::shared_ptr< Row > RowSP
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
llvm::SmallVector< lldb::addr_t, 6 > MmapArgList
std::shared_ptr< lldb_private::Platform > PlatformSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::UnwindPlan > UnwindPlanSP
@ eRegisterKindDWARF
the register numbers seen DWARF