From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5536 invoked by alias); 10 May 2012 17:15:01 -0000 Received: (qmail 5516 invoked by uid 22791); 10 May 2012 17:14:59 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 May 2012 17:14:47 +0000 From: "brobecker at gnat dot com" To: gdb-prs@sourceware.org Subject: [Bug exp/14093] New: Wrong type found by check_typedef Date: Thu, 10 May 2012 17:15:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: exp X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: brobecker at gnat dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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: 2012-q2/txt/msg00106.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=14093 Bug #: 14093 Summary: Wrong type found by check_typedef Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: exp AssignedTo: unassigned@sourceware.org ReportedBy: brobecker@gnat.com Classification: Unclassified Created attachment 6404 --> http://sourceware.org/bugzilla/attachment.cgi?id=6404 Text files containing all sources needed to reproduce. Reproduced on x86_64-linux, using GNU gdb (GDB) 7.4.50.20120509-cvs. The sources are filed as an attachement. To compile the sources, do: % gcc -o libfoo.so -g -shared -fPIC lib-foo.c lib-if.c % gcc -o main -g foo.c foo-if.c main.c -lfoo -L. The sources create a scenario where two source files use an opaque type (foo-if.c and lib-if.c). The opaque type in each file has the same name (struct some_data), but the actual definition is different. When trying to print the value of a variable of that type, check_typedef needs to be called in order to resolve the variable's type. The resolution is performed regardless of context, and thus results in the same type being returned each time. This means that one of the times, the variable value is printed wrong, as demonstrated in the GDB transcript below. One way to mitigate the problem in this example is to enhance check_typedef to search the same objfile as the objfile where the variable is defined. But the testcase can be tweaked into a single executable, and reveal the same problem. Just compile the sources using: % gcc -o main-single -g *.c In that case, the heuristics of searching the current objfile first isn't going to be sufficient. Not sure if there is a solution to that problem... GDB session transcript: (gdb) b foo-if.c:9 Breakpoint 1 at 0x4004f3: file foo-if.c, line 9. (gdb) b lib-if.c:9 Breakpoint 2 at 0x400581: file lib-if.c, line 9. (gdb) run Starting program: /[...]/main Breakpoint 1, do_something_in_foo () at foo-if.c:9 9 return data != NULL; (gdb) p *data $1 = {a = 11, b = 21} (gdb) c Continuing. Breakpoint 2, do_something_in_lib () at lib-if.c:9 9 return data != NULL; (gdb) p *data $2 = {a = 1684234849, b = 0} -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.