[Lldb-commits] [lldb] [lldb] Fix address to read segment data (PR #120655)

via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 19 16:04:14 PST 2024


https://github.com/GeorgeHuyubo created https://github.com/llvm/llvm-project/pull/120655

Previous commit https://github.com/llvm/llvm-project/commit/bcf654c7f5fb84dd7cff5fe112d96658853cd8f5
introduced a bug which makes lldb unable to parse gnu build id for the main executable from a core file.

This PR fix it by replace p_vaddr with p_offset.

Tested with core files with ELF headers off all modules. LLDB is able to parse the gnu build id for main executable as well as other shared libs.

>From 9cab114ab9929c0cebb6c89b8d18006711b8b79a Mon Sep 17 00:00:00 2001
From: George Hu <hyubo at meta.com>
Date: Thu, 19 Dec 2024 15:38:12 -0800
Subject: [PATCH] [lldb] Fix address to read segment data

---
 lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index b3916cc913f7db..cf3e056a20a049 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -1047,9 +1047,9 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
     std::vector<uint8_t> note_bytes;
     note_bytes.resize(program_header.p_memsz);
 
-    // We need to slide the address of the p_vaddr as these values don't get
+    // We need to slide the address of the p_offset as these values don't get
     // relocated in memory.
-    const lldb::addr_t vaddr = program_header.p_vaddr + address;
+    const lldb::addr_t vaddr = program_header.p_offset + address;
     byte_read =
         ReadMemory(vaddr, note_bytes.data(), program_header.p_memsz, error);
     if (byte_read != program_header.p_memsz)



More information about the lldb-commits mailing list