This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
exp/1158: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression
- From: moriyoshi at at dot wakwak dot com
- To: gdb-gnats at sources dot redhat dot com
- Date: 30 Mar 2003 16:17:00 -0000
- Subject: exp/1158: dereferencing a pointer to a function clobbers arguments' value when invoking it in the expression
- Reply-to: moriyoshi at at dot wakwak dot com
>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 at dot wakwak dot 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: