Since I don't currently have the time to go through the sources, I ask here.
Hi Martin,
Today, OPDF is in exactly the same boat as fpdebug.
TDefAnsiString carries only a TypeID and a name, and pdr's string evaluator
hardcodes "length at pointer-8, refcount at pointer-4, data at pointer+0". If
FPC changes the header tomorrow, my debugger breaks until rebuilt — same
trade-off you've already worked through.
The thing your question changes for me, and the reason it's well-timed: OPDF is
still in pull-request state with the FPC team. The spec is genuinely still
malleable, with no deployed binaries to stay compatible with. So if extending
TDefAnsiString to carry header field offsets — LengthOffset, RefCountOffset,
CodePageOffset, ElementSizeOffset — is the right call, I can put them straight
into v1 of the record before the PR lands. The FPC writer (best placed to know
the exact offsets) emits them at compile time, and any consumer reads them at
runtime with no recompile and no per-FPC constant table.
You've raised a genuinely good point here, and I think extending the record
structure before OPDF merges into FPC is the right long-term strategy. Every
offset and layout assumption I can move out of the debugger and into the format
itself is one less hardcoded constant the debug engine has to carry — and one
less thing that has to be patched when FPC's internals shift. The whole spirit
of OPDF is "let the compiler describe what it knows", and string headers fit
that brief as well as anything. I'd rather take the time to get this in now than
ship a v1 that quietly relies on the same hardcoded knowledge fpdebug already
has to maintain.
To answer the cross-version question explicitly: an OPDF binary produced today
by FPC 3.3.1 will remain readable by all future pdr versions — the format is
versioned, every record carries an explicit RecSize, and unknown records are
skipped cleanly. What is not guaranteed yet is that pdr will interpret an
AnsiString whose offsets have shifted underneath it. The descriptor would close
that gap.
Two other limitations worth flagging in the same spirit: OPDF doesn't model
register-allocated variables yet, and it doesn't have anything like .eh_frame —
it leans on RBP frame chains and breaks the moment the optimiser drops them.
Both are known gaps. The proposal isn't "OPDF replaces DWARF"; the two sit
happily in the same binary in separate ELF sections. Anyone who needs GDB
compatibility keeps using -gw; anyone who wants first-class Object Pascal
debugging adds -gO. No pressure to deprecate anything.
On a side note: since you'll likely browse the docs at some point: the early
analysis and design documents in the repo predate the current implementation and
may read as slightly dated in places. I've kept them in deliberately to show the
rationale and the design evolution — this is actually my third attempt at
getting the format right, and I think there's value in leaving the trail visible
rather than rewriting history to look planned.
Cheers,
Graeme