This is the mail archive of the gdb-prs@sources.redhat.com 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/1656: if gdb cannot find function return value location, random unitialized value is used


>Number:         1656
>Category:       exp
>Synopsis:       if gdb cannot find function return value location, random unitialized value is used
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 23 14:38:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     mec.gnu@mindspring.com
>Release:        gdb 6.1
>Organization:
>Environment:
native i686-pc-linux-gnu
gcc HEAD 2004-05-14 21:34:48 UTC
>Description:
This is fallout from the gcc tree-ssa merge.

Consider this source code from gdb.base/structs.c:

  zed ();
  L1  = fun1();

With pre-merge gcc HEAD, the generated code looks like this:

  push &L1
  call fun1

With post-merge gcc HEAD, the generated code looks like this:

  push &tmp
  call fun1
  L1 = tmp

The user does this:

  (gdb) break main
  (gdb) run
  (gdb) advance fun1
  (gdb) return foo1
  The location at which to store the function's return value is unknown.
  If you continue, the return value that you specified will be ignored.
  Make fun1 return now? (y or n) y

At this point gdb suppresses the return value and forces the function to return.

With the pre-merge gcc HEAD, suppressing the return value means that the old value is left in L1.  gdb.base/structs.exp is prepared for this to happen.

With the post-merge gcc HEAD, suppressing the return value means that the uninitialized temporary 'tmp' is left uninitialized.  This uninitialized value is copied from 'tmp' to L1.  gdb.base/structs.exp is not prepared for this to happen.
>How-To-Repeat:
Run structs.exp with gcc HEAD.
>Fix:
(1) Add some doco like this for the "return" command:

"Sometimes, gdb does not know where the return value of a function is located.  This is more likely to happen if the return value is an aggregate value such as a structure value.  If this happens, gdb will ask you whether you want to continue forcing the function to return.  If you do continue, the function return value may be undefined or random".

(2) Add another line to the warning from gdb that the return value may be undefined or random.

(3) Enhance structs.exp so that if gdb emits this warning, structs.exp does not expect any specific value at all for the return value.
>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]