public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "spuebla at hotmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug exp/13800] New: gdb does not print right values of getopt-related values
Date: Sun, 04 Mar 2012 17:22:00 -0000	[thread overview]
Message-ID: <bug-13800-4717@http.sourceware.org/bugzilla/> (raw)

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.


             reply	other threads:[~2012-03-04 17:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-04 17:22 spuebla at hotmail dot com [this message]
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

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-13800-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: link
Be 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).