Skip to content

Fix LLDB Swift data formatters breaking Swift code debugging #72601

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
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions utils/lldb/lldbSwiftDataFormatters.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
"""
LLDB Formatters for LLVM data types for use in the swift project.

Load into LLDB with 'command script import /path/to/lldbDataFormatters.py'
Load into LLDB with 'command script import /path/to/lldbSwiftDataFormatters.py'
"""

import sys
from enum import Enum


def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('type category define -e swift -l c++')
category = 'swift-compiler-internals'
debugger.HandleCommand(f'type category define -e {category} -l c++')

tName = 'lldbSwiftDataFormatters.SmallBitVectorSummaryProvider'
debugger.HandleCommand('type summary add -w llvm '
'-F %s -x "^llvm::SmallBitVector$"' % tName)
debugger.HandleCommand('type summary add --expand --skip-references -w swift '
f'-F {tName} -x "^llvm::SmallBitVector$"')
debugger.HandleCommand(f'type summary add --expand --skip-references -w {category} '
'-F lldbSwiftDataFormatters.DemangleNodeSummaryProvider '
'-x "^swift::Demangle::Node$"')
debugger.HandleCommand('type synthetic add --skip-references -w swift '
debugger.HandleCommand(f'type synthetic add --skip-references -w {category} '
'-l lldbSwiftDataFormatters.DemangleNodeSynthProvider '
'-x "^swift::Demangle::Node$"')
debugger.HandleCommand('type summary add -w swift '
debugger.HandleCommand(f'type summary add -w {category} '
'-s "${var.Pointer%S}" '
'swift::Identifier')

Expand Down