Pangram verdict · v3.3
We believe that this text is a mix of AI and human-written content.
AI likelihood · overall
MixedArticle text · 1,035 words · 13 segments analyzed
GSoC 2026 - Adding Fortran Support to LLDB (LLVM)While Flang has matured, the developer tooling around it has lagged behind. In particular it lacks a dedicated debugger. LLDB lacks native Fortran support, it is only able to resolve basic breakpoints via raw line tables. This project adds support for Fortran in LLDB and lays the foundations on which a fully-featured Flang-backed debugger can be built.Specifically, this work introduces native support for:Primitive types (INTEGER, REAL, LOGICAL, COMPLEX)ArraysPointersFunctionsCurrent Status & Running the CodeBecause the upstreaming process for a project of this scale is ongoing, not all features have been merged into the LLVM main branch yet.
However a working implementation is available for anyone to test.
You can view the full set of changes, clone the code, and compile it yourself from my personal branch.To keep up to date with the ongoing integration of this project, you can follow the tracking issue.High-Level ArchitectureAdding a new language to LLDB requires teaching it how to extract, represent, and display the values from compiled binaries. This relies on three core components:DWARFASTParser: Parses compiler-generated DWARF debug information and extracts raw type metadata (e.g., symbol names, byte sizes, and layouts).TypeSystem: Represents the internal type model of the language within LLDB.
It takes the metadata parsed from DWARF and constructs native LLDB type representations.Language Plugin: Registers Fortran with LLDB and supplies language-specific pretty-printers, value formatters, and synthetic children providers.For more details on how to add a new language to LLDB, see the official documentation.RFC processWhen proposing any significant change to LLVM, it first needs to go through the RFC process. In short, a proposal is written providing an overview of the change, the motivation behind it, the overall architecture of what will be changed, and open questions. It then receives feedback, and if consensus is reached, the change is accepted and can be upstreamed.Reaching consensus on my RFC took approximately two months since it was a major new feature, but it taught me a lot about how to communicate an idea and interact with other developers.The most important decisions we reached in the RFC were:Figuring out where and how testing would be performed, including setting up buildbots (x86_64 / AArch64) to prevent bit-rot.Expression evaluation will eventually be supported using Flang, but later in the project’s lifetime and outside the scope of GSoC.LLDB will not link directly to Flang at this stage due to Flang’s demanding build requirements.
For now, only a Fortran compiler is needed to run tests.Array support will be added using synthetic children, rather than making intrusive changes to LLDB’s core infrastructure.Language-specific details like Fortran’s case insensitivity will be handled inside the plugin via DWARF attributes (DW_AT_identifier_case) without polluting core LLDB.Testing and UpstreamingFor a large part of GSoC, development took place on my personal LLVM fork while waiting for community consensus on the RFC.
Once consensus was reached, the focus shifted to breaking the work into small, incrementally testable pull requests that were easy for maintainers to review.To ensure long-term stability without regressions, the implementation leverages LLDB’s lit-based testing infrastructure across two distinct levels:Unit Tests (C++): Added three test suites to test core components in isolation:TypeSystemFortranTests: Verifies that TypeSystemFortran correctly instantiates, constructs, and queries Fortran types.DWARFASTParserFortranTests: Tests that raw DWARF debug info is parsed accurately into internal types.FortranLanguageTests: Validates language plugin registration and synthetic child provider hooks.API Tests (Python / SB API): End-to-end integration tests using LLDB’s Scripting Bridge API. These compile sample Fortran programs, launch debug sessions, and verify that the plugin, DWARF parser, and type system communicate properly to inspect variables and print output.For more details on LLDB testing standards, see the official testing documentation.Features added1.
Laying the FoundationFor API tests, LLDB needs to compile sample Fortran programs.
This patch updated LLDB’s test runner to automatically detect an installed Fortran compiler and conditionally enable the Fortran test suite.
PR #208298Before adding actual language features, LLDB requires substantial boilerplate to satisfy its internal interfaces, specifically the TypeSystem, which demands numerous stub methods just to compile.
To keep patches incremental and easy to review, this initial scaffolding was split into three minimal PRs that contain no active feature logic (except for registering the language plugin itself):Language Plugin Registration: Registers Fortran as a supported language within LLDB.PR #218014TypeSystem Stubs (TypeSystemFortran): Adds the class skeleton and required interface overrides.PR #218016DWARF Parser Stubs (DWARFASTParserFortran): Adds the parser skeleton to prepare for DWARF type parsing.PR #2180242.
Primitive TypesPrimitive types in Fortran consist of the INTEGER, REAL, LOGICAL and COMPLEX types and they are all described by the DW_TAG_base_type DWARF tag.Type System ImplementationTypeSystemFortran manages the lifetime and representation of all Fortran types in LLDB:Memory Management & Deduplication: For memory management without leaks, types are stored as unique pointers in a vector.
To avoid redundant allocations, an LLVM FoldingSet uniques types so existing instances are reused whenever a matching type is requested.Primitive Type Representation: To represent basic primitive types (INTEGER, REAL, LOGICAL, COMPLEX), the type system tracks three essential properties:Type nameByte sizeType kindAdd support for basic types in TypeSystemFortran PR #218269DWARFASTParser ImplementationDWARFASTParserFortran bridges the raw debug symbols generated by the compiler and LLDB’s internal type system:Tag Recognition: Parses the DW_TAG_base_type and its children, collecting information about the type.Scope Extraction: Calculates the scope/context of the type.Type Construction: Forwards the extracted information to TypeSystemFortran to instantiate and cache the corresponding type.3.
Functions & SubroutinesType System Implementation (Functions & Subroutines)To represent Fortran functions and subroutines, TypeSystemFortran tracks three key elements:Parameters: Stores the name and type of each parameter, which are used to construct the function signature and resolve argument inspection at runtime.Name: Receives the base identifier from the DWARF parser and formats the complete Fortran signature (e.g., INTEGER sample(INTEGER arg1)).Return Type: Tracks the return type for functions (or absence thereof for subroutines) to build the signature and provide accurate type info.DWARFASTParser Implementation (Functions & Subroutines)When encountering a Fortran function or subroutine, DWARFASTParserFortran handles two main tasks:Parsing Subprogram Information: Identifies DW_TAG_subprogram (and Fortran subroutines) and extracts the symbol name, parameter metadata, and return type, passing them to TypeSystemFortran to instantiate the function type.Calculating Frame Bounds: Determines the start and end memory addresses (low/high PC) of the subprogram. This address range is essential for stack frame unwinding and allows frame variable to correctly locate and display local variables in the current scope.4.