https://github.com/Nerixyz updated https://github.com/llvm/llvm-project/pull/166090
>From 51316c3a3a87cdc425dba02704c7930d7d374416 Mon Sep 17 00:00:00 2001 From: Nerixyz <[email protected]> Date: Sun, 2 Nov 2025 20:20:03 +0100 Subject: [PATCH 1/3] [LLDB][NativePDB] Check function type before casting --- lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index e7fddf08967fb..85f0c3873447b 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -1010,7 +1010,8 @@ PdbAstBuilder::CreateFunctionDeclFromId(PdbTypeSymId func_tid, lldbassert(false && "Invalid function id type!"); } clang::QualType func_qt = GetOrCreateType(func_ti); - if (func_qt.isNull() || !parent) + if (func_qt.isNull() || !parent || + !llvm::isa<clang::FunctionProtoType>(func_qt)) return nullptr; CompilerType func_ct = ToCompilerType(func_qt); uint32_t param_count = >From 7d7cad2a9d9599284db4c97a6516efdd57dca5f7 Mon Sep 17 00:00:00 2001 From: Nerixyz <[email protected]> Date: Wed, 5 Nov 2025 14:32:58 +0100 Subject: [PATCH 2/3] feat: add test for this --- .../invalid-func-type-in-inlinee.yaml | 300 ++++++++++++++++++ .../Shell/SymbolFile/NativePDB/lit.local.cfg | 1 + 2 files changed, 301 insertions(+) create mode 100644 lldb/test/Shell/SymbolFile/NativePDB/invalid-func-type-in-inlinee.yaml diff --git a/lldb/test/Shell/SymbolFile/NativePDB/invalid-func-type-in-inlinee.yaml b/lldb/test/Shell/SymbolFile/NativePDB/invalid-func-type-in-inlinee.yaml new file mode 100644 index 0000000000000..1a63955fa2f03 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/invalid-func-type-in-inlinee.yaml @@ -0,0 +1,300 @@ +# RUN: llvm-pdbutil yaml2pdb %s --pdb=%t +# RUN: lldb-test symbols %t | FileCheck %s + +# CHECK: CompileUnit +# CHECK: Function{{.*}}, demangled = main, +# CHECK-NEXT: Block{{.*}} +# CHECK-NEXT: Variable{{.*}}, name = "argc", type = {{.*}} (int), scope = parameter +# CHECK-NEXT: Variable{{.*}}, name = "argv", type = {{.*}} (char **), scope = parameter +# CHECK-NEXT: Block{{.*}}, parent = {{.*}}, name = "foo", decl = inline_sites_live.cpp:14 +# CHECK-NEXT: Variable{{.*}}, name = "param", type = {{.*}} (int), scope = parameter +# CHECK-NEXT: Variable{{.*}}, name = "local", type = {{.*}} (int), scope = local +--- +MSF: + SuperBlock: + FreeBlockMap: 2 + NumBlocks: 18 + NumDirectoryBytes: 116 + BlockMapAddr: 3 + NumDirectoryBlocks: 1 + DirectoryBlocks: [ 17 ] + NumStreams: 15 + FileSize: 73728 +DbiStream: + BuildNumber: 36363 + Flags: 0 + MachineType: Amd64 + Modules: + - Module: 'C:\Users\johannes\AppData\Local\Temp\inline_sites_live-2a62f2.o' + SourceFiles: + - 'F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\inline_sites_live.cpp' + Subsections: + - !InlineeLines + HasExtraFiles: false + Sites: + - FileName: 'F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\inline_sites_live.cpp' + LineNum: 14 + Inlinee: 4096 + - !Lines + CodeSize: 17 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 1 + Blocks: + - FileName: 'F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\inline_sites_live.cpp' + Lines: + - Offset: 0 + LineStart: 14 + IsStatement: false + EndDelta: 0 + - Offset: 5 + LineStart: 15 + IsStatement: false + EndDelta: 0 + - Offset: 15 + LineStart: 19 + IsStatement: false + EndDelta: 0 + Columns: [] + - !FileChecksums + Checksums: + - FileName: 'F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\inline_sites_live.cpp' + Kind: MD5 + Checksum: 856E65504B68E2EF155921DFCCB753CE + Modi: + Records: + - Kind: S_OBJNAME + ObjNameSym: + Signature: 0 + ObjectName: 'C:\Users\johannes\AppData\Local\Temp\inline_sites_live-2a62f2.o' + - Kind: S_COMPILE3 + Compile3Sym: + Flags: [ ] + Machine: X64 + FrontendMajor: 19 + FrontendMinor: 1 + FrontendBuild: 5 + FrontendQFE: 0 + BackendMajor: 19015 + BackendMinor: 0 + BackendBuild: 0 + BackendQFE: 0 + Version: clang version 19.1.5 + - Kind: S_GPROC32 + ProcSym: + PtrEnd: 264 + CodeSize: 17 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4097 + Segment: 1 + Flags: [ HasOptimizedDebugInfo ] + DisplayName: foo + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 8 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ SafeBuffers ] + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ IsParameter ] + VarName: param + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 4 + Range: + OffsetStart: 5 + ISectStart: 1 + Range: 12 + Gaps: [] + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ ] + VarName: local + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 0 + Range: + OffsetStart: 5 + ISectStart: 1 + Range: 12 + Gaps: [] + - Kind: S_END + ScopeEndSym: {} + - Kind: S_GPROC32 + ProcSym: + PtrEnd: 512 + CodeSize: 39 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4100 + Offset: 32 + Segment: 1 + Flags: [ IsNoInline, HasOptimizedDebugInfo ] + DisplayName: main + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 24 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ SafeBuffers ] + - Kind: S_INLINEES + CallerSym: + FuncID: [ 4096 ] + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ IsParameter ] + VarName: argc + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 4 + Range: + OffsetStart: 45 + ISectStart: 1 + Range: 26 + Gaps: [] + - Kind: S_LOCAL + LocalSym: + Type: 4098 + Flags: [ IsParameter ] + VarName: argv + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 8 + Range: + OffsetStart: 45 + ISectStart: 1 + Range: 26 + Gaps: [] + - Kind: S_INLINESITE + InlineSiteSym: + PtrParent: 268 + PtrEnd: 508 + Inlinee: 4096 + AnnotationData: [ 6, 2, 3, 21, 4, 11, 0, 0 ] + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ IsParameter ] + VarName: param + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 20 + Range: + OffsetStart: 53 + ISectStart: 1 + Range: 11 + Gaps: [] + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ ] + VarName: local + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 16 + Range: + OffsetStart: 53 + ISectStart: 1 + Range: 11 + Gaps: [] + - Kind: S_INLINESITE_END + ScopeEndSym: {} + - Kind: S_END + ScopeEndSym: {} + SectionHeaders: + - Name: .text + VirtualSize: 71 + VirtualAddress: 4096 + SizeOfRawData: 512 + PointerToRawData: 1024 + PointerToRelocations: 0 + PointerToLinenumbers: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + Characteristics: 1610612768 + - Name: .rdata + VirtualSize: 100 + VirtualAddress: 8192 + SizeOfRawData: 512 + PointerToRawData: 1536 + PointerToRelocations: 0 + PointerToLinenumbers: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + Characteristics: 1073741888 + - Name: .pdata + VirtualSize: 24 + VirtualAddress: 12288 + SizeOfRawData: 512 + PointerToRawData: 2048 + PointerToRelocations: 0 + PointerToLinenumbers: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + Characteristics: 1073741888 +TpiStream: + Records: + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 3 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4096 + - Kind: LF_POINTER + Pointer: + ReferentType: 1648 + Attrs: 65548 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116, 4098 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 116 + CallConv: NearC + Options: [ None ] + ParameterCount: 2 + ArgumentList: 4099 +IpiStream: + Records: + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 0x1002 # this points to the wrong type (LF_POINTER) + Name: foo + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4100 + Name: main + - Kind: LF_BUILDINFO + BuildInfo: + ArgIndices: [ 4098, 4101, 4099, 4100, 4102 ] +PublicsStream: + Records: + - Kind: S_PUB32 + PublicSym32: + Flags: [ Function ] + Offset: 32 + Segment: 1 + Name: main + - Kind: S_PUB32 + PublicSym32: + Flags: [ Function ] + Segment: 1 + Name: '?foo@@YAXH@Z' +... diff --git a/lldb/test/Shell/SymbolFile/NativePDB/lit.local.cfg b/lldb/test/Shell/SymbolFile/NativePDB/lit.local.cfg index 02bc504eea55c..e24875fdad5d4 100644 --- a/lldb/test/Shell/SymbolFile/NativePDB/lit.local.cfg +++ b/lldb/test/Shell/SymbolFile/NativePDB/lit.local.cfg @@ -1 +1,2 @@ config.environment["LLDB_USE_NATIVE_PDB_READER"] = "1" +config.suffixes = ['.cpp', '.ll', '.s', '.test', '.yaml'] >From 81f1cf0bbad276470cdb82861f3a909069aeb25d Mon Sep 17 00:00:00 2001 From: Nerixyz <[email protected]> Date: Wed, 19 Nov 2025 17:55:35 +0100 Subject: [PATCH 3/3] fix: reorder for readability --- .../invalid-func-type-in-inlinee.yaml | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/lldb/test/Shell/SymbolFile/NativePDB/invalid-func-type-in-inlinee.yaml b/lldb/test/Shell/SymbolFile/NativePDB/invalid-func-type-in-inlinee.yaml index 1a63955fa2f03..fc133efaa918d 100644 --- a/lldb/test/Shell/SymbolFile/NativePDB/invalid-func-type-in-inlinee.yaml +++ b/lldb/test/Shell/SymbolFile/NativePDB/invalid-func-type-in-inlinee.yaml @@ -20,6 +20,47 @@ MSF: DirectoryBlocks: [ 17 ] NumStreams: 15 FileSize: 73728 +IpiStream: + Records: + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 0x1002 # this points to the wrong type (LF_POINTER) + Name: foo + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4100 + Name: main + - Kind: LF_BUILDINFO + BuildInfo: + ArgIndices: [ 4098, 4101, 4099, 4100, 4102 ] +TpiStream: + Records: + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 3 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4096 + - Kind: LF_POINTER + Pointer: + ReferentType: 1648 + Attrs: 65548 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116, 4098 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 116 + CallConv: NearC + Options: [ None ] + ParameterCount: 2 + ArgumentList: 4099 DbiStream: BuildNumber: 36363 Flags: 0 @@ -243,47 +284,6 @@ DbiStream: NumberOfRelocations: 0 NumberOfLinenumbers: 0 Characteristics: 1073741888 -TpiStream: - Records: - - Kind: LF_ARGLIST - ArgList: - ArgIndices: [ 116 ] - - Kind: LF_PROCEDURE - Procedure: - ReturnType: 3 - CallConv: NearC - Options: [ None ] - ParameterCount: 1 - ArgumentList: 4096 - - Kind: LF_POINTER - Pointer: - ReferentType: 1648 - Attrs: 65548 - - Kind: LF_ARGLIST - ArgList: - ArgIndices: [ 116, 4098 ] - - Kind: LF_PROCEDURE - Procedure: - ReturnType: 116 - CallConv: NearC - Options: [ None ] - ParameterCount: 2 - ArgumentList: 4099 -IpiStream: - Records: - - Kind: LF_FUNC_ID - FuncId: - ParentScope: 0 - FunctionType: 0x1002 # this points to the wrong type (LF_POINTER) - Name: foo - - Kind: LF_FUNC_ID - FuncId: - ParentScope: 0 - FunctionType: 4100 - Name: main - - Kind: LF_BUILDINFO - BuildInfo: - ArgIndices: [ 4098, 4101, 4099, 4100, 4102 ] PublicsStream: Records: - Kind: S_PUB32 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
