Skip to content
PaskalCPP
Tools

The debugger

One debugging engine with two front ends: the console debugger (pcpp <file> -d) and the debug adapter (pcpp --dap) the editor runs.

What it debugs

Debugging is for the x86_64-windows-gnu target: -d makes a debug build whatever @optimize says. An exe is debugged on its own, a dll inside the exe that loads it (--host <exe>; the editor remembers the host it was given per dll). The command-line forms and their errors are on Debugging from the command line.

The console debugger runs the engine in pcpp's own process; the debug adapter speaks DAP on stdin / stdout, and the editor's debug host runs it.

Breakpoints and stops

  • Every @breakpoint statement of the program is a breakpoint, placed with the ones you set; a console session starts by saying how many it found (<n> breakpoint(s) from @breakpoint).
  • A breakpoint on a line with no code (a comment, a routine's header) stops at the next line that has code, and says so: Breakpoint #<n> at <file>:76 (code at line 78).
  • A breakpoint in a dll waits until the dll is loaded.
  • A console session with no breakpoint at all holds the program at its entry, so you can set one first.
  • A stop names its reason (entry, breakpoint, step, pause or an exception: exception $<code>, first chance while a guard may still catch it) with the routine and the line: Stopped (breakpoint) in Square at <file>:61. The end of the program is Program exited with code <n>.
  • Continue, step over (the next line), step into, step out and pause (Ctrl+C in the console, F6 in the editor) work on PaskalCPP lines.

Looking at the program

  • Variables are shown with PaskalCPP's names and types, by frame: Params:, Locals:, Globals:, each line name: type = value. The call stack lists PaskalCPP routines with their file and line.
  • p <expr> (a WATCH row or a hover in the editor) prints a name and then its members (.x), elements ([n]) or targets (^).
  • An own, ref or weak shows the object it holds as its target, as a typed pointer does; a weak whose object is gone shows expired.
  • The program's own input and output go to the console the console debugger runs in, or to the editor's TERMINAL tab.

The console debugger's commands

CommandWhat it does
b <file>:<line>, b <line>set a breakpoint (b <line> in the current file)
bllist the breakpoints
bd <n>delete breakpoint n
bcdelete every breakpoint
ccontinue
nstep over (the next line)
sstep into
finishstep out
btthe call stack
f <n>select frame n (locals and p look at it)
localsthe variables of the selected frame
p <expr>print a name, a member, an element or a target
srcthe source around the selected frame
threadsthe threads
rrun the program again
Ctrl+Cpause the running program
hthis help
qquit (ends the program)

In the editor, continue, step over, into and out, pause and stop are on the Debug menu: see Menus and keys.

The debugger's own reports

The debugger's codes are DB; DB0012 (a target other than x86_64-windows-gnu) is on The pcpp command. Each message names the file, address or thread it is about, with the system's reason where there is one.

CodeWhat it reports
DB0001, DB0002the program to debug, or the --host, is not there
DB0003the program cannot start under the debugger
DB0018the program never reached its entry stop (it is ended)
DB0014 (warning)the host exited before it loaded the dll being debugged
DB0005, DB0010the symbol handler cannot start, or a symbol load or lookup fails
DB0006no line numbers: the program's .pdb must be beside it (build with -opt debug)
DB0015 (hint), DB0019 (warning)no PaskalCPP sources found, or one cannot be read: C++ names and types are shown for them
DB0011 (warning)a breakpoint where the program has no code (No code at <file>:<line>)
DB0016 (warning)a command that needs the program stopped, given while it runs
DB0008, DB0009the program's code cannot be patched, or a thread's registers cannot be read or written
DB0017the program cannot be paused
DB0004the debug loop itself failed (the program is ended)