Skip to content

Bug fix in FindModuleUUID #137075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged

Bug fix in FindModuleUUID #137075

merged 1 commit into from
Apr 23, 2025

Conversation

GeorgeHuyubo
Copy link
Contributor

In some core file, we are seeing that it's not always the case that the ELF header would exist in the first region in NT_FILES section. Therefore the FindModuleUUID is not able to find the module UUID by just returning the first entry with path matching.

This fix change the behavior to continue search the NT_FILE entries until finding a valid UUID with path matching.

@llvmbot
Copy link
Member

llvmbot commented Apr 23, 2025

@llvm/pr-subscribers-lldb

Author: None (GeorgeHuyubo)

Changes

In some core file, we are seeing that it's not always the case that the ELF header would exist in the first region in NT_FILES section. Therefore the FindModuleUUID is not able to find the module UUID by just returning the first entry with path matching.

This fix change the behavior to continue search the NT_FILE entries until finding a valid UUID with path matching.


Full diff: https://github.com/llvm/llvm-project/pull/137075.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp (+1-1)
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 5f85f99ce7bdd..6635b15b669f1 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -289,7 +289,7 @@ void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
 UUID ProcessElfCore::FindModuleUUID(const llvm::StringRef path) {
   // Returns the gnu uuid from matched NT_FILE entry
   for (NT_FILE_Entry &entry : m_nt_file_entries)
-    if (path == entry.path)
+    if (path == entry.path && entry.uuid.IsValid())
       return entry.uuid;
   return UUID();
 }

@GeorgeHuyubo GeorgeHuyubo requested a review from clayborg April 23, 2025 22:31
Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Any chance you could artifically craft such a core file for a test?

@GeorgeHuyubo
Copy link
Contributor Author

LGTM. Any chance you could artifically craft such a core file for a test?

I think this file historically lack a good way of testing changes due to difficulties in hand craft a ELF core file using YAML.

@GeorgeHuyubo GeorgeHuyubo merged commit d72f1f9 into llvm:main Apr 23, 2025
10 of 11 checks passed
@clayborg
Copy link
Collaborator

LGTM. Any chance you could artifically craft such a core file for a test?

The ELF support yaml2obj doesn't allow content to be supplied for a program header. It expects section headers to contain data and ELF core files don't have section headers. So it would take some modifications to the ELF obj2yaml and yaml2obj to support this. It would be great if we can add this support at some point if anyone has expertise in the yaml layer as it would be easy to create a core file, reduce it using a different tool, and then obj2yaml it for a test.

IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
In some core file, we are seeing that it's not always the case that the
ELF header would exist in the first region in NT_FILES section.
Therefore the FindModuleUUID is not able to find the module UUID by just
returning the first entry with path matching.

This fix change the behavior to continue search the NT_FILE entries
until finding a valid UUID with path matching.

Co-authored-by: George Hu <[email protected]>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
In some core file, we are seeing that it's not always the case that the
ELF header would exist in the first region in NT_FILES section.
Therefore the FindModuleUUID is not able to find the module UUID by just
returning the first entry with path matching.

This fix change the behavior to continue search the NT_FILE entries
until finding a valid UUID with path matching.

Co-authored-by: George Hu <[email protected]>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
In some core file, we are seeing that it's not always the case that the
ELF header would exist in the first region in NT_FILES section.
Therefore the FindModuleUUID is not able to find the module UUID by just
returning the first entry with path matching.

This fix change the behavior to continue search the NT_FILE entries
until finding a valid UUID with path matching.

Co-authored-by: George Hu <[email protected]>
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
In some core file, we are seeing that it's not always the case that the
ELF header would exist in the first region in NT_FILES section.
Therefore the FindModuleUUID is not able to find the module UUID by just
returning the first entry with path matching.

This fix change the behavior to continue search the NT_FILE entries
until finding a valid UUID with path matching.

Co-authored-by: George Hu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants