This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug exp/13800] New: gdb does not print right values ofgetopt-related values


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]