From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10280 invoked by alias); 8 Apr 2010 16:13:12 -0000 Received: (qmail 10153 invoked by uid 48); 8 Apr 2010 16:13:11 -0000 Date: Thu, 08 Apr 2010 16:13:00 -0000 From: "muller at ics dot u-strasbg dot fr" To: gdb-prs@sourceware.org Message-ID: <20100408161310.11479.muller@ics.u-strasbg.fr> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug symtab/11479] New: Stabs qualified function argument with opaque type not dispalyed correctly X-Bugzilla-Reason: CC Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org X-SW-Source: 2010-q2/txt/msg00055.txt.bz2 If a function is using qualified arguments with opaque types, the size of this qualified type is not set correctly when the type is resolved. This leads to garbage output with GDB. Example code: struct dummy; void * test (const struct dummy *t) { struct dummy *tt; tt = t; return t; } void * test2 (struct dummy *t) { struct dummy *tt; tt = t; return t; } struct dummy { int x; int y; double b; } tag_dummy; int main () { struct dummy tt; tt.x = 5; tt.y = 25; tt.b = 2.5; test2 (&tt); return test (&tt); } gcc -gstabs+ -o test test.c gives the following output: Pierre@d620-muller ~/gdbcvs/build-norm/gdb $ gdb71.exe ./test GNU gdb (GDB) 7.1 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-cygwin". For bug reporting instructions, please see: ... Reading symbols from /usr/local/src/gdbcvs/build-norm/gdb/test.exe...done. Setting up the environment for debugging gdb. Function "internal_error" not defined. Make breakpoint pending on future shared library load? (y or [n]) [answered N; i nput not from terminal] Function "info_command" not defined. Make breakpoint pending on future shared library load? (y or [n]) [answered N; i nput not from terminal] /usr/local/src/gdbcvs/build-norm/gdb/.gdbinit:8: Error in sourced command file: No breakpoint number 0. (gdb) rb test Breakpoint 1 at 0x401056: file test.c, line 8. void *test(const struct dummy *); Breakpoint 2 at 0x401067: file test.c, line 16. void *test2(struct dummy *); (gdb) r Starting program: /usr/local/src/gdbcvs/build-norm/gdb/test.exe [New Thread 5388.0x774] [New Thread 5388.0x1438] Breakpoint 2, test2 (t=0x22cc80) at test.c:16 16 tt = t; (gdb) p *t $1 = {x = 5, y = 25, b = 2.5} (gdb) c Continuing. Breakpoint 1, test (t=0x22cc80) at test.c:8 8 tt = t; (gdb) p *t $2 = {x = 0, y = 0, b = 5.3049894774131808e-313} Using 'set debug target 1' explains better what happens: Breakpoint 2, test2 (t=0x22cc80) at test.c:16 16 tt = t; (gdb) set debug target 1 (gdb) p *t child:target_xfer_partial (2, (null), 0x1edea50, 0x0, 0x22cc50, 4) = 4, bytes = 80 cc 22 00 child:target_xfer_partial (2, (null), 0x1ede9d0, 0x0, 0x22cc80, 16) = 16, bytes = 05 00 00 00 19 00 00 00 00 00 00 00 00 00 04 40 $5 = {x = 5, y = 25, b = 2.5} (gdb) set debug target 0 (gdb) c Continuing. Breakpoint 1, test (t=0x22cc80) at test.c:8 8 tt = t; (gdb) set debug target 1 (gdb) p *t child:target_xfer_partial (2, (null), 0x202fc20, 0x0, 0x22cc50, 4) = 4, bytes = 80 cc 22 00 $6 = {x = 0, y = 0, b = 4.0317920028340174e-313} (gdb) p sizeof (*t) $7 = 0 If fact, the const qualifier in test function declaration triggers the generation of a new structure type. This new type does not get its size set when the structure is resolved. Tested both on windows and linux (32 bit generated code). -- Summary: Stabs qualified function argument with opaque type not dispalyed correctly Product: gdb Version: unknown Status: UNCONFIRMED Severity: normal Priority: P2 Component: symtab AssignedTo: unassigned at sourceware dot org ReportedBy: muller at ics dot u-strasbg dot fr CC: gdb-prs at sourceware dot org http://sourceware.org/bugzilla/show_bug.cgi?id=11479 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.