[Lldb-commits] [lldb] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() (PR #102263)

Igor Kudrin via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 6 19:13:15 PDT 2024


https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/102263

There is no need to clone the content and set extraction properties because `m_auxv` is already in the required form.

>From d3a72694e444cf19e62bceab3234b8a338aec7b1 Mon Sep 17 00:00:00 2001
From: Igor Kudrin <ikudrin at accesssoftek.com>
Date: Tue, 6 Aug 2024 18:33:01 -0700
Subject: [PATCH] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData()

There is no need to create a new `DataExtractor` and clone the content,
because `m_auxv` already has the required form.
---
 lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 30af9345999c41..e73e31ca78d19f 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -1077,10 +1077,10 @@ ArchSpec ProcessElfCore::GetArchitecture() {
 }
 
 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 DataExtractor(buffer, GetByteOrder(), GetAddressByteSize());
+  assert(m_auxv.GetByteSize() == 0 ||
+         (m_auxv.GetByteOrder() == GetByteOrder() &&
+          m_auxv.GetAddressByteSize() == GetAddressByteSize()));
+  return DataExtractor(m_auxv);
 }
 
 bool ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info) {



More information about the lldb-commits mailing list