public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* Re: pascal/2283: Copy/paste error in print_variable_at_address regarding printing pchars
@ 2007-09-26 12:27 muller
  0 siblings, 0 replies; 4+ messages in thread
From: muller @ 2007-09-26 12:27 UTC (permalink / raw)
  To: gdb-prs, jonas, muller, nobody, pierre

Synopsis: Copy/paste error in print_variable_at_address regarding printing pchars

Responsible-Changed-From-To: unassigned->muller
Responsible-Changed-By: muller
Responsible-Changed-When: Wed Sep 26 12:27:16 2007
Responsible-Changed-Why:
    Pascal specific
State-Changed-From-To: open->feedback
State-Changed-By: muller
State-Changed-When: Wed Sep 26 12:27:16 2007
State-Changed-Why:
     Patch applied to current gdb 2007/09/26
    
    Thanks Jonas
    and sorry for the slow reaction.

http://sourceware.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=2283


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pascal/2283: Copy/paste error in print_variable_at_address regarding printing pchars
@ 2007-10-01 13:29 muller
  0 siblings, 0 replies; 4+ messages in thread
From: muller @ 2007-10-01 13:29 UTC (permalink / raw)
  To: gdb-prs, jonas, muller, pierre

Synopsis: Copy/paste error in print_variable_at_address regarding printing pchars

State-Changed-From-To: feedback->closed
State-Changed-By: muller
State-Changed-When: Mon Oct  1 13:29:00 2007
State-Changed-Why:
     Ackowledged as fixed by the submitter.

http://sourceware.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=2283


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pascal/2283: Copy/paste error in print_variable_at_address regarding printing pchars
@ 2007-07-03 21:48 Jonas Maebe
  0 siblings, 0 replies; 4+ messages in thread
From: Jonas Maebe @ 2007-07-03 21:48 UTC (permalink / raw)
  To: nobody; +Cc: gdb-prs

The following reply was made to PR pascal/2283; it has been noted by GNATS.

From: Jonas Maebe <jonas@freepascal.org>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: pascal/2283: Copy/paste error in print_variable_at_address regarding printing pchars
Date: Tue, 3 Jul 2007 23:40:41 +0200

 Sorry, I added the wrong patch: the supplied patch fixes printing an  
 "array of char" as string (it's ok to apply that one too though,  
 since it's trivial and about a similar issues).
 
 Here is the (also pretty trivial) patch for fixing the printing of  
 pointers to chars as strings:
 
 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:38:56 -0000
 @@ -172,7 +172,8 @@
            /* For a pointer to char or unsigned char, also print the  
 string
               pointed to, unless pointer is null.  */
            if (TYPE_LENGTH (elttype) == 1
 -             && TYPE_CODE (elttype) == TYPE_CODE_INT
 +	      && (TYPE_CODE (elttype) == TYPE_CODE_INT
 +		  || TYPE_CODE (elttype) == TYPE_CODE_CHAR)
                && (format == 0 || format == 's')
                && addr != 0)
              {
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* pascal/2283: Copy/paste error in print_variable_at_address regarding printing pchars
@ 2007-07-03 21:28 jonas
  0 siblings, 0 replies; 4+ messages in thread
From: jonas @ 2007-07-03 21:28 UTC (permalink / raw)
  To: gdb-gnats; +Cc: pierre


>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:


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-10-01 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-26 12:27 pascal/2283: Copy/paste error in print_variable_at_address regarding printing pchars muller
  -- strict thread matches above, loose matches on Subject: below --
2007-10-01 13:29 muller
2007-07-03 21:48 Jonas Maebe
2007-07-03 21:28 jonas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).