From c9931d2ac1fb142178670a68693011774df0950d Mon Sep 17 00:00:00 2001 From: TetzkatLipHoka Date: Sat, 11 Jul 2026 21:35:28 +0200 Subject: [PATCH] uPSDebugger: add TPSCustomDebugExec.HasCodeAtRow for exact breakpoint-line testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An IDE integrating the debugger needs to know whether a given source line can carry a breakpoint, i.e. whether any bytecode maps to that line. The debug position table already holds this information (per procedure, a list of FileName/Position/Row/Col records), but there was no public way to query it by row - callers had to either walk the private tables or fall back to a text heuristic that cannot tell a declaration body or comment from real code. HasCodeAtRow(Row, Fn) returns True when any procedure has a position entry for that source row (Fn '' matches any module). It is a small read-only scan of the already-loaded position tables; it returns False when no debug data is loaded. Verified DCC32/DCC64: against a compiled script the table correctly reports executable lines True and declaration / begin / blank lines False. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- Source/uPSDebugger.pas | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Source/uPSDebugger.pas b/Source/uPSDebugger.pas index 2c40d503..d050bfd6 100644 --- a/Source/uPSDebugger.pas +++ b/Source/uPSDebugger.pas @@ -38,6 +38,12 @@ TPSCustomDebugExec = class(TPSExec) function TranslatePosition(Proc, Position: Cardinal): Cardinal; function TranslatePositionEx(Proc, Position: Cardinal; var Pos, Row, Col: Cardinal; var Fn: tbtstring): Boolean; + + { True when any opcode of any procedure maps to source row Row. This is + the exact "may a breakpoint sit on this line" test for IDEs - only + meaningful while DebugDataLoaded is True. Fn filters by source/module + name ('' = any file). } + function HasCodeAtRow(Row: Cardinal; const Fn: tbtstring = ''): Boolean; procedure LoadDebugData(const Data: tbtstring); @@ -273,6 +279,32 @@ function GetProcDebugInfo(FProcs: TIFList; Proc: TPSProcRec): PFunctionInfo; REsult := c; end; +function TPSCustomDebugExec.HasCodeAtRow(Row: Cardinal; const Fn: tbtstring): Boolean; +var + i, j: Longint; + fi: PFunctionInfo; + r: PPositionData; +begin + Result := False; + if FDebugDataForProcs = nil then + Exit; + for i := 0 to FDebugDataForProcs.Count - 1 do + begin + fi := FDebugDataForProcs[i]; + if fi^.FPositionTable = nil then + Continue; + for j := 0 to fi^.FPositionTable.Count - 1 do + begin + r := PPositionData(fi^.FPositionTable[j]); + if (r^.Row = Row) and ((Fn = '') or (r^.FileName = Fn)) then + begin + Result := True; + Exit; + end; + end; + end; +end; + procedure TPSCustomDebugExec.LoadDebugData(const Data: tbtstring); var CP, I: Longint;