public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "brobecker at gnat dot com" <sourceware-bugzilla@sourceware.org> 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 [thread overview] Message-ID: <bug-14093-4717@http.sourceware.org/bugzilla/> (raw) 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.
next reply other threads:[~2012-05-10 17:15 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-05-10 17:15 brobecker at gnat dot com [this message] 2012-05-10 17:15 ` [Bug exp/14093] " brobecker at gnat dot com 2014-11-05 19:46 ` xdje42 at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-14093-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).