LLDB  mainline
RegisterUtilities.h
Go to the documentation of this file.
1 //===-- RegisterUtilities.h -------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERUTILITIES_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERUTILITIES_H
11 
14 #include "llvm/BinaryFormat/ELF.h"
15 
16 namespace lldb_private {
17 /// Core files PT_NOTE segment descriptor types
18 
19 namespace NETBSD {
20 enum { NT_PROCINFO = 1, NT_AUXV = 2 };
21 
22 /* Size in bytes */
23 enum { NT_PROCINFO_SIZE = 160 };
24 
25 /* Size in bytes */
26 enum {
48 };
49 
50 namespace AARCH64 {
51 enum { NT_REGS = 32, NT_FPREGS = 34 };
52 }
53 
54 namespace AMD64 {
55 enum { NT_REGS = 33, NT_FPREGS = 35 };
56 }
57 
58 namespace I386 {
59 enum { NT_REGS = 33, NT_FPREGS = 35 };
60 }
61 
62 } // namespace NETBSD
63 
64 namespace OPENBSD {
65 enum {
67  NT_AUXV = 11,
68  NT_REGS = 20,
69  NT_FPREGS = 21,
70 };
71 }
72 
73 struct CoreNote {
76 };
77 
78 // A structure describing how to find a register set in a core file from a given
79 // OS.
80 struct RegsetDesc {
81  // OS to which this entry applies to. Must not be UnknownOS.
82  llvm::Triple::OSType OS;
83 
84  // Architecture to which this entry applies to. Can be UnknownArch, in which
85  // case it applies to all architectures of a given OS.
86  llvm::Triple::ArchType Arch;
87 
88  // The note type under which the register set can be found.
90 };
91 
92 // Returns the register set in Notes which corresponds to the specified Triple
93 // according to the list of register set descriptions in RegsetDescs. The list
94 // is scanned linearly, so you can use a more specific entry (e.g. linux-i386)
95 // to override a more general entry (e.g. general linux), as long as you place
96 // it earlier in the list. If a register set is not found, it returns an empty
97 // DataExtractor.
98 DataExtractor getRegset(llvm::ArrayRef<CoreNote> Notes,
99  const llvm::Triple &Triple,
100  llvm::ArrayRef<RegsetDesc> RegsetDescs);
101 
102 constexpr RegsetDesc FPR_Desc[] = {
103  // FreeBSD/i386 core NT_FPREGSET is x87 FSAVE result but the XSAVE dump
104  // starts with FXSAVE struct, so use that instead if available.
105  {llvm::Triple::FreeBSD, llvm::Triple::x86, llvm::ELF::NT_X86_XSTATE},
106  {llvm::Triple::FreeBSD, llvm::Triple::UnknownArch, llvm::ELF::NT_FPREGSET},
107  // In a i386 core file NT_FPREGSET is present, but it's not the result
108  // of the FXSAVE instruction like in 64 bit files.
109  // The result from FXSAVE is in NT_PRXFPREG for i386 core files
110  {llvm::Triple::Linux, llvm::Triple::x86, llvm::ELF::NT_PRXFPREG},
111  {llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_FPREGSET},
112  {llvm::Triple::NetBSD, llvm::Triple::aarch64, NETBSD::AARCH64::NT_FPREGS},
113  {llvm::Triple::NetBSD, llvm::Triple::x86, NETBSD::I386::NT_FPREGS},
114  {llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::AMD64::NT_FPREGS},
115  {llvm::Triple::OpenBSD, llvm::Triple::UnknownArch, OPENBSD::NT_FPREGS},
116 };
117 
119  {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_SVE},
120 };
121 
123  {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_PAC_MASK},
124 };
125 
126 constexpr RegsetDesc PPC_VMX_Desc[] = {
127  {llvm::Triple::FreeBSD, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX},
128  {llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX},
129 };
130 
131 constexpr RegsetDesc PPC_VSX_Desc[] = {
132  {llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VSX},
133 };
134 
135 } // namespace lldb_private
136 
137 #endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERUTILITIES_H
lldb_private::NETBSD::NT_PROCINFO_SIZE
@ NT_PROCINFO_SIZE
Definition: RegisterUtilities.h:23
lldb_private::OPENBSD::NT_REGS
@ NT_REGS
Definition: RegisterUtilities.h:68
lldb_private::NETBSD::NT_PROCINFO_CPI_SIGMASK_SIZE
@ NT_PROCINFO_CPI_SIGMASK_SIZE
Definition: RegisterUtilities.h:32
lldb_private::NETBSD::NT_PROCINFO_CPI_CPISIZE_SIZE
@ NT_PROCINFO_CPI_CPISIZE_SIZE
Definition: RegisterUtilities.h:28
lldb_private::FPR_Desc
constexpr RegsetDesc FPR_Desc[]
Definition: RegisterUtilities.h:102
lldb_private::NETBSD::NT_PROCINFO_CPI_PID_SIZE
@ NT_PROCINFO_CPI_PID_SIZE
Definition: RegisterUtilities.h:35
lldb_private::NETBSD::NT_PROCINFO_CPI_EGID_SIZE
@ NT_PROCINFO_CPI_EGID_SIZE
Definition: RegisterUtilities.h:43
lldb_private::NETBSD::AMD64::NT_REGS
@ NT_REGS
Definition: RegisterUtilities.h:55
lldb_private::NETBSD::NT_PROCINFO_CPI_VERSION_SIZE
@ NT_PROCINFO_CPI_VERSION_SIZE
Definition: RegisterUtilities.h:27
lldb_private::NETBSD::NT_PROCINFO_CPI_SIGNO_SIZE
@ NT_PROCINFO_CPI_SIGNO_SIZE
Definition: RegisterUtilities.h:29
lldb_private::NETBSD::NT_PROCINFO_CPI_SVUID_SIZE
@ NT_PROCINFO_CPI_SVUID_SIZE
Definition: RegisterUtilities.h:41
lldb_private::RegsetDesc::OS
llvm::Triple::OSType OS
Definition: RegisterUtilities.h:82
lldb_private::NETBSD::NT_PROCINFO_CPI_SVGID_SIZE
@ NT_PROCINFO_CPI_SVGID_SIZE
Definition: RegisterUtilities.h:44
lldb_private::NETBSD::NT_PROCINFO_CPI_RUID_SIZE
@ NT_PROCINFO_CPI_RUID_SIZE
Definition: RegisterUtilities.h:39
ELFNote
Definition: ObjectFileELF.h:24
lldb_private::NETBSD::AARCH64::NT_FPREGS
@ NT_FPREGS
Definition: RegisterUtilities.h:51
lldb_private::NETBSD::NT_PROCINFO_CPI_EUID_SIZE
@ NT_PROCINFO_CPI_EUID_SIZE
Definition: RegisterUtilities.h:40
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::NETBSD::NT_PROCINFO_CPI_SIGIGNORE_SIZE
@ NT_PROCINFO_CPI_SIGIGNORE_SIZE
Definition: RegisterUtilities.h:33
lldb_private::NETBSD::NT_AUXV
@ NT_AUXV
Definition: RegisterUtilities.h:20
lldb_private::PPC_VMX_Desc
constexpr RegsetDesc PPC_VMX_Desc[]
Definition: RegisterUtilities.h:126
lldb_private::NETBSD::NT_PROCINFO_CPI_PPID_SIZE
@ NT_PROCINFO_CPI_PPID_SIZE
Definition: RegisterUtilities.h:36
lldb_private::CoreNote::info
ELFNote info
Definition: RegisterUtilities.h:74
ObjectFileELF.h
lldb_private::NETBSD::NT_PROCINFO_CPI_NAME_SIZE
@ NT_PROCINFO_CPI_NAME_SIZE
Definition: RegisterUtilities.h:46
lldb_private::OPENBSD::NT_PROCINFO
@ NT_PROCINFO
Definition: RegisterUtilities.h:66
lldb_private::RegsetDesc::Arch
llvm::Triple::ArchType Arch
Definition: RegisterUtilities.h:86
lldb_private::NETBSD::NT_PROCINFO_CPI_SID_SIZE
@ NT_PROCINFO_CPI_SID_SIZE
Definition: RegisterUtilities.h:38
lldb_private::NETBSD::NT_PROCINFO_CPI_RGID_SIZE
@ NT_PROCINFO_CPI_RGID_SIZE
Definition: RegisterUtilities.h:42
lldb_private::NETBSD::NT_PROCINFO_CPI_SIGCODE_SIZE
@ NT_PROCINFO_CPI_SIGCODE_SIZE
Definition: RegisterUtilities.h:30
lldb_private::NETBSD::I386::NT_REGS
@ NT_REGS
Definition: RegisterUtilities.h:59
lldb_private::NETBSD::NT_PROCINFO_CPI_SIGCATCH_SIZE
@ NT_PROCINFO_CPI_SIGCATCH_SIZE
Definition: RegisterUtilities.h:34
lldb_private::getRegset
DataExtractor getRegset(llvm::ArrayRef< CoreNote > Notes, const llvm::Triple &Triple, llvm::ArrayRef< RegsetDesc > RegsetDescs)
Definition: RegisterUtilities.cpp:28
lldb_private::AARCH64_SVE_Desc
constexpr RegsetDesc AARCH64_SVE_Desc[]
Definition: RegisterUtilities.h:118
lldb_private::OPENBSD::NT_FPREGS
@ NT_FPREGS
Definition: RegisterUtilities.h:69
lldb_private::RegsetDesc::Note
uint32_t Note
Definition: RegisterUtilities.h:89
uint32_t
lldb_private::NETBSD::NT_PROCINFO_CPI_SIGPEND_SIZE
@ NT_PROCINFO_CPI_SIGPEND_SIZE
Definition: RegisterUtilities.h:31
lldb_private::NETBSD::NT_PROCINFO_CPI_PGRP_SIZE
@ NT_PROCINFO_CPI_PGRP_SIZE
Definition: RegisterUtilities.h:37
lldb_private::CoreNote
Definition: RegisterUtilities.h:73
DataExtractor.h
lldb_private::AARCH64_PAC_Desc
constexpr RegsetDesc AARCH64_PAC_Desc[]
Definition: RegisterUtilities.h:122
lldb_private::RegsetDesc
Definition: RegisterUtilities.h:80
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::NETBSD::I386::NT_FPREGS
@ NT_FPREGS
Definition: RegisterUtilities.h:59
lldb_private::NETBSD::AMD64::NT_FPREGS
@ NT_FPREGS
Definition: RegisterUtilities.h:55
lldb_private::PPC_VSX_Desc
constexpr RegsetDesc PPC_VSX_Desc[]
Definition: RegisterUtilities.h:131
lldb_private::NETBSD::AARCH64::NT_REGS
@ NT_REGS
Definition: RegisterUtilities.h:51
lldb_private::OPENBSD::NT_AUXV
@ NT_AUXV
Definition: RegisterUtilities.h:67
lldb_private::NETBSD::NT_PROCINFO_CPI_SIGLWP_SIZE
@ NT_PROCINFO_CPI_SIGLWP_SIZE
Definition: RegisterUtilities.h:47
lldb_private::CoreNote::data
DataExtractor data
Definition: RegisterUtilities.h:75
lldb_private::NETBSD::NT_PROCINFO
@ NT_PROCINFO
Definition: RegisterUtilities.h:20
lldb_private::NETBSD::NT_PROCINFO_CPI_NLWPS_SIZE
@ NT_PROCINFO_CPI_NLWPS_SIZE
Definition: RegisterUtilities.h:45