Skip to content

Fixes: Debugger and disassembler - #326

Open
ElminsterAU wants to merge 1 commit into
remobjects:masterfrom
ElminsterAU:fixes/debugger
Open

ElminsterAU wants to merge 1 commit into
remobjects:masterfrom
ElminsterAU:fixes/debugger

Conversation

@ElminsterAU

Copy link
Copy Markdown

Debugger and disassembler: 12 changes, each described in the commit messages.

This is one of a series of pull requests carrying the fixes NexusDB made to Pascal Script, split by area so that each can be reviewed on its own. The fixes are listed one per line in each commit's message.

Applies to master on its own.

Tested. With the whole series applied, every unit of Source compiles, and a script run through TPSScript (strings, Int64, reals, calls into host functions, exceptions, a class from the Classes library, for / Break) gives the expected results, on Delphi 7, 2005, 2006, 2007, 2009, 2010, XE, XE2 - XE8 and 10 Seattle - 13 Florence (Win32, and Win64 from XE2), and on Free Pascal 3.2.2 (i386) and 3.3.1 (x86_64), with and without PS_USESSUPPORT; compilers before XE4 need the last pull request of the series. Master as it stands does not compile on XE4, XE5 Win64, 10 Seattle, 10.1 Berlin, 10.3 Rio Win64, Free Pascal 3.2.2 or 3.3.1, nor on anything before XE4.

Beyond that smoke test, the fixes were developed and are covered in NexusDB, whose suite runs about 6,400 checks on 37 Delphi compiler / platform combinations and on Free Pascal. NexusDB defines PS_USECLASSICINVOKE, so there every Delphi calls native routines through x86.inc / x64.inc; the InvokeCall.inc path (the default from Delphi 10 Seattle) is exercised here by the smoke test only.

These fixes come from NexusDB, which ships Pascal Script as its script engine.  Each was found and fixed
there; most were measured against what Delphi itself does with the same code, and most have a regression
test in NexusDB's own suite, which runs on Delphi 7 through 13 Florence (Win32 and Win64) and on Free Pascal
3.2.2 (i386) and 3.3.1 (x86_64).  NexusDB builds the engine with PS_USECLASSICINVOKE and PS_USESSUPPORT; the
fixes are given here in Pascal Script's own unit names and configuration.

uPSDebugger.pas:
- The line hook sees the current routine's variables
- No source line after a line hook stopped the script
- StepOver of a native call that runs a script routine
- The debug record looked up again after a line hook that ran a script routine
- GetCurrentPosition translates the current instruction
- GetCallStack ends at a stack base without a return address and names the main block
- No routine's debug record is current without debug information
- The debug record is the current routine's whenever it is read
- The debug executor looked up the current instruction's source position by scanning the routine's
  whole position table before every instruction, so with debug information -- every TPSScript's
  default -- a script ran slower the more statements its routine held; the table is in code order,
  so the lookup is now a binary search
- The debug executor -- every TPSScript's -- took Pause for the debugger's wait at the next line,
  which needs an idle call; with none, as in a TPSScript that is no TPSScriptDebugger, a host's
  Pause was ignored and the script ran on. Without an idle call it is now the executor's own pause
- The debug executor's wait at a line -- where StepInto or StepOver arrive, or a Pause whose idle
  call the host then took away -- needs an idle call; with none it ran on and left the debugger
  paused for good. Without one it is now the executor's own pause, as an earlier fix made Pause

uPSDisassembly.pas:
- Delphi XE3 - XE5 for Win64 leak the exception object of an except handler left by a jump; each
  such handler is left after its end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant