LLDB  mainline
AuxVector.h
Go to the documentation of this file.
1 //===-- AuxVector.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_UTILITY_AUXVECTOR_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_AUXVECTOR_H
11 
13 #include "lldb/Utility/Log.h"
14 #include <unordered_map>
15 
16 class AuxVector {
17 
18 public:
20 
21  /// Constants describing the type of entry.
22  /// On Linux, running "LD_SHOW_AUXV=1 ./executable" will spew AUX
23  /// information. Added AUXV prefix to avoid potential conflicts with system-
24  /// defined macros
25  enum EntryType {
26  AUXV_AT_NULL = 0, ///< End of auxv.
27  AUXV_AT_IGNORE = 1, ///< Ignore entry.
28  AUXV_AT_EXECFD = 2, ///< File descriptor of program.
29  AUXV_AT_PHDR = 3, ///< Program headers.
30  AUXV_AT_PHENT = 4, ///< Size of program header.
31  AUXV_AT_PHNUM = 5, ///< Number of program headers.
32  AUXV_AT_PAGESZ = 6, ///< Page size.
33  AUXV_AT_BASE = 7, ///< Interpreter base address.
34  AUXV_AT_FLAGS = 8, ///< Flags.
35  AUXV_AT_ENTRY = 9, ///< Program entry point.
36  AUXV_AT_NOTELF = 10, ///< Set if program is not an ELF.
37  AUXV_AT_UID = 11, ///< UID.
38  AUXV_AT_EUID = 12, ///< Effective UID.
39  AUXV_AT_GID = 13, ///< GID.
40  AUXV_AT_EGID = 14, ///< Effective GID.
41  AUXV_AT_CLKTCK = 17, ///< Clock frequency (e.g. times(2)).
42  AUXV_AT_PLATFORM = 15, ///< String identifying platform.
44  16, ///< Machine dependent hints about processor capabilities.
45  AUXV_AT_FPUCW = 18, ///< Used FPU control word.
46  AUXV_AT_DCACHEBSIZE = 19, ///< Data cache block size.
47  AUXV_AT_ICACHEBSIZE = 20, ///< Instruction cache block size.
48  AUXV_AT_UCACHEBSIZE = 21, ///< Unified cache block size.
49  AUXV_AT_IGNOREPPC = 22, ///< Entry should be ignored.
50  AUXV_AT_SECURE = 23, ///< Boolean, was exec setuid-like?
51  AUXV_AT_BASE_PLATFORM = 24, ///< String identifying real platforms.
52  AUXV_AT_RANDOM = 25, ///< Address of 16 random bytes.
53  AUXV_AT_HWCAP2 = 26, ///< Extension of AT_HWCAP.
54  AUXV_AT_EXECFN = 31, ///< Filename of executable.
55  AUXV_AT_SYSINFO = 32, ///< Pointer to the global system page used for system
56  /// calls and other nice things.
58  AUXV_AT_L1I_CACHESHAPE = 34, ///< Shapes of the caches.
62  };
63 
64  llvm::Optional<uint64_t> GetAuxValue(enum EntryType entry_type) const;
65  void DumpToLog(lldb_private::Log *log) const;
66  const char *GetEntryName(EntryType type) const;
67 
68 private:
69  void ParseAuxv(const lldb_private::DataExtractor &data);
70 
71  std::unordered_map<uint64_t, uint64_t> m_auxv_entries;
72 };
73 
74 #endif
AuxVector::AUXV_AT_SYSINFO_EHDR
@ AUXV_AT_SYSINFO_EHDR
Definition: AuxVector.h:57
AuxVector::AUXV_AT_PHDR
@ AUXV_AT_PHDR
Program headers.
Definition: AuxVector.h:29
AuxVector::GetEntryName
const char * GetEntryName(EntryType type) const
Definition: AuxVector.cpp:52
AuxVector::AUXV_AT_ICACHEBSIZE
@ AUXV_AT_ICACHEBSIZE
Instruction cache block size.
Definition: AuxVector.h:47
AuxVector::AUXV_AT_HWCAP
@ AUXV_AT_HWCAP
Machine dependent hints about processor capabilities.
Definition: AuxVector.h:43
AuxVector::AUXV_AT_FLAGS
@ AUXV_AT_FLAGS
Flags.
Definition: AuxVector.h:34
AuxVector::AUXV_AT_BASE_PLATFORM
@ AUXV_AT_BASE_PLATFORM
String identifying real platforms.
Definition: AuxVector.h:51
AuxVector::AUXV_AT_PHNUM
@ AUXV_AT_PHNUM
Number of program headers.
Definition: AuxVector.h:31
AuxVector::AUXV_AT_PHENT
@ AUXV_AT_PHENT
Size of program header.
Definition: AuxVector.h:30
AuxVector::AUXV_AT_L2_CACHESHAPE
@ AUXV_AT_L2_CACHESHAPE
Definition: AuxVector.h:60
AuxVector::AUXV_AT_HWCAP2
@ AUXV_AT_HWCAP2
Extension of AT_HWCAP.
Definition: AuxVector.h:53
EntryType
FormatEntity::Entry::Type EntryType
Definition: FormatEntity.cpp:83
AuxVector::AUXV_AT_DCACHEBSIZE
@ AUXV_AT_DCACHEBSIZE
Data cache block size.
Definition: AuxVector.h:46
AuxVector::AUXV_AT_UID
@ AUXV_AT_UID
UID.
Definition: AuxVector.h:37
AuxVector::AUXV_AT_EGID
@ AUXV_AT_EGID
Effective GID.
Definition: AuxVector.h:40
AuxVector::AUXV_AT_CLKTCK
@ AUXV_AT_CLKTCK
Clock frequency (e.g. times(2)).
Definition: AuxVector.h:41
AuxVector::AUXV_AT_BASE
@ AUXV_AT_BASE
Interpreter base address.
Definition: AuxVector.h:33
AuxVector::AuxVector
AuxVector(const lldb_private::DataExtractor &data)
Definition: AuxVector.cpp:11
AuxVector::AUXV_AT_UCACHEBSIZE
@ AUXV_AT_UCACHEBSIZE
Unified cache block size.
Definition: AuxVector.h:48
AuxVector::AUXV_AT_L1D_CACHESHAPE
@ AUXV_AT_L1D_CACHESHAPE
Definition: AuxVector.h:59
AuxVector::AUXV_AT_NULL
@ AUXV_AT_NULL
End of auxv.
Definition: AuxVector.h:26
AuxVector::AUXV_AT_EUID
@ AUXV_AT_EUID
Effective UID.
Definition: AuxVector.h:38
AuxVector::AUXV_AT_PAGESZ
@ AUXV_AT_PAGESZ
Page size.
Definition: AuxVector.h:32
AuxVector::DumpToLog
void DumpToLog(lldb_private::Log *log) const
Definition: AuxVector.cpp:40
lldb_private::DataExtractor
Definition: DataExtractor.h:48
Log.h
AuxVector
Definition: AuxVector.h:16
AuxVector::ParseAuxv
void ParseAuxv(const lldb_private::DataExtractor &data)
Definition: AuxVector.cpp:15
AuxVector::AUXV_AT_ENTRY
@ AUXV_AT_ENTRY
Program entry point.
Definition: AuxVector.h:35
AuxVector::AUXV_AT_NOTELF
@ AUXV_AT_NOTELF
Set if program is not an ELF.
Definition: AuxVector.h:36
AuxVector::AUXV_AT_EXECFN
@ AUXV_AT_EXECFN
Filename of executable.
Definition: AuxVector.h:54
AuxVector::AUXV_AT_SYSINFO
@ AUXV_AT_SYSINFO
Pointer to the global system page used for system calls and other nice things.
Definition: AuxVector.h:55
AuxVector::AUXV_AT_L3_CACHESHAPE
@ AUXV_AT_L3_CACHESHAPE
Definition: AuxVector.h:61
AuxVector::EntryType
EntryType
Constants describing the type of entry.
Definition: AuxVector.h:25
AuxVector::AUXV_AT_GID
@ AUXV_AT_GID
GID.
Definition: AuxVector.h:39
AuxVector::AUXV_AT_RANDOM
@ AUXV_AT_RANDOM
Address of 16 random bytes.
Definition: AuxVector.h:52
AuxVector::GetAuxValue
llvm::Optional< uint64_t > GetAuxValue(enum EntryType entry_type) const
Definition: AuxVector.cpp:33
DataExtractor.h
AuxVector::AUXV_AT_EXECFD
@ AUXV_AT_EXECFD
File descriptor of program.
Definition: AuxVector.h:28
AuxVector::m_auxv_entries
std::unordered_map< uint64_t, uint64_t > m_auxv_entries
Definition: AuxVector.h:71
AuxVector::AUXV_AT_SECURE
@ AUXV_AT_SECURE
Boolean, was exec setuid-like?
Definition: AuxVector.h:50
AuxVector::AUXV_AT_IGNORE
@ AUXV_AT_IGNORE
Ignore entry.
Definition: AuxVector.h:27
AuxVector::AUXV_AT_IGNOREPPC
@ AUXV_AT_IGNOREPPC
Entry should be ignored.
Definition: AuxVector.h:49
AuxVector::AUXV_AT_FPUCW
@ AUXV_AT_FPUCW
Used FPU control word.
Definition: AuxVector.h:45
lldb_private::Log
Definition: Log.h:49
AuxVector::AUXV_AT_PLATFORM
@ AUXV_AT_PLATFORM
String identifying platform.
Definition: AuxVector.h:42
AuxVector::AUXV_AT_L1I_CACHESHAPE
@ AUXV_AT_L1I_CACHESHAPE
Shapes of the caches.
Definition: AuxVector.h:58