Skip to content

[lldb][NativePDB] Introduce PdbAstBuilderSwift#12317

Open
speednoisemovement wants to merge 4 commits intoswiftlang:stable/21.xfrom
speednoisemovement:ast_swift
Open

[lldb][NativePDB] Introduce PdbAstBuilderSwift#12317
speednoisemovement wants to merge 4 commits intoswiftlang:stable/21.xfrom
speednoisemovement:ast_swift

Conversation

@speednoisemovement
Copy link

Introduces a Swift-specific PdbAstBuilder, PdbAstBuilderSwift and wires it up to TypeSystemSwift.

This brings support for printing locals when using the NativePDB backend. See the tests for some known-working types.

Generics are blocked by swiftlang/swift#87093 and let constants are forthcoming.

This brings support for printing locals when using the NativePDB
backend. See the tests for some known-working types.

Generics are blocked by swiftlang/swift#87093
and let constants are forthcoming.
@speednoisemovement speednoisemovement requested a review from a team as a code owner February 9, 2026 23:43
@@ -0,0 +1,65 @@
//===------------------------------------------------------------*- C++ -*-===//

Choose a reason for hiding this comment

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

The LLVM coding style recently abandoned the emacs language markers -*- C++ -*-

Copy link
Author

Choose a reason for hiding this comment

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

Done

return false;
ClassRecord cr;
llvm::cantFail(TypeDeserializer::deserializeAs<ClassRecord>(cvt, cr));
return cr.hasUniqueName() && cr.UniqueName.starts_with("$s");

Choose a reason for hiding this comment

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

Swift types can start with a number of mangling prefixes (_T, $s, $e). Can you check if we have a helper for this already, either in Mangled or in LanguageRuntimeSwiftNames.cpp, and if we really don't, create one?

Copy link
Author

Choose a reason for hiding this comment

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

Perfect, thanks! Done

@@ -0,0 +1,90 @@
#include "PdbAstBuilderSwift.h"
Copy link
Member

Choose a reason for hiding this comment

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

Missing LLVM header

Copy link
Author

Choose a reason for hiding this comment

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

Done

Comment on lines 77 to 81
CompilerType ct;
if (best_type.index != type.index)
ct = GetOrCreateType(best_type);
else
ct = CreateType(type, index.tpi());
Copy link
Member

Choose a reason for hiding this comment

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

I'd use a ternary.

Copy link
Author

Choose a reason for hiding this comment

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

Done


# RUN: split-file %s %t
# RUN: %target-swiftc -v -g -debug-info-format=codeview %t/main.swift -o %t.exe -Xlinker -debug -use-ld=lld
# RUN: %lldb -x -b -s %t/commands.input %t.exe -o exit 2>&1 | FileCheck %s

Choose a reason for hiding this comment

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

This kind of Shell test makes sense for narrow testing of specific parser behavior.
Going forward we need to find a way to run the entire LLDB API test suite in PDB mode. My thinking is that we probably should introduce a category at the same level as the dwarf/dsym/dwo debug info formats and sue that to automatically generate PDB variants of all tests.
This does not have to happen in this PR, but we should get started on that soon so we have a better idea of what works and what doesn't.

Copy link
Author

Choose a reason for hiding this comment

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

Ack. I'll start paging this in

# Pre-emptively skipping since it won't pass until the following
# is fixed:
# https://github.com/swiftlang/llvm-project/issues/12289
skip lldb-shell :: SymbolFile/NativePDB/swift-frame-var.test

Choose a reason for hiding this comment

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

Should we mark the test as XFAIL instead in lldb/test/Shell/SymbolFile/NativePDB/swift-frame-var.test ?

AFAIK, windows-swift-llvm-lit-test-overrides.txt is for upstream tests which fail downstream.

Copy link
Author

Choose a reason for hiding this comment

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

Thank, done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants