As part of the OS X port, I try to make GPC part of Apple's ProjectBuilder, a GUI integrated development enviroment running on top of tools like JAM, GCC and GDB. There is a screen shot of how it will look at <www.microbizz.nl/gpcscreen01.png>.
I had expected debugging GNU Pascal programs (with Project Builder) to work, bit it didn't. After a late night session I found that stepping and breaking actually do (!) work. It was just that the Pascal source on the screen and the current-line indicator didn't reflect it ....
Stephen Bespalko (from the Mac OS X Ada team) advised me to try the GDB command line, so (in another late night session) I found:
(gdb) info source Current source file is /SourceCache/Csu/Csu-45/crt.c [instead of pentomino.pas] Compilation directory is /SourceCache/Csu/Csu-45/ Source language is c. Compiled with stabs debugging format. Does not include preprocessor macro info.
(gdb) info sources Source files for which symbols have been read in:
/Users/adriaan/gnu/gpc-3.2.1-patch/gcc/p/rts/init.pas, <implicit code>, /Users/adriaan/gnu/gpc-3.2.1-patch/gcc/p/rts/numtodec.pas, ../../gpc-3.2.1-patch/gcc/libgcc2.c, /Users/adriaan/gnu/gpc-3.2.1-patch/gcc/p/rts/sets.pas, /Users/adriaan/gnu/gpc-3.2.1-patch/gcc/p/rts/move.pas, /Users/adriaan/gnu/gpc-3.2.1-patch/gcc/p/rts/file.c, /Users/adriaan/gnu/gpc-3.2.1-patch/gcc/p/rts/rts-va.c, ../../include/stdarg.h, start.s, /SourceCache/Csu/Csu-45/crt.c, tconfig.h, ...<snip>... /Users/adriaan/gnu/gpc-3.2.1-patch/gcc/p/rts/rts.c, /SourceCache/Csu/Csu-45/crt.c
So, the problem seems to be that GDB sees /SourceCache/Csu/Csu-45/crt.c as the source code instead of ./pentomino.pas. The promising point is that debugging Pascal code in listed runtime units (like init.pas) seemed to work perfectly.
So, I started playing with the linker:
[G4:~/pb/pentomino] adriaan% gpc -g -c -o pentomino.o pentomino.pas [G4:~/pb/pentomino] adriaan% set libpath = /Developer/Pascal/gpc321d8/lib/gcc-lib/powerpc-apple-darwin6.3/3.2.1/ [G4:~/pb/pentomino] adriaan% ld /usr/lib/crt1.o pentomino.o -L$libpath -lgpc -lgcc -lSystem [G4:~/pb/pentomino] adriaan% gdb pentmino GNU gdb 5.3-20021014 (Apple version gdb-250) (Sat Dec 7 02:14:27 GMT 2002)
(gdb) info source Current source file is pentomino.pas Compilation directory is /Users/adriaan/pb/pentomino/ Located in /Users/adriaan/pb/pentomino/pentomino.pas Contains 254 lines. Source language is pascal. Compiled with stabs debugging format. Does not include preprocessor macro info.
Suddenly, the problem had gone.....
So, somehow, the source-file name "pentomino.pas" gets lost when typing one of these:
[G4:~/pb/pentomino] adriaan% gpc -g -o pentomino pentomino.pas [G4:~/pb/pentomino] adriaan% gpc -g -o pentomino.o --automake pentomino.pas
What can that be ????
Here is what it does (-v)
[G4:~/pb/pentomino] adriaan% gpc -o pentomino -v pentomino.pas Reading specs from /Developer/Pascal/gpc321d8/lib/gcc-lib/powerpc-apple-darwin6.3/3.2.1/ specs Configured with: ../gpc-20030209/configure --enable-languages=pascal,c --prefix=/Developer/Pascal/gpc321d8 --enable-threads=posix Thread model: posix gpc version 20030209, based on gcc-3.2.1
/Developer/Pascal/gpc321d8/lib/gcc-lib/powerpc-apple-darwin6.3/3.2.1/ gpcpp -D__BITS_BIG_ENDIAN__=1 -D__BYTES_BIG_ENDIAN__=1 -D__WORDS_BIG_ENDIAN__=1 -D__NEED_NO_ALIGNMENT__=1 -v -iprefix /usr/bin/../lib/gcc-lib/powerpc-apple-darwin6.3/3.2.1/ -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__GXX_ABI_VERSION=102 -D__ppc__ -D__POWERPC__ -D__NATURAL_ALIGNMENT__ -D__MACH__ -D__BIG_ENDIAN__ -D__APPLE__ -D__ppc__ -D__POWERPC__ -D__NATURAL_ALIGNMENT__ -D__MACH__ -D__BIG_ENDIAN__ -D__APPLE__ -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D__APPLE_CC__=999 -D__DYNAMIC__ pentomino.pas -famtmpfile=/var/tmp//ccMIljqO.gpa /var/tmp//ccknfExA.i GNU Pascal Compiler PreProcessor version 20030209, based on gcc-3.2.1 (Darwin/PowerPC)
/Developer/Pascal/gpc321d8/lib/gcc-lib/powerpc-apple-darwin6.3/3.2.1/ gpc1 /var/tmp//ccknfExA.i -fPIC -quiet -dumpbase pentomino.pas -version -famtmpfile=/var/tmp//ccMIljqO.gpa -o /var/tmp//cc6VO6Cd.s GNU Pascal version 3.2.1 (powerpc-apple-darwin6.3) compiled by GNU C version 3.2.1. GNU Pascal version is actually 20030209, based on gcc-3.2.1 as -o /var/tmp//ccm7Qu4a.o /var/tmp//cc6VO6Cd.s
/Developer/Pascal/gpc321d8/lib/gcc-lib/powerpc-apple-darwin6.3/3.2.1/ collect2 -o pentomino -lcrt1.o -L/usr/bin/../lib/gcc-lib -L/Developer/Pascal/gpc321d8/lib/gcc-lib/powerpc-apple-darwin6.3/3.2.1 -L/Developer/Pascal/gpc321d8/lib/gcc-lib/powerpc-apple-darwin6.3/3.2.1/ ../../.. /var/tmp//ccm7Qu4a.o -lgpc -lgcc -lSystem -lgcc
Regards,
Adriaan van Os