A debug information format designed for Object Pascal, and PDR (Pascal Debug Reference), the debugger that reads it. The Blaise compiler and an OPDF-capable Free Pascal Compiler (FPC) both produce it.
The Object Pascal Debug Format (OPDF) provides native, first-class support for Object Pascal concepts that are poorly represented in DWARF:
-
Properties with getter/setter methods (field-backed and method-backed)
-
String types (ShortString, AnsiString, UnicodeString)
-
Dynamic arrays with correct length display
-
Class instances with inherited fields and interfaces
-
Sets with enum member name display
-
Method call injection for getter property evaluation
OPDF data is embedded in the executable, with all addresses resolved at link time:
| Container | Section |
|---|---|
ELF (Linux, FreeBSD) |
|
Mach-O (macOS) |
|
PE/COFF (Windows) |
|
Blaise emits OPDF with --debug-opdf; an OPDF-capable FPC emits it with -gO. Readers check the format version, which is currently 2.
This is a multi-module project built with PasBuild:
-
opdf-lib: OPDF binary format definitions, reader/writer library, ELF section extractor
-
pdr-core: PDR debugger core engine (hexagonal architecture, platform-agnostic)
-
pdr-adapters: Platform-specific adapters (Linux and FreeBSD ptrace, macOS Mach, an untested Windows debug-API adapter, the OPDF reader, x86_64/AArch64/i386/ARM architecture adapters)
-
pdr-cli: Command-line debugger interface (
pdr, an interactive REPL with a batch/script mode) -
pdr-dap: Debug Adapter Protocol server over stdio (
pdr-dap), for IDEs such as Hexagram -
tools: Diagnostic tools (
opdf_dump— OPDF section analyser)
Requires PasBuild and FPC 3.2.2 or later. PDR itself is built with a stock FPC; only the FPC-produced test programs need an OPDF-capable compiler.
# Build all modules
pasbuild compile
# Build the debugger and the DAP server
pasbuild compile -m pdr-cli
pasbuild compile -m pdr-dap
# View dependency graph
pasbuild compile -vEach suite compiles its test programs, drives the debugger with a command script, and compares the output with the expected results.
| Suite | Covers |
|---|---|
|
40 programs compiled by Blaise: the main suite, run on every supported platform |
|
41 programs compiled by an OPDF-capable FPC ( |
|
|
|
the macOS Mach adapter |
# Blaise suite: point it at a Blaise tree and compiler
BLAISE_ROOT=~/devel/blaise BLAISE=~/devel/blaise/compiler/target/blaise \
bash tests/integration-blaise/run_tests.sh
# Run a single test
bash tests/integration-blaise/run_tests.sh test_01_primitivesLinux x86_64 must be tested on a real x86-64 kernel: Rosetta does not implement ptrace. scripts/linux-qemu.sh runs a Debian 12 VM under QEMU for that purpose.
PDR is the reference debugger for OPDF. It runs on:
-
Linux x86_64 (ptrace)
-
FreeBSD x86_64 (ptrace)
-
macOS arm64 (Mach)
It currently supports:
-
Launching a program, or attaching to a running process (
attach/detach), with the ASLR slide applied for position-independent executables -
Breakpoints by file:line, hex address, function name, or variable name
-
Multi-threaded programs: a breakpoint stops the thread that hit it and every other thread of the program
-
Hit-count conditional breakpoints (
break … if count=N) -
Source-level stepping (step over and step into)
-
Call stack display with function names and source locations
-
Variable evaluation for all Object Pascal types: primitives, floats, enums, sets, ShortString, AnsiString, UnicodeString, pointers, static arrays, dynamic arrays, records, classes (with field display), interfaces
-
Compile-time constant evaluation
-
Property evaluation: field-backed (automatic) and method-backed (via call injection)
-
Array slice display:
print arr[2..5] -
In-process variable assignment:
set x = 42,set day = Monday -
Local variable listing with scope awareness (including nested procedures)
-
Structured inspect command for records, classes, and interfaces
-
Auto-print display list (
display/undisplay) -
Hardware watchpoints (x86_64 debug registers DR0-DR3, AArch64 watchpoint registers)
-
Break on exception raise with class name and message display, for Blaise and FPC programs
-
A stop where a Blaise program ends with a runtime error, reported as
Runtime error <code>: <message>with its source location -
Thread-local variables
-
Method call injection for getter property evaluation (x86_64 SysV ABI, register save/restore, INT3 sentinel, red zone handling, managed return types)
Stopping on a Blaise raise or runtime error needs a program built by a Blaise compiler that names those hooks in OPDF: Blaise v0.16.2 or later.
-
Windows is not supported yet. PDR reads PE/COFF, and a Windows debug-API adapter exists, but it has never been run.
-
Stack unwinding relies on RBP frame pointer chains, which breaks with optimised RTL compiled without frame pointers.
-
Variant records, Variant type, and generics are not yet covered.
See docs/progress.adoc for the full progress tracker and roadmap.
See the docs/ directory:
-
opdf-specification.adoc: Complete binary format specification
-
blaise-opdf-integration.adoc: How the Blaise compiler emits OPDF
-
opdf-roadmap.adoc: OPDF and PDR roadmap
-
architecture.adoc: Debugger architecture and command trace documentation
-
design-decisions.adoc: Architecture, design pattern, and data type decisions
-
feature-specs.adoc: Detailed feature specifications
-
progress.adoc: Live progress tracker and roadmap
-
analysis.adoc: Strategic analysis and comparison with DWARF
PDR uses Hexagonal Architecture (Ports and Adapters):
-
Core Domain: Pure debugging logic, platform-agnostic (
pdr_engine.pas,pdr_typesys.pas) -
Ports: Interfaces defined in
pdr_ports.pas(IProcessController, IDebugInfoReader, IArchAdapter) -
Adapters: Platform-specific implementations (Linux/FreeBSD ptrace, macOS Mach, OPDF reader, architecture adapters)
This enables:
-
Platform independence — core engine has no platform imports
-
Support for multiple debug formats (OPDF, potentially DWARF)
-
Multiple UI frontends (the CLI and the DAP server share one engine) — integrating into an IDE requires only implementing the adapter interfaces; all type evaluation, property resolution, breakpoint logic, call injection, and display formatting are reusable as-is
OPDF does not replace DWARF. DWARF remains valuable for interoperability with standard tools (GDB, LLDB, Valgrind, perf), for platforms where OPDF is not yet supported, and for features that OPDF does not yet cover (e.g. register-allocated variables in optimised code, .eh_frame-based stack unwinding).
OPDF and DWARF can coexist in the same binary — they use separate ELF sections. A user who needs GDB compatibility continues using -gw. A user who wants first-class Object Pascal debugging uses -gO.
This project follows Test-Driven Development (TDD) and vertical slice implementation:
-
Write failing test
-
Implement feature
-
Verify test passes
-
Commit
BSD 3-Clause License (see LICENSE file)
|
Note
|
When integrated into FPC compiler, those portions will be licensed under GPL-2.0-or-later to match FPC’s licensing. |
Design influenced by:
-
Borland/Embarcadero Delphi debugging experience
-
fpdebug project (https://github.com/graemeg/fpdebug)
-
duby project - that sparked my interest in debuggers
-
DWARF debugging standard analysis
-
FPC community feedback