public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* Re: exp/1158: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression
@ 2008-07-27  2:00 tromey
  0 siblings, 0 replies; 5+ messages in thread
From: tromey @ 2008-07-27  2:00 UTC (permalink / raw)
  To: gdb-prs, moriyoshi, tromey

Synopsis: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression

State-Changed-From-To: analyzed->closed
State-Changed-By: tromey
State-Changed-When: Sun Jul 27 02:00:55 2008
State-Changed-Why:
    Fix checked in.

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


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

* Re: exp/1158: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression
@ 2008-07-26 23:31 tromey
  0 siblings, 0 replies; 5+ messages in thread
From: tromey @ 2008-07-26 23:31 UTC (permalink / raw)
  To: gdb-prs, moriyoshi, nobody, tromey

Synopsis: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression

Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Sat Jul 26 23:31:43 2008
Responsible-Changed-Why:
    I am testing a fix.
State-Changed-From-To: open->analyzed
State-Changed-By: tromey
State-Changed-When: Sat Jul 26 23:31:43 2008
State-Changed-Why:
    The bug is that pt->t is treated as a method invocation
    in all cases, so a "this" pointer is inserted.

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


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

* Re: exp/1158: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression
@ 2003-07-20 22:28 Moriyoshi Koizumi
  0 siblings, 0 replies; 5+ messages in thread
From: Moriyoshi Koizumi @ 2003-07-20 22:28 UTC (permalink / raw)
  To: nobody; +Cc: gdb-prs

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

From: Moriyoshi Koizumi <moriyoshi@at.wakwak.com>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: exp/1158: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression
Date: Mon, 21 Jul 2003 07:30:07 +0900

 Hi,
 
 Sorry if this is the wrong address to send an additional note to the PR.
 
 Andrew Cagney <ac131313@redhat.com> wrote:
 > I suspect that you attached the wrong test case.  test(1,2) vs test(1)?
 
 Oops, the following is the correct test case.
 
 == test case begins here ==
 == test.c ==
 #include <stdio.h>
 
 void test(int c)
 {
     printf("%d\n", c + 2);
 }
 
 int main(int argc, char **argv)
 {
     struct {
         void (*t)(int c);
     } t, *pt;
     t.t = test;
     pt = &t;
 }
 == action to replicate the problem ==
 GNU gdb 5.3.90_2003-06-29-cvs-debian
 Copyright 2003 Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you are
 welcome to change it and/or distribute copies of it under certain conditions.
 Type "show copying" to see the conditions.
 There is absolutely no warranty for GDB.  Type "show warranty" for details.
 This GDB was configured as "i386-linux"...
 (gdb) break test.c:15
 Breakpoint 1 at 0x8048360: file test.c, line 15.
 (gdb) run
 Starting program: /tmp/test
 
 Breakpoint 1, main (argc=1, argv=0xbffffd34) at test.c:15
 15      }
 (gdb) print *pt
 $1 = {t = 0x8048328 <test>}
 (gdb) call test(3)
 3
 (gdb) call pt->t(3)
 -1073742636
 (gdb) printf "%d\n", pt
 -1073742636
 == end of test case ==
 
 Thanks,
 Moriyoshi
 


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

* Re: exp/1158: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression
@ 2003-04-12  0:18 Andrew Cagney
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2003-04-12  0:18 UTC (permalink / raw)
  To: nobody; +Cc: gdb-prs

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

From: Andrew Cagney <ac131313@redhat.com>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: exp/1158: dereferencing a pointer to a function clobbers arguments'
 value when invoking it in the expression
Date: Fri, 11 Apr 2003 20:14:38 -0400

 I suspect that you attached the wrong test case.  test(1,2) vs test(1)?
 
 


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

* exp/1158: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression
@ 2003-03-30 16:28 moriyoshi
  0 siblings, 0 replies; 5+ messages in thread
From: moriyoshi @ 2003-03-30 16:28 UTC (permalink / raw)
  To: gdb-gnats


>Number:         1158
>Category:       exp
>Synopsis:       dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          maintenance
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 30 16:18:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     moriyoshi@at.wakwak.com
>Release:        5.3-debian
>Organization:
>Environment:
Linux(2.4.20pre5) + glibc(2.3.1)
>Description:
When trying to invoke a function in a gdb expression that is dereferencing the pointer to the function from a pointer to a structure, the value of the first argument is unexpectedly replaced by the same value as the address of the dereferenced pointer (i.e. pointer to the structure).
>How-To-Repeat:
A snippet to reproduce this problem:

#include <stdio.h>

void test(int c)
{
    printf("%d\n", c + 2);
}

int main(int argc, char **argv)
{
    struct {
        void (*t)(int c);
    } t, *pt;
    t.t = test;
    pt = &t;
}


$ gdb test
GNU gdb 5.3-debian
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...
(gdb) break test.c:15
Breakpoint 1 at 0x804836b: file test.c, line 15.
(gdb) run
Starting program: /tmp/test

Breakpoint 1, main (argc=1, argv=0xbffffda4) at test.c:15
15      }
(gdb) print *pt
$1 = {t = 0x8048328 <test>}
(gdb) call test(1, 3)
3 7
(gdb) call pt->t(1, 3)
-1073742522 5
(gdb) printf "%d\n", pt
-1073742524
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2008-07-27  2:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-27  2:00 exp/1158: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression tromey
  -- strict thread matches above, loose matches on Subject: below --
2008-07-26 23:31 tromey
2003-07-20 22:28 Moriyoshi Koizumi
2003-04-12  0:18 Andrew Cagney
2003-03-30 16:28 moriyoshi

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).