This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
pascal/2283: Copy/paste error in print_variable_at_address regarding printing pchars
- From: jonas at freepascal dot org
- To: gdb-gnats at sources dot redhat dot com
- Cc: pierre at freepascal dot org
- Date: 3 Jul 2007 21:24:22 -0000
- Subject: pascal/2283: Copy/paste error in print_variable_at_address regarding printing pchars
- Reply-to: jonas at freepascal dot org
>Number: 2283
>Category: pascal
>Synopsis: Copy/paste error in print_variable_at_address regarding printing pchars
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: patch
>Submitter-Id: net
>Arrival-Date: Tue Jul 03 21:28:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator: jonas@freepascal.org
>Release: gdb cvs 20070703
>Organization:
>Environment:
Linux/i386
>Description:
print_variable_at_address in p-valprint.c contains this code (around line 90), probably copied from m2-valprint.c:
/* For an array of chars, print with string syntax. */
if (eltlen == 1 &&
((TYPE_CODE (elttype) == TYPE_CODE_INT)
|| ((current_language->la_language == language_m2)
&& (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
&& (format == 0 || format == 's'))
{
That language_m2 should read language_pascal. Pascal compilers also emit TYPE_CODE_CHAR for characters, as a char and an integer are two distinct types in Pascal.
Without the patch below, the strings to which pchars (pointers to chars) point are not printed by gdb (unless you use "x/s pcharvar" or so).
>How-To-Repeat:
Compile this program with the Free Pascal Compiler with -g:
***
var
p: pchar;
begin
p:='this is a test';
writeln(p);
end.
***
Then load it in gdb and:
(gdb) b PASCALMAIN
Breakpoint 1 at 0x8048086: file str.pp, line 6.
(gdb) r
Starting program: /user/jmaebe/lnxhome/fpc/test/debug/str
Breakpoint 1, 0x08048086 in main () at str.pp:6
6 begin
(gdb) n
7 p:='this is a test';
(gdb)
8 writeln(p);
(gdb) p p
$1 = (PCHAR) 0x8060038
After the patch below this becomes:
(gdb) p p
$1 = (PCHAR) 0x20b98 'this is a test'
The same goes for ansistrings.
>Fix:
Index: p-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/p-valprint.c,v
retrieving revision 1.49
diff -u -r1.49 p-valprint.c
--- p-valprint.c 13 Jun 2007 17:30:01 -0000 1.49
+++ p-valprint.c 3 Jul 2007 21:07:17 -0000
@@ -89,7 +89,7 @@
/* For an array of chars, print with string syntax. */
if (eltlen == 1 &&
((TYPE_CODE (elttype) == TYPE_CODE_INT)
- || ((current_language->la_language == language_m2)
+ || ((current_language->la_language == language_pascal)
&& (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
&& (format == 0 || format == 's'))
{
>Release-Note:
>Audit-Trail:
>Unformatted: