From 3b0f38bb5186cdda52ab38b13965678036aba22c Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Tue, 18 Oct 2022 15:58:07 -0700 Subject: [PATCH] [LLDB][NativePDB] Fix parameter size for member functions LF_MFUNCTION Fix the problem that it was treating member functions as non-member functions when trying to get the parameter size. This causes some non-parameter variables showing up in function signature. Suprisingly, `cantFail(TypeDeserializer::deserializeAs(...))` just sliently parse it without error and gave the wrong result. It's hard to test it. This only causes problem when `params_remaining` is larger than the real parameter size. If it's smaller, we also check individual local variable's attribute to see it's a parameter. When I trying to come up with a test, the parameter size is always 0 if we parse LF_MFUNCTION as LF_PROCEDURE. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D136209 --- .../SymbolFile/NativePDB/SymbolFileNativePDB.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index a34ce04..8fdd23d 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1897,9 +1897,24 @@ size_t SymbolFileNativePDB::ParseVariablesForBlock(PdbCompilandSymId block_id) { ProcSym proc(static_cast(sym.kind())); cantFail(SymbolDeserializer::deserializeAs(sym, proc)); CVType signature = m_index->tpi().getType(proc.FunctionType); - ProcedureRecord sig; - cantFail(TypeDeserializer::deserializeAs(signature, sig)); - params_remaining = sig.getParameterCount(); + if (signature.kind() == LF_PROCEDURE) { + ProcedureRecord sig; + if (llvm::Error e = TypeDeserializer::deserializeAs( + signature, sig)) { + llvm::consumeError(std::move(e)); + return 0; + } + params_remaining = sig.getParameterCount(); + } else if (signature.kind() == LF_MFUNCTION) { + MemberFunctionRecord sig; + if (llvm::Error e = TypeDeserializer::deserializeAs( + signature, sig)) { + llvm::consumeError(std::move(e)); + return 0; + } + params_remaining = sig.getParameterCount(); + } else + return 0; break; } case S_BLOCK32: -- 2.7.4