summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h108
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt2
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp26
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h1
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp4
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h2
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp15
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeProcessLinux.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/AuxVector.cpp (renamed from lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp)97
-rw-r--r--lldb/source/Plugins/Process/Utility/AuxVector.h73
-rw-r--r--lldb/source/Plugins/Process/Utility/CMakeLists.txt1
-rw-r--r--lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp4
-rw-r--r--lldb/source/Plugins/Process/elf-core/ProcessElfCore.h2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp4
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h2
-rw-r--r--lldb/source/Target/Process.cpp2
16 files changed, 143 insertions, 204 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h
deleted file mode 100644
index cf32d9cd30f..00000000000
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h
+++ /dev/null
@@ -1,108 +0,0 @@
-//===-- AuxVector.h ---------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_AuxVector_H_
-#define liblldb_AuxVector_H_
-
-#include <vector>
-
-#include "lldb/lldb-forward.h"
-
-namespace lldb_private {
-class DataExtractor;
-}
-
-/// \class AuxVector
-/// Represents a processes auxiliary vector.
-///
-/// When a process is loaded on Linux a vector of values is placed onto the
-/// stack communicating operating system specific information. On
-/// construction this class locates and parses this information and provides a
-/// simple read-only interface to the entries found.
-class AuxVector {
-
-public:
- AuxVector(lldb_private::Process *process);
-
- struct Entry {
- uint64_t type;
- uint64_t value;
-
- Entry() : type(0), value(0) {}
- };
-
- /// Constants describing the type of entry.
- /// On Linux, running "LD_SHOW_AUXV=1 ./executable" will spew AUX
- /// information. Added AUXV prefix to avoid potential conflicts with system-
- /// defined macros
- enum EntryType {
- AUXV_AT_NULL = 0, ///< End of auxv.
- AUXV_AT_IGNORE = 1, ///< Ignore entry.
- AUXV_AT_EXECFD = 2, ///< File descriptor of program.
- AUXV_AT_PHDR = 3, ///< Program headers.
- AUXV_AT_PHENT = 4, ///< Size of program header.
- AUXV_AT_PHNUM = 5, ///< Number of program headers.
- AUXV_AT_PAGESZ = 6, ///< Page size.
- AUXV_AT_BASE = 7, ///< Interpreter base address.
- AUXV_AT_FLAGS = 8, ///< Flags.
- AUXV_AT_ENTRY = 9, ///< Program entry point.
- AUXV_AT_NOTELF = 10, ///< Set if program is not an ELF.
- AUXV_AT_UID = 11, ///< UID.
- AUXV_AT_EUID = 12, ///< Effective UID.
- AUXV_AT_GID = 13, ///< GID.
- AUXV_AT_EGID = 14, ///< Effective GID.
- AUXV_AT_CLKTCK = 17, ///< Clock frequency (e.g. times(2)).
- AUXV_AT_PLATFORM = 15, ///< String identifying platform.
- AUXV_AT_HWCAP = 16, ///< Machine dependent hints about processor capabilities.
- AUXV_AT_FPUCW = 18, ///< Used FPU control word.
- AUXV_AT_DCACHEBSIZE = 19, ///< Data cache block size.
- AUXV_AT_ICACHEBSIZE = 20, ///< Instruction cache block size.
- AUXV_AT_UCACHEBSIZE = 21, ///< Unified cache block size.
- AUXV_AT_IGNOREPPC = 22, ///< Entry should be ignored.
- AUXV_AT_SECURE = 23, ///< Boolean, was exec setuid-like?
- AUXV_AT_BASE_PLATFORM = 24, ///< String identifying real platforms.
- AUXV_AT_RANDOM = 25, ///< Address of 16 random bytes.
- AUXV_AT_EXECFN = 31, ///< Filename of executable.
- AUXV_AT_SYSINFO = 32, ///< Pointer to the global system page used for system
- ///calls and other nice things.
- AUXV_AT_SYSINFO_EHDR = 33,
- AUXV_AT_L1I_CACHESHAPE = 34, ///< Shapes of the caches.
- AUXV_AT_L1D_CACHESHAPE = 35,
- AUXV_AT_L2_CACHESHAPE = 36,
- AUXV_AT_L3_CACHESHAPE = 37,
- };
-
-private:
- typedef std::vector<Entry> EntryVector;
-
-public:
- typedef EntryVector::const_iterator iterator;
-
- iterator begin() const { return m_auxv.begin(); }
- iterator end() const { return m_auxv.end(); }
-
- iterator FindEntry(EntryType type) const;
-
- static const char *GetEntryName(const Entry &entry) {
- return GetEntryName(static_cast<EntryType>(entry.type));
- }
-
- static const char *GetEntryName(EntryType type);
-
- void DumpToLog(lldb_private::Log *log) const;
-
-private:
- lldb_private::Process *m_process;
- EntryVector m_auxv;
-
- lldb::DataBufferSP GetAuxvData();
-
- void ParseAuxv(lldb_private::DataExtractor &data);
-};
-
-#endif
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
index 409ba92a0e1..c1e00b2dd44 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
@@ -1,5 +1,4 @@
add_lldb_library(lldbPluginDynamicLoaderPosixDYLD PLUGIN
- AuxVector.cpp
DYLDRendezvous.cpp
DynamicLoaderPOSIXDYLD.cpp
@@ -10,6 +9,7 @@ add_lldb_library(lldbPluginDynamicLoaderPosixDYLD PLUGIN
lldbSymbol
lldbTarget
lldbPluginProcessElfCore
+ lldbPluginProcessUtility
LINK_COMPONENTS
Support
)
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 591a27f4492..b55660899d0 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -9,8 +9,6 @@
// Main header include
#include "DynamicLoaderPOSIXDYLD.h"
-#include "AuxVector.h"
-
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -90,8 +88,8 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
if (log)
log->Printf("DynamicLoaderPOSIXDYLD::%s() pid %" PRIu64, __FUNCTION__,
m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
+ m_auxv = llvm::make_unique<AuxVector>(m_process->GetAuxvData());
- m_auxv.reset(new AuxVector(m_process));
if (log)
log->Printf("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " reloaded auxv data",
__FUNCTION__,
@@ -182,7 +180,7 @@ void DynamicLoaderPOSIXDYLD::DidLaunch() {
ModuleSP executable;
addr_t load_offset;
- m_auxv.reset(new AuxVector(m_process));
+ m_auxv = llvm::make_unique<AuxVector>(m_process->GetAuxvData());
executable = GetTargetExecutable();
load_offset = ComputeLoadOffset();
@@ -628,13 +626,13 @@ addr_t DynamicLoaderPOSIXDYLD::ComputeLoadOffset() {
}
void DynamicLoaderPOSIXDYLD::EvalSpecialModulesStatus() {
- auto I = m_auxv->FindEntry(AuxVector::AUXV_AT_SYSINFO_EHDR);
- if (I != m_auxv->end() && I->value != 0)
- m_vdso_base = I->value;
+ if (llvm::Optional<uint64_t> vdso_base =
+ m_auxv->GetAuxValue(AuxVector::AUXV_AT_SYSINFO_EHDR))
+ m_vdso_base = *vdso_base;
- I = m_auxv->FindEntry(AuxVector::AUXV_AT_BASE);
- if (I != m_auxv->end() && I->value != 0)
- m_interpreter_base = I->value;
+ if (llvm::Optional<uint64_t> interpreter_base =
+ m_auxv->GetAuxValue(AuxVector::AUXV_AT_BASE))
+ m_interpreter_base = *interpreter_base;
}
addr_t DynamicLoaderPOSIXDYLD::GetEntryPoint() {
@@ -644,12 +642,12 @@ addr_t DynamicLoaderPOSIXDYLD::GetEntryPoint() {
if (m_auxv == nullptr)
return LLDB_INVALID_ADDRESS;
- AuxVector::iterator I = m_auxv->FindEntry(AuxVector::AUXV_AT_ENTRY);
-
- if (I == m_auxv->end())
+ llvm::Optional<uint64_t> entry_point =
+ m_auxv->GetAuxValue(AuxVector::AUXV_AT_ENTRY);
+ if (!entry_point)
return LLDB_INVALID_ADDRESS;
- m_entry_point = static_cast<addr_t>(I->value);
+ m_entry_point = static_cast<addr_t>(*entry_point);
const ArchSpec &arch = m_process->GetTarget().GetArchitecture();
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
index d61f1563497..0630d1eb11d 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -13,6 +13,7 @@
#include <memory>
#include "DYLDRendezvous.h"
+#include "Plugins/Process/Utility/AuxVector.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Target/DynamicLoader.h"
diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
index d29a5e8c993..770794569f7 100644
--- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -876,7 +876,7 @@ bool ProcessFreeBSD::IsAThreadRunning() {
return is_running;
}
-const DataBufferSP ProcessFreeBSD::GetAuxvData() {
+lldb_private::DataExtractor ProcessFreeBSD::GetAuxvData() {
// If we're the local platform, we can ask the host for auxv data.
PlatformSP platform_sp = GetTarget().GetPlatform();
assert(platform_sp && platform_sp->IsHost());
@@ -890,7 +890,7 @@ const DataBufferSP ProcessFreeBSD::GetAuxvData() {
buf_sp.reset();
}
- return buf_sp;
+ return DataExtractor(buf_sp, GetByteOrder(), GetAddressByteSize());
}
struct EmulatorBaton {
diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
index 293f7b854b4..8c1b78cda9a 100644
--- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
+++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
@@ -127,7 +127,7 @@ public:
size_t PutSTDIN(const char *buf, size_t len,
lldb_private::Status &error) override;
- const lldb::DataBufferSP GetAuxvData() override;
+ const lldb_private::DataExtractor GetAuxvData() override;
// ProcessFreeBSD internal API.
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index a55dc41bed0..81d257e95e1 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -2082,3 +2082,18 @@ Status NativeProcessLinux::StopProcessorTracingOnThread(lldb::user_id_t traceid,
return error;
}
+
+llvm::Optional<uint64_t>
+NativeProcessLinux::GetAuxValue(enum AuxVector::EntryType type) {
+ if (m_aux_vector == nullptr) {
+ auto buffer_or_error = GetAuxvData();
+ if (!buffer_or_error)
+ return llvm::None;
+ DataExtractor auxv_data(buffer_or_error.get()->getBufferStart(),
+ buffer_or_error.get()->getBufferSize(),
+ GetByteOrder(), GetAddressByteSize());
+ m_aux_vector = llvm::make_unique<AuxVector>(auxv_data);
+ }
+
+ return m_aux_vector->GetAuxValue(type);
+}
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
index 006ae000168..0a67af0a0a4 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
@@ -12,6 +12,7 @@
#include <csignal>
#include <unordered_set>
+#include "Plugins/Process/Utility/AuxVector.h"
#include "lldb/Host/Debug.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/linux/Support.h"
@@ -102,6 +103,8 @@ public:
return getProcFile(GetID(), "auxv");
}
+ llvm::Optional<uint64_t> GetAuxValue(enum AuxVector::EntryType type);
+
lldb::user_id_t StartTrace(const TraceOptions &config,
Status &error) override;
@@ -132,6 +135,7 @@ protected:
private:
MainLoop::SignalHandleUP m_sigchld_handle;
ArchSpec m_arch;
+ std::unique_ptr<AuxVector> m_aux_vector;
LazyBool m_supports_mem_region = eLazyBoolCalculate;
std::vector<std::pair<MemoryRegionInfo, FileSpec>> m_mem_region_cache;
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp b/lldb/source/Plugins/Process/Utility/AuxVector.cpp
index 71d42c8fd99..aab164ff93a 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
+++ b/lldb/source/Plugins/Process/Utility/AuxVector.cpp
@@ -7,98 +7,53 @@
//===----------------------------------------------------------------------===//
#include "AuxVector.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/DataExtractor.h"
-#include "lldb/Utility/Log.h"
-using namespace lldb;
-using namespace lldb_private;
-
-static bool GetMaxU64(DataExtractor &data, lldb::offset_t *offset_ptr,
- uint64_t *value, unsigned int byte_size) {
- lldb::offset_t saved_offset = *offset_ptr;
- *value = data.GetMaxU64(offset_ptr, byte_size);
- return *offset_ptr != saved_offset;
-}
-
-static bool ParseAuxvEntry(DataExtractor &data, AuxVector::Entry &entry,
- lldb::offset_t *offset_ptr, unsigned int byte_size) {
- if (!GetMaxU64(data, offset_ptr, &entry.type, byte_size))
- return false;
-
- if (!GetMaxU64(data, offset_ptr, &entry.value, byte_size))
- return false;
-
- return true;
-}
-
-DataBufferSP AuxVector::GetAuxvData() {
- if (m_process)
- return m_process->GetAuxvData();
- else
- return DataBufferSP();
+AuxVector::AuxVector(const lldb_private::DataExtractor &data) {
+ ParseAuxv(data);
}
-void AuxVector::ParseAuxv(DataExtractor &data) {
- const unsigned int byte_size = m_process->GetAddressByteSize();
+void AuxVector::ParseAuxv(const lldb_private::DataExtractor &data) {
lldb::offset_t offset = 0;
-
- for (;;) {
- Entry entry;
-
- if (!ParseAuxvEntry(data, entry, &offset, byte_size))
+ const size_t value_type_size = data.GetAddressByteSize() * 2;
+ while (data.ValidOffsetForDataOfSize(offset, value_type_size)) {
+ // We're not reading an address but an int that could be 32 or 64 bit
+ // depending on the address size, which is what GetAddress does.
+ const uint64_t type = data.GetAddress(&offset);
+ const uint64_t value = data.GetAddress(&offset);
+ if (type == AUXV_AT_NULL)
break;
-
- if (entry.type == AUXV_AT_NULL)
- break;
-
- if (entry.type == AUXV_AT_IGNORE)
+ if (type == AUXV_AT_IGNORE)
continue;
- m_auxv.push_back(entry);
+ m_auxv_entries[type] = value;
}
}
-AuxVector::AuxVector(Process *process) : m_process(process) {
- DataExtractor data;
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
-
- data.SetData(GetAuxvData());
- data.SetByteOrder(m_process->GetByteOrder());
- data.SetAddressByteSize(m_process->GetAddressByteSize());
-
- ParseAuxv(data);
-
- if (log)
- DumpToLog(log);
-}
-
-AuxVector::iterator AuxVector::FindEntry(EntryType type) const {
- for (iterator I = begin(); I != end(); ++I) {
- if (I->type == static_cast<uint64_t>(type))
- return I;
- }
-
- return end();
+llvm::Optional<uint64_t>
+AuxVector::GetAuxValue(enum EntryType entry_type) const {
+ auto it = m_auxv_entries.find(static_cast<uint64_t>(entry_type));
+ if (it != m_auxv_entries.end())
+ return it->second;
+ return llvm::None;
}
-void AuxVector::DumpToLog(Log *log) const {
+void AuxVector::DumpToLog(lldb_private::Log *log) const {
if (!log)
return;
log->PutCString("AuxVector: ");
- for (iterator I = begin(); I != end(); ++I) {
- log->Printf(" %s [%" PRIu64 "]: %" PRIx64, GetEntryName(*I), I->type,
- I->value);
+ for (auto entry : m_auxv_entries) {
+ log->Printf(" %s [%" PRIu64 "]: %" PRIx64,
+ GetEntryName(static_cast<EntryType>(entry.first)), entry.first,
+ entry.second);
}
}
-const char *AuxVector::GetEntryName(EntryType type) {
+const char *AuxVector::GetEntryName(EntryType type) const {
const char *name = "AT_???";
-#define ENTRY_NAME(_type) \
- _type: \
+#define ENTRY_NAME(_type) \
+ _type: \
name = &#_type[5]
switch (type) {
case ENTRY_NAME(AUXV_AT_NULL); break;
diff --git a/lldb/source/Plugins/Process/Utility/AuxVector.h b/lldb/source/Plugins/Process/Utility/AuxVector.h
new file mode 100644
index 00000000000..c16be68aedb
--- /dev/null
+++ b/lldb/source/Plugins/Process/Utility/AuxVector.h
@@ -0,0 +1,73 @@
+//===-- AuxVector.h ---------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_AuxVector_H_
+#define liblldb_AuxVector_H_
+
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
+#include <unordered_map>
+
+class AuxVector {
+
+public:
+ AuxVector(const lldb_private::DataExtractor &data);
+
+ /// Constants describing the type of entry.
+ /// On Linux, running "LD_SHOW_AUXV=1 ./executable" will spew AUX
+ /// information. Added AUXV prefix to avoid potential conflicts with system-
+ /// defined macros
+ enum EntryType {
+ AUXV_AT_NULL = 0, ///< End of auxv.
+ AUXV_AT_IGNORE = 1, ///< Ignore entry.
+ AUXV_AT_EXECFD = 2, ///< File descriptor of program.
+ AUXV_AT_PHDR = 3, ///< Program headers.
+ AUXV_AT_PHENT = 4, ///< Size of program header.
+ AUXV_AT_PHNUM = 5, ///< Number of program headers.
+ AUXV_AT_PAGESZ = 6, ///< Page size.
+ AUXV_AT_BASE = 7, ///< Interpreter base address.
+ AUXV_AT_FLAGS = 8, ///< Flags.
+ AUXV_AT_ENTRY = 9, ///< Program entry point.
+ AUXV_AT_NOTELF = 10, ///< Set if program is not an ELF.
+ AUXV_AT_UID = 11, ///< UID.
+ AUXV_AT_EUID = 12, ///< Effective UID.
+ AUXV_AT_GID = 13, ///< GID.
+ AUXV_AT_EGID = 14, ///< Effective GID.
+ AUXV_AT_CLKTCK = 17, ///< Clock frequency (e.g. times(2)).
+ AUXV_AT_PLATFORM = 15, ///< String identifying platform.
+ AUXV_AT_HWCAP =
+ 16, ///< Machine dependent hints about processor capabilities.
+ AUXV_AT_FPUCW = 18, ///< Used FPU control word.
+ AUXV_AT_DCACHEBSIZE = 19, ///< Data cache block size.
+ AUXV_AT_ICACHEBSIZE = 20, ///< Instruction cache block size.
+ AUXV_AT_UCACHEBSIZE = 21, ///< Unified cache block size.
+ AUXV_AT_IGNOREPPC = 22, ///< Entry should be ignored.
+ AUXV_AT_SECURE = 23, ///< Boolean, was exec setuid-like?
+ AUXV_AT_BASE_PLATFORM = 24, ///< String identifying real platforms.
+ AUXV_AT_RANDOM = 25, ///< Address of 16 random bytes.
+ AUXV_AT_EXECFN = 31, ///< Filename of executable.
+ AUXV_AT_SYSINFO = 32, ///< Pointer to the global system page used for system
+ /// calls and other nice things.
+ AUXV_AT_SYSINFO_EHDR = 33,
+ AUXV_AT_L1I_CACHESHAPE = 34, ///< Shapes of the caches.
+ AUXV_AT_L1D_CACHESHAPE = 35,
+ AUXV_AT_L2_CACHESHAPE = 36,
+ AUXV_AT_L3_CACHESHAPE = 37,
+ };
+
+ llvm::Optional<uint64_t> GetAuxValue(enum EntryType entry_type) const;
+ void DumpToLog(lldb_private::Log *log) const;
+ const char *GetEntryName(EntryType type) const;
+
+private:
+ void ParseAuxv(const lldb_private::DataExtractor &data);
+
+ std::unordered_map<uint64_t, uint64_t> m_auxv_entries;
+};
+
+#endif
diff --git a/lldb/source/Plugins/Process/Utility/CMakeLists.txt b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
index e36ce4dec98..9ed2d020a4c 100644
--- a/lldb/source/Plugins/Process/Utility/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
@@ -1,4 +1,5 @@
add_lldb_library(lldbPluginProcessUtility PLUGIN
+ AuxVector.cpp
DynamicRegisterInfo.cpp
FreeBSDSignals.cpp
GDBRemoteSignals.cpp
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index f40ff130cf5..980169e16c5 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -894,11 +894,11 @@ ArchSpec ProcessElfCore::GetArchitecture() {
return arch;
}
-const lldb::DataBufferSP ProcessElfCore::GetAuxvData() {
+DataExtractor ProcessElfCore::GetAuxvData() {
const uint8_t *start = m_auxv.GetDataStart();
size_t len = m_auxv.GetByteSize();
lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len));
- return buffer;
+ return DataExtractor(buffer, GetByteOrder(), GetAddressByteSize());
}
bool ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info) {
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index 6828f5a42ff..829fe9ac719 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -97,7 +97,7 @@ public:
lldb_private::ArchSpec GetArchitecture();
// Returns AUXV structure found in the core file
- const lldb::DataBufferSP GetAuxvData() override;
+ lldb_private::DataExtractor GetAuxvData() override;
bool GetProcessInfo(lldb_private::ProcessInstanceInfo &info) override;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index c4df4e716d0..194e79085a0 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4046,7 +4046,7 @@ Status ProcessGDBRemote::SendEventData(const char *data) {
return error;
}
-const DataBufferSP ProcessGDBRemote::GetAuxvData() {
+DataExtractor ProcessGDBRemote::GetAuxvData() {
DataBufferSP buf;
if (m_gdb_comm.GetQXferAuxvReadSupported()) {
std::string response_string;
@@ -4056,7 +4056,7 @@ const DataBufferSP ProcessGDBRemote::GetAuxvData() {
buf = std::make_shared<DataBufferHeap>(response_string.c_str(),
response_string.length());
}
- return buf;
+ return DataExtractor(buf, GetByteOrder(), GetAddressByteSize());
}
StructuredData::ObjectSP
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index a82b0950a6e..83c4807ed59 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -324,7 +324,7 @@ protected:
bool ParsePythonTargetDefinition(const FileSpec &target_definition_fspec);
- const lldb::DataBufferSP GetAuxvData() override;
+ DataExtractor GetAuxvData() override;
StructuredData::ObjectSP GetExtendedInfoForThread(lldb::tid_t tid);
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 1f2305ac832..84840523519 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2708,7 +2708,7 @@ DynamicLoader *Process::GetDynamicLoader() {
return m_dyld_up.get();
}
-const lldb::DataBufferSP Process::GetAuxvData() { return DataBufferSP(); }
+DataExtractor Process::GetAuxvData() { return DataExtractor(); }
JITLoaderList &Process::GetJITLoaders() {
if (!m_jit_loaders_up) {
OpenPOWER on IntegriCloud