J. David Bryan wrote:
When debugging GPC 2.1 programs with GDB, I am unable to print the values of variables that are of the "standard" types. Variables of user-defined types appear to print OK.
program gdbtest (output);
var i : integer; r : real; c : char; e : (enum1, enum2); s : 0..10; t : string (12);
begin i := 3; r := 3.14159; c := 'Q'; e := enum2; s := 4; t := 'test string';
writeln (i, r, c, s, t);
end.
Breakpoint 1, pascal_main_program () at gdbtest.pas:18 18 writeln (i, r, c, s, t); (gdb) p i $1 = void (gdb) p r $2 = void (gdb) p c $3 = void (gdb) p e $4 = Enum2 (gdb) p s $5 = 4 (gdb) p t $6 = 'test string'
Could someone please confirm whether these results are reproducible across platforms or are specific to the ix86-mingw32 platform? Thanks!
Reproducible.
Note that the first three variables (of standard types "Integer", "Real", and "Char") print void values in the debugger. I have also tried this with GDB 4.18 and observe the same problem.
I note that gpc-20020410, when built with the same options, produces an executable from the test program I supplied that works as expected with gdb. Something appears to have changed between 20020410 and 20020510 to the debugging type information for the predefined types.
These two hints enabled me to find the problematic change by looking through the respective diffs. I think the following should fix it.
--- /home/gpc/src/p/gpc-decl.c.orig Sun Aug 25 05:03:34 2002 +++ /home/gpc/src/p/gpc-decl.c Sun Sep 1 04:02:45 2002 @@ -3134,7 +3134,9 @@
if (TREE_CODE (x) == TYPE_DECL) { - if (DECL_SOURCE_LINE (x) == 0 && TYPE_NAME (TREE_TYPE (x)) == 0) + if (TYPE_NAME (TREE_TYPE (x)) == x) + ; + else if (DECL_SOURCE_LINE (x) == 0 && TYPE_NAME (TREE_TYPE (x)) == 0) TYPE_NAME (TREE_TYPE (x)) = x; else if (TREE_TYPE (x) != error_mark_node) {
Prof Abimbola Olowofoyeku wrote:
No. But the "-s" switch may have strayed into the flags for the RTS. Frank, can you please tell us whether CFLAGS are passed through to building the RTS?
Yes, they are. (However, since the affected types are compiler built-ins, not declared in the RTS, this was not the issue here, anyway. And, as Dave said, I think `-s' should not matter while building libraries.)
I think that RTSFLAGS deals with that, but I am not sure.
They are given in addition -- after CFLAGS, so they can overwrite them.
BTW, I wouldn't actually recommend distributing stripped binaries. As we all know, GPC sometimes does unexpected things ;-), and in such cases a stack dump etc. generated from a compiler with debug info can provide useful information ...
Frank