public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/14093] Wrong type found by check_typedef
  2012-05-10 17:15 [Bug exp/14093] New: Wrong type found by check_typedef brobecker at gnat dot com
@ 2012-05-10 17:15 ` brobecker at gnat dot com
  2014-11-05 19:46 ` xdje42 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: brobecker at gnat dot com @ 2012-05-10 17:15 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14093

brobecker at gnat dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |brobecker at gnat dot com

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


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

* [Bug exp/14093] New: Wrong type found by check_typedef
@ 2012-05-10 17:15 brobecker at gnat dot com
  2012-05-10 17:15 ` [Bug exp/14093] " brobecker at gnat dot com
  2014-11-05 19:46 ` xdje42 at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: brobecker at gnat dot com @ 2012-05-10 17:15 UTC (permalink / raw)
  To: gdb-prs

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.


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

* [Bug exp/14093] Wrong type found by check_typedef
  2012-05-10 17:15 [Bug exp/14093] New: Wrong type found by check_typedef brobecker at gnat dot com
  2012-05-10 17:15 ` [Bug exp/14093] " brobecker at gnat dot com
@ 2014-11-05 19:46 ` xdje42 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: xdje42 at gmail dot com @ 2014-11-05 19:46 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=14093

Doug Evans <xdje42 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xdje42 at gmail dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

end of thread, other threads:[~2014-11-05 19:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-10 17:15 [Bug exp/14093] New: Wrong type found by check_typedef brobecker at gnat dot com
2012-05-10 17:15 ` [Bug exp/14093] " brobecker at gnat dot com
2014-11-05 19:46 ` xdje42 at gmail dot com

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