Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Process/Utility/AuxVector.h
39642 views
//===-- AuxVector.h ---------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_AUXVECTOR_H9#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_AUXVECTOR_H1011#include "lldb/Utility/DataExtractor.h"12#include "lldb/Utility/Log.h"13#include <optional>14#include <unordered_map>1516class AuxVector {1718public:19AuxVector(const lldb_private::DataExtractor &data);2021/// Constants describing the type of entry.22/// On Linux and FreeBSD, running "LD_SHOW_AUXV=1 ./executable" will spew AUX23/// information. Added AUXV prefix to avoid potential conflicts with system-24/// defined macros. For FreeBSD, the numbers can be found in sys/elf_common.h.25enum EntryType {26AUXV_AT_NULL = 0, ///< End of auxv.27AUXV_AT_IGNORE = 1, ///< Ignore entry.28AUXV_AT_EXECFD = 2, ///< File descriptor of program.29AUXV_AT_PHDR = 3, ///< Program headers.30AUXV_AT_PHENT = 4, ///< Size of program header.31AUXV_AT_PHNUM = 5, ///< Number of program headers.32AUXV_AT_PAGESZ = 6, ///< Page size.33AUXV_AT_BASE = 7, ///< Interpreter base address.34AUXV_AT_FLAGS = 8, ///< Flags.35AUXV_AT_ENTRY = 9, ///< Program entry point.36AUXV_AT_NOTELF = 10, ///< Set if program is not an ELF.37AUXV_AT_UID = 11, ///< UID.38AUXV_AT_EUID = 12, ///< Effective UID.39AUXV_AT_GID = 13, ///< GID.40AUXV_AT_EGID = 14, ///< Effective GID.4142// At this point Linux and FreeBSD diverge and many of the following values43// are Linux specific. If you use them make sure you are in Linux specific44// code or they have the same value on other platforms.4546AUXV_AT_CLKTCK = 17, ///< Clock frequency (e.g. times(2)).47AUXV_AT_PLATFORM = 15, ///< String identifying platform.48AUXV_AT_HWCAP =4916, ///< Machine dependent hints about processor capabilities.50AUXV_AT_FPUCW = 18, ///< Used FPU control word.51AUXV_AT_DCACHEBSIZE = 19, ///< Data cache block size.52AUXV_AT_ICACHEBSIZE = 20, ///< Instruction cache block size.53AUXV_AT_UCACHEBSIZE = 21, ///< Unified cache block size.54AUXV_AT_IGNOREPPC = 22, ///< Entry should be ignored.55AUXV_AT_SECURE = 23, ///< Boolean, was exec setuid-like?56AUXV_AT_BASE_PLATFORM = 24, ///< String identifying real platforms.57AUXV_AT_RANDOM = 25, ///< Address of 16 random bytes.58AUXV_AT_HWCAP2 = 26, ///< Extension of AT_HWCAP.59AUXV_AT_EXECFN = 31, ///< Filename of executable.60AUXV_AT_SYSINFO = 32, ///< Pointer to the global system page used for system61/// calls and other nice things.62AUXV_AT_SYSINFO_EHDR = 33,63AUXV_AT_L1I_CACHESHAPE = 34, ///< Shapes of the caches.64AUXV_AT_L1D_CACHESHAPE = 35,65AUXV_AT_L2_CACHESHAPE = 36,66AUXV_AT_L3_CACHESHAPE = 37,6768// Platform specific values which may overlap the Linux values.6970AUXV_FREEBSD_AT_HWCAP = 25, ///< FreeBSD specific AT_HWCAP value.71};7273std::optional<uint64_t> GetAuxValue(enum EntryType entry_type) const;74void DumpToLog(lldb_private::Log *log) const;75const char *GetEntryName(EntryType type) const;7677private:78void ParseAuxv(const lldb_private::DataExtractor &data);7980std::unordered_map<uint64_t, uint64_t> m_auxv_entries;81};8283#endif848586