1 //===-- AuxVector.cpp -----------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
12 AuxVector::AuxVector(const lldb_private::DataExtractor
&data
) {
16 void AuxVector::ParseAuxv(const lldb_private::DataExtractor
&data
) {
17 lldb::offset_t offset
= 0;
18 const size_t value_type_size
= data
.GetAddressByteSize() * 2;
19 while (data
.ValidOffsetForDataOfSize(offset
, value_type_size
)) {
20 // We're not reading an address but an int that could be 32 or 64 bit
21 // depending on the address size, which is what GetAddress does.
22 const uint64_t type
= data
.GetAddress(&offset
);
23 const uint64_t value
= data
.GetAddress(&offset
);
24 if (type
== AUXV_AT_NULL
)
26 if (type
== AUXV_AT_IGNORE
)
29 m_auxv_entries
[type
] = value
;
33 std::optional
<uint64_t>
34 AuxVector::GetAuxValue(enum EntryType entry_type
) const {
35 auto it
= m_auxv_entries
.find(static_cast<uint64_t>(entry_type
));
36 if (it
!= m_auxv_entries
.end())
41 void AuxVector::DumpToLog(lldb_private::Log
*log
) const {
45 log
->PutCString("AuxVector: ");
46 for (auto entry
: m_auxv_entries
) {
47 LLDB_LOGF(log
, " %s [%" PRIu64
"]: %" PRIx64
,
48 GetEntryName(static_cast<EntryType
>(entry
.first
)), entry
.first
,
53 const char *AuxVector::GetEntryName(EntryType type
) const {
54 const char *name
= "AT_???";
56 #define ENTRY_NAME(_type) \
60 case ENTRY_NAME(AUXV_AT_NULL
); break;
61 case ENTRY_NAME(AUXV_AT_IGNORE
); break;
62 case ENTRY_NAME(AUXV_AT_EXECFD
); break;
63 case ENTRY_NAME(AUXV_AT_PHDR
); break;
64 case ENTRY_NAME(AUXV_AT_PHENT
); break;
65 case ENTRY_NAME(AUXV_AT_PHNUM
); break;
66 case ENTRY_NAME(AUXV_AT_PAGESZ
); break;
67 case ENTRY_NAME(AUXV_AT_BASE
); break;
68 case ENTRY_NAME(AUXV_AT_FLAGS
); break;
69 case ENTRY_NAME(AUXV_AT_ENTRY
); break;
70 case ENTRY_NAME(AUXV_AT_NOTELF
); break;
71 case ENTRY_NAME(AUXV_AT_UID
); break;
72 case ENTRY_NAME(AUXV_AT_EUID
); break;
73 case ENTRY_NAME(AUXV_AT_GID
); break;
74 case ENTRY_NAME(AUXV_AT_EGID
); break;
75 case ENTRY_NAME(AUXV_AT_CLKTCK
); break;
76 case ENTRY_NAME(AUXV_AT_PLATFORM
); break;
77 case ENTRY_NAME(AUXV_AT_HWCAP
); break;
78 case ENTRY_NAME(AUXV_AT_FPUCW
); break;
79 case ENTRY_NAME(AUXV_AT_DCACHEBSIZE
); break;
80 case ENTRY_NAME(AUXV_AT_ICACHEBSIZE
); break;
81 case ENTRY_NAME(AUXV_AT_UCACHEBSIZE
); break;
82 case ENTRY_NAME(AUXV_AT_IGNOREPPC
); break;
83 case ENTRY_NAME(AUXV_AT_SECURE
); break;
84 case ENTRY_NAME(AUXV_AT_BASE_PLATFORM
); break;
85 case ENTRY_NAME(AUXV_AT_RANDOM
); break;
86 case ENTRY_NAME(AUXV_AT_HWCAP2
); break;
87 case ENTRY_NAME(AUXV_AT_EXECFN
); break;
88 case ENTRY_NAME(AUXV_AT_SYSINFO
); break;
89 case ENTRY_NAME(AUXV_AT_SYSINFO_EHDR
); break;
90 case ENTRY_NAME(AUXV_AT_L1I_CACHESHAPE
); break;
91 case ENTRY_NAME(AUXV_AT_L1D_CACHESHAPE
); break;
92 case ENTRY_NAME(AUXV_AT_L2_CACHESHAPE
); break;
93 case ENTRY_NAME(AUXV_AT_L3_CACHESHAPE
); break;