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_REGISTERUTILITIES_H 10 #define LLDB_REGISTERUTILITIES_H 11 12 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" 13 #include "lldb/Utility/DataExtractor.h" 14 15 namespace lldb_private { 16 /// Core files PT_NOTE segment descriptor types 17 18 namespace FREEBSD { 19 enum { 20 NT_PRSTATUS = 1, 21 NT_FPREGSET, 22 NT_PRPSINFO, 23 NT_THRMISC = 7, 24 NT_PROCSTAT_AUXV = 16, 25 NT_PPC_VMX = 0x100 26 }; 27 } 28 29 namespace NETBSD { 30 enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 }; 31 } 32 33 namespace OPENBSD { 34 enum { 35 NT_PROCINFO = 10, 36 NT_AUXV = 11, 37 NT_REGS = 20, 38 NT_FPREGS = 21, 39 }; 40 } 41 42 namespace LINUX { 43 enum { 44 NT_PRSTATUS = 1, 45 NT_FPREGSET, 46 NT_PRPSINFO, 47 NT_TASKSTRUCT, 48 NT_PLATFORM, 49 NT_AUXV, 50 NT_FILE = 0x46494c45, 51 NT_SIGINFO = 0x53494749, 52 NT_PPC_VMX = 0x100, 53 NT_PPC_VSX = 0x102, 54 NT_PRXFPREG = 0x46e62b7f, 55 }; 56 } 57 58 struct CoreNote { 59 ELFNote info; 60 DataExtractor data; 61 }; 62 63 // A structure describing how to find a register set in a core file from a given 64 // OS. 65 struct RegsetDesc { 66 // OS to which this entry applies to. Must not be UnknownOS. 67 llvm::Triple::OSType OS; 68 69 // Architecture to which this entry applies to. Can be UnknownArch, in which 70 // case it applies to all architectures of a given OS. 71 llvm::Triple::ArchType Arch; 72 73 // The note type under which the register set can be found. 74 uint32_t Note; 75 }; 76 77 // Returns the register set in Notes which corresponds to the specified Triple 78 // according to the list of register set descriptions in RegsetDescs. The list 79 // is scanned linearly, so you can use a more specific entry (e.g. linux-i386) 80 // to override a more general entry (e.g. general linux), as long as you place 81 // it earlier in the list. If a register set is not found, it returns an empty 82 // DataExtractor. 83 DataExtractor getRegset(llvm::ArrayRef<CoreNote> Notes, 84 const llvm::Triple &Triple, 85 llvm::ArrayRef<RegsetDesc> RegsetDescs); 86 87 constexpr RegsetDesc FPR_Desc[] = { 88 {llvm::Triple::FreeBSD, llvm::Triple::UnknownArch, FREEBSD::NT_FPREGSET}, 89 // In a i386 core file NT_FPREGSET is present, but it's not the result 90 // of the FXSAVE instruction like in 64 bit files. 91 // The result from FXSAVE is in NT_PRXFPREG for i386 core files 92 {llvm::Triple::Linux, llvm::Triple::x86, LINUX::NT_PRXFPREG}, 93 {llvm::Triple::Linux, llvm::Triple::UnknownArch, LINUX::NT_FPREGSET}, 94 {llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::NT_AMD64_FPREGS}, 95 {llvm::Triple::OpenBSD, llvm::Triple::UnknownArch, OPENBSD::NT_FPREGS}, 96 }; 97 98 constexpr RegsetDesc PPC_VMX_Desc[] = { 99 {llvm::Triple::FreeBSD, llvm::Triple::UnknownArch, FREEBSD::NT_PPC_VMX}, 100 {llvm::Triple::Linux, llvm::Triple::UnknownArch, LINUX::NT_PPC_VMX}, 101 }; 102 103 constexpr RegsetDesc PPC_VSX_Desc[] = { 104 {llvm::Triple::Linux, llvm::Triple::UnknownArch, LINUX::NT_PPC_VSX}, 105 }; 106 107 } // namespace lldb_private 108 109 #endif // #ifndef LLDB_REGISTERUTILITIES_H 110