Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specially debugging line by line

I have a script written in Pascal. I would to debug it in this way: stop at every line, dump values of all variables in memory and go to the next line. Is it possible to do it with gdb or some other open-source tool for Linux?

like image 375
Tom Tichý Avatar asked Apr 12 '26 17:04

Tom Tichý


2 Answers

Compile file with option -g:

fpc/gpc -g file.pas

Run gdb for this file:

gdb file

Set all of needed variables:

display first_var
display second_var
...

Start debugging:

start

By pressing s you can continue to the next line.

like image 175
yetty Avatar answered Apr 15 '26 08:04

yetty


Yes it is possible to use the gdb debugger on Pascal programs, provided your Pascal compiler is giving DWARF debug information. If using GNU Pascal (i.e. gpc) you want to pass the -g option when invoking gpc. If you use Free Pascal, it also accepts the -g option to fpc.

Once you compiled your Pascal program with debugging information, you need to learn how to use GNU gdb. You probably want the display, step, next, break, print, frame, cont commands (to gdb) and some more.

like image 26
Basile Starynkevitch Avatar answered Apr 15 '26 08:04

Basile Starynkevitch