← Back to team overview

touch-packages team mailing list archive

[Bug 1224651] Re: gdb displays wrong values for variables while debugging c code

 

closing as invalid. please recheck with 14.04 LTS and 14.10, and re-open
the issue if appropriate.

** Changed in: gdb (Ubuntu)
       Status: Confirmed => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to gdb in Ubuntu.
https://bugs.launchpad.net/bugs/1224651

Title:
  gdb displays wrong values for variables while debugging c code

Status in “gdb” package in Ubuntu:
  Invalid

Bug description:
  Hi,
  gdb shows wrong values for variables when displayed through "print <variable name>" command. Although it is not the case always and I cannot figure out under what circumstances this happens. 
  I checked the value of the variable by adding printf command directly in the code, the actual value printed to stdout is correct. Only the gdb shows wrong value.

  Environment details : 
  Linux mint 15 (based on Ubuntu 13.04)

  gdb version :
  GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu

  gdb configuration:
  "i686-linux-gnu"

  steps to reproduce the bug:

  compile the attached c source code (source code is a simple demo of getopt_long function) using,
  gcc -o gdb_bug_rpt gdb_bug_rpt.c -g -Wall -pedantic

  run the code using gdb
  gdb ./gdb_bug_rpt
  cmds given below are gdb commands,
  (gdb)break main
  (gdb)run -o file1 file 2 file3
  (gdb)next
  ...
  (gdb)next (step through the code until line -- 	printf ("value of optind = %d\n", optind);
  now check value of optind variable using print cmd
  (gdb)print optind 
  gdb will display the value to be 1, but the actual value is 3 ,which you can see by executing the printf line.
  Also the value of optind is assigned to variable i.you can also check the value of i using print i after executing the foe loop for the first time. the value of i is also found to be 3.

  But gdb displays wrong values to the user.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1224651/+subscriptions