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]

exp/2319: value of variable used in nested procedure and parent procedure displays incorrectly


>Number:         2319
>Category:       exp
>Synopsis:       value of variable used in nested procedure and parent procedure displays incorrectly
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 14 21:38:02 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Seth Grover
>Release:        6.6
>Organization:
>Environment:
Ubuntu 7.04 i386, 2.6.20-16-generic kernel
>Description:
Given the following tiny test program:

==========================================
#include <stdio.h>

int
main (int argc, char *argv[])
{
  int a;
 
  void whatever ()
  {
    a = 123;
  }
 
  whatever();
  a = 321;
  return 0;
}
==========================================

I run this program in GDB, and break right before the call to whatever(). At this point, I print "a", and the value is no good, but the variable is uninitialized so that's expected. However, after the other statements which set the value of "a", printing "a" still show the uninitialized value.

The program is actually executing correctly, as I can see by inserting printf statements. It appears gdb is simply not getting the value correctly.

If I remove the use of "a" within the nested procedure, gdb works as expected.

This seems to be a serious bug, as debugging with nested procedures is essentially useless if you're using the same variables in both the nested and the parent procedures.

>How-To-Repeat:
- Save the test program mentioned in the description as test.c

- Compile the test program mentioned in the description:
  gcc -g test.c

- Run the output in gdb
  gdb ./a.out

- Place breakpoints after the assignment of "a" in the program, then "print a". You'll see the value is bad.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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