In generating DWARF debugging information, GCC produces a single location for
some formal parameters instead of a location list. This location is not valid
until the function prologue copies the parameter from the location where it
exists at function entry into the assigned location. A debugger would be able
to show the value of the parameter at function entry if GCC provided a location
list instead. Users of GDB who simply ask to break on a function generally get
the correct value for the parameter because GDB sets the breakpoint not at
function entry, but at some point in or after the function prologue. Users of
other debuggers, however, could get incorrect values for the parameter at
function entry even though GCC knows where the parameter is and could provide
that information to a consumer in a location list.

 gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)

gcc -save-temps -g -o gccdw gccdw.c

cat gccdw.i
# 1 "gccdw.c"
# 1 "/u01/jdraper/projects/l1//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "gccdw.c"
int foo (int *);

int
main (int argc, char** argv)
{
  int x;
  x = atoi (argv[1]);
  foo (&x);
  return 1;
}

int
foo (int *y)
{
  int j;
  for (j = 2; j < 8; j++) {
    *y = *y/j;
  }
}


-- 
           Summary: GCC produces single locations instead of location lists
                    for some formal parameters
           Product: gcc
           Version: 4.2.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jdraper at super dot org
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39703

Reply via email to