Skip to content

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Aug 13, 2025

Some functions don't have the FunctionType set. We can't look these up and won't be able to call them, so ignore them when caching the function names.

This does fix the failures caused by #153160 mentioned in #153160 (comment). However, in lldb-shell::msstl_smoke.cpp there's another failure not introduced by #153160 (fixed with #153386).

@Nerixyz Nerixyz requested a review from JDevlieghere as a code owner August 13, 2025 10:23
@Nerixyz
Copy link
Contributor Author

Nerixyz commented Aug 13, 2025

CC @slydiman

@llvmbot llvmbot added the lldb label Aug 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 13, 2025

@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)

Changes

Some functions don't have the FunctionType set. We can't look these up and won't be able to call them, so ignore them when caching the function names.

This does fix the failures caused by #153160 mentioned in #153160 (comment). However, in lldb-shell::msstl_smoke.cpp there's another failure not introduced by #153160.


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

1 Files Affected:

  • (modified) lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp (+1-1)
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 986d647b4de2d..5b2e12101d26e 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1675,7 +1675,7 @@ void SymbolFileNativePDB::CacheFunctionNames() {
         llvm::cantFail(SymbolDeserializer::deserializeAs<ProcSym>(*iter));
     if ((proc.Flags & ProcSymFlags::IsUnreachable) != ProcSymFlags::None)
       continue;
-    if (proc.Name.empty())
+    if (proc.Name.empty() || proc.FunctionType.isNoneType())
       continue;
 
     // The function/procedure symbol only contains the demangled name.

@Michael137
Copy link
Member

Michael137 commented Aug 13, 2025

Could you elaborate in the PR description why these "no prototype functions" would cause issues if we cached them?

@Nerixyz
Copy link
Contributor Author

Nerixyz commented Aug 13, 2025

Could you elaborate in the PR description why these "no prototype functions" would cause issues if we cached them?

A bit later in the function, we look up the function type:

auto type = m_index->tpi().getType(proc.FunctionType);

In PDB, types with an index lower than 0x1000 are simple/primitive types. These types are predefined and won't occur in the type streams. Or rather: the type streams start from 0x1000, so this is subtracted from every type index to get to the array index. The none type is 0 and we'd overflow. LLVM has an assert in this function which caught this.

@Michael137
Copy link
Member

Could you elaborate in the PR description why these "no prototype functions" would cause issues if we cached them?

A bit later in the function, we look up the function type:

auto type = m_index->tpi().getType(proc.FunctionType);

In PDB, types with an index lower than 0x1000 are simple/primitive types. These types are predefined and won't occur in the type streams. Or rather: the type streams start from 0x1000, so this is subtracted from every type index to get to the array index. The none type is 0 and we'd overflow. LLVM has an assert in this function which caught this.

Ah gotcha. Thanks for the context. It would be more obvious if we guarded this on TypeIndex::isSimple then (see inline comment)

@@ -1675,7 +1675,7 @@ void SymbolFileNativePDB::CacheFunctionNames() {
llvm::cantFail(SymbolDeserializer::deserializeAs<ProcSym>(*iter));
if ((proc.Flags & ProcSymFlags::IsUnreachable) != ProcSymFlags::None)
continue;
if (proc.Name.empty())
if (proc.Name.empty() || proc.FunctionType.isNoneType())
Copy link
Member

@Michael137 Michael137 Aug 14, 2025

Choose a reason for hiding this comment

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

Would proc.FunctionType.isSimple() be more robust? Or can FunctionType never be "simple"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, it would be more robust, let's do that. I couldn't think of a case where the type would be simple and not none (i.e. a primitive type). But in that case, we should still skip the function.

@Michael137 Michael137 merged commit 7bda763 into llvm:main Aug 14, 2025
9 checks passed
@Nerixyz Nerixyz deleted the fix/lldb-tests branch August 14, 2025 13:57
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.

3 participants