public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/13800] New: gdb does not print right values of getopt-related values
@ 2012-03-04 17:22 spuebla at hotmail dot com
  2012-03-05 19:42 ` [Bug exp/13800] " tromey at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: spuebla at hotmail dot com @ 2012-03-04 17:22 UTC (permalink / raw)
  To: gdb-prs

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

             Bug #: 13800
           Summary: gdb does not print right values of getopt-related
                    values
           Product: gdb
           Version: 7.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: exp
        AssignedTo: unassigned@sourceware.org
        ReportedBy: spuebla@hotmail.com
    Classification: Unclassified


Created attachment 6260
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6260
C99 source file which prints the getopt-related variables

GDB 7.4 cannot print the right values for getopt-related valued for the program
being debugged in Ubuntu 10.04 LTS but fixed values are shown instead.

How to reproduce this bug:

- Compile the attached C99 source file (with debugging information, of course).
- Start gdb and load the program built from the attached source, then set a
breakpoint in the line containing the first statement in the do loop.
- Once the breakpoint was reached, invoke the print command to show the values
currently set to getopt-related variables:

  (gdb) print optarg
  (gdb) print opterr
  (gdb) print optind
  (gdb) print /c optopt

- You can also see the addresses of these global variables:

  (gdb) print &optarg
  (gdb) print &opterr
  (gdb) print &optind
  (gdb) print &optopt

- Let execution of the program being debugged continue, and it will print the
values set to those variables by it itselt.
- Repeat the previous steps until the program finishes.

It is expected that gdb's print command shows the values set to optind, optopt,
and optarg by getopt. However, gdb prints the same values for such variables:

  (gdb) print optarg
  $1 = 0x00
  (gdb) print opterr
  $2 = 1
  (gdb) print optind
  $3 = 1
  (gdb) print /c optopt
  $4 = '?'

That's not all, the memory addresses of such variables printed by gdb differs
from the addresses printed by the program being debugged.

This bug does not exists in Windows Vista. A gdb process running in that OS
always shows the right values (and addresses) of those variables for the
process being debugged. The same gdb version are installed in both systems. In
Ubuntu, gdb was configured as "i686-pc-linux-gnu".

-- 
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] 4+ messages in thread

* [Bug exp/13800] gdb does not print right values of getopt-related values
  2012-03-04 17:22 [Bug exp/13800] New: gdb does not print right values of getopt-related values spuebla at hotmail dot com
@ 2012-03-05 19:42 ` tromey at redhat dot com
  2012-03-06 19:03 ` tromey at redhat dot com
  2013-02-04 20:18 ` naesten at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at redhat dot com @ 2012-03-05 19:42 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com

--- Comment #1 from Tom Tromey <tromey at redhat dot com> 2012-03-05 19:41:52 UTC ---
I was able to reproduce on Fedora 16.

I debugged it a little and it seems that we get the correct
address for these symbols in elfread.c, but then we
apparently have the wrong offset in the relevant target section,
so we compute the wrong address for the minsym.

-- 
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] 4+ messages in thread

* [Bug exp/13800] gdb does not print right values of getopt-related values
  2012-03-04 17:22 [Bug exp/13800] New: gdb does not print right values of getopt-related values spuebla at hotmail dot com
  2012-03-05 19:42 ` [Bug exp/13800] " tromey at redhat dot com
@ 2012-03-06 19:03 ` tromey at redhat dot com
  2013-02-04 20:18 ` naesten at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at redhat dot com @ 2012-03-06 19:03 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Tom Tromey <tromey at redhat dot com> 2012-03-06 19:02:32 UTC ---
Another weird thing this uncovered is our handling of LOC_UNRESOLVED.
Currently in the main objfile, things like optind are LOC_UNRESOLVED.
This causes them to be looked up as minsyms to find their values.
But in my case I have glibc debuginfo installed, and it seems to me
that it would be better to first defer to their definitions coming
from there.

-- 
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] 4+ messages in thread

* [Bug exp/13800] gdb does not print right values of getopt-related values
  2012-03-04 17:22 [Bug exp/13800] New: gdb does not print right values of getopt-related values spuebla at hotmail dot com
  2012-03-05 19:42 ` [Bug exp/13800] " tromey at redhat dot com
  2012-03-06 19:03 ` tromey at redhat dot com
@ 2013-02-04 20:18 ` naesten at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: naesten at gmail dot com @ 2013-02-04 20:18 UTC (permalink / raw)
  To: gdb-prs

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

Samuel Bronson <naesten at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |naesten at gmail dot com
         Resolution|                            |DUPLICATE

--- Comment #3 from Samuel Bronson <naesten at gmail dot com> 2013-02-04 20:18:47 UTC ---
This is a duplicate of PR 8588.

*** This bug has been marked as a duplicate of bug 8588 ***

-- 
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] 4+ messages in thread

end of thread, other threads:[~2013-02-04 20:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-04 17:22 [Bug exp/13800] New: gdb does not print right values of getopt-related values spuebla at hotmail dot com
2012-03-05 19:42 ` [Bug exp/13800] " tromey at redhat dot com
2012-03-06 19:03 ` tromey at redhat dot com
2013-02-04 20:18 ` naesten 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).