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 liblldb_AuxVector_H_
10 #define liblldb_AuxVector_H_
11 
12 #include <vector>
13 
14 #include "lldb/lldb-forward.h"
15 
16 namespace lldb_private {
17 class DataExtractor;
18 }
19 
20 /// \class AuxVector
21 /// Represents a processes auxiliary vector.
22 ///
23 /// When a process is loaded on Linux a vector of values is placed onto the
24 /// stack communicating operating system specific information. On
25 /// construction this class locates and parses this information and provides a
26 /// simple read-only interface to the entries found.
27 class AuxVector {
28 
29 public:
31 
32  struct Entry {
33  uint64_t type;
34  uint64_t value;
35 
36  Entry() : type(0), value(0) {}
37  };
38 
39  /// Constants describing the type of entry.
40  /// On Linux, running "LD_SHOW_AUXV=1 ./executable" will spew AUX
41  /// information. Added AUXV prefix to avoid potential conflicts with system-
42  /// defined macros
43  enum EntryType {
44  AUXV_AT_NULL = 0, ///< End of auxv.
45  AUXV_AT_IGNORE = 1, ///< Ignore entry.
46  AUXV_AT_EXECFD = 2, ///< File descriptor of program.
47  AUXV_AT_PHDR = 3, ///< Program headers.
48  AUXV_AT_PHENT = 4, ///< Size of program header.
49  AUXV_AT_PHNUM = 5, ///< Number of program headers.
50  AUXV_AT_PAGESZ = 6, ///< Page size.
51  AUXV_AT_BASE = 7, ///< Interpreter base address.
52  AUXV_AT_FLAGS = 8, ///< Flags.
53  AUXV_AT_ENTRY = 9, ///< Program entry point.
54  AUXV_AT_NOTELF = 10, ///< Set if program is not an ELF.
55  AUXV_AT_UID = 11, ///< UID.
56  AUXV_AT_EUID = 12, ///< Effective UID.
57  AUXV_AT_GID = 13, ///< GID.
58  AUXV_AT_EGID = 14, ///< Effective GID.
59  AUXV_AT_CLKTCK = 17, ///< Clock frequency (e.g. times(2)).
60  AUXV_AT_PLATFORM = 15, ///< String identifying platform.
61  AUXV_AT_HWCAP = 16, ///< Machine dependent hints about processor capabilities.
62  AUXV_AT_FPUCW = 18, ///< Used FPU control word.
63  AUXV_AT_DCACHEBSIZE = 19, ///< Data cache block size.
64  AUXV_AT_ICACHEBSIZE = 20, ///< Instruction cache block size.
65  AUXV_AT_UCACHEBSIZE = 21, ///< Unified cache block size.
66  AUXV_AT_IGNOREPPC = 22, ///< Entry should be ignored.
67  AUXV_AT_SECURE = 23, ///< Boolean, was exec setuid-like?
68  AUXV_AT_BASE_PLATFORM = 24, ///< String identifying real platforms.
69  AUXV_AT_RANDOM = 25, ///< Address of 16 random bytes.
70  AUXV_AT_EXECFN = 31, ///< Filename of executable.
71  AUXV_AT_SYSINFO = 32, ///< Pointer to the global system page used for system
72  ///calls and other nice things.
73  AUXV_AT_SYSINFO_EHDR = 33,
74  AUXV_AT_L1I_CACHESHAPE = 34, ///< Shapes of the caches.
75  AUXV_AT_L1D_CACHESHAPE = 35,
76  AUXV_AT_L2_CACHESHAPE = 36,
77  AUXV_AT_L3_CACHESHAPE = 37,
78  };
79 
80 private:
81  typedef std::vector<Entry> EntryVector;
82 
83 public:
84  typedef EntryVector::const_iterator iterator;
85 
86  iterator begin() const { return m_auxv.begin(); }
87  iterator end() const { return m_auxv.end(); }
88 
89  iterator FindEntry(EntryType type) const;
90 
91  static const char *GetEntryName(const Entry &entry) {
92  return GetEntryName(static_cast<EntryType>(entry.type));
93  }
94 
95  static const char *GetEntryName(EntryType type);
96 
97  void DumpToLog(lldb_private::Log *log) const;
98 
99 private:
100  lldb_private::Process *m_process;
101  EntryVector m_auxv;
102 
103  lldb::DataBufferSP GetAuxvData();
104 
105  void ParseAuxv(lldb_private::DataExtractor &data);
106 };
107 
108 #endif
An data extractor class.
Definition: DataExtractor.h:47
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
EntryType
Constants describing the type of entry.
Definition: AuxVector.h:43
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
Represents a processes auxiliary vector.
Definition: AuxVector.h:27
uint64_t type
Definition: AuxVector.h:33
static const FormatEntity::Entry::Definition * FindEntry(const llvm::StringRef &format_str, const FormatEntity::Entry::Definition *parent, llvm::StringRef &remainder)
static const char * GetEntryName(const Entry &entry)
Definition: AuxVector.h:91
EntryVector::const_iterator iterator
Definition: AuxVector.h:84
uint64_t value
Definition: AuxVector.h:34
iterator begin() const
Definition: AuxVector.h:86
iterator end() const
Definition: AuxVector.h:87