Bug 42782 - [4.5 Regression] VTA missed location: parameter via stack
Summary: [4.5 Regression] VTA missed location: parameter via stack
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P2 minor
Target Milestone: 4.5.0
Assignee: Alexandre Oliva
Keywords: wrong-debug
Depends on:
Reported: 2010-01-17 21:33 UTC by Jan Kratochvil
Modified: 2010-01-22 17:02 UTC (History)
2 users (show)

See Also:
Target: i386-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2010-01-18 10:13:58


Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2010-01-17 21:33:10 UTC
gcc (GCC) 4.5.0 20100117 (experimental)
x86_64-unknown-linux-gnu running -m32
Reproduced on Fedora 12: gcc-4.4.2-20.fc12.x86_64
extern void g (void);

f (int a)
  g ();

  return a;
gcc -o 1.o -c -Wall 1.c -m32 -O1 -g -Wall
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 08                sub    $0x8,%esp
   6:   e8 fc ff ff ff          call   7 <f+0x7>
   b:   8b 45 08                mov    0x8(%ebp),%eax
   e:   c9                      leave  
   f:   c3                      ret    
Contents of the .debug_info section:
 <2><40>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <41>   DW_AT_name        : a        
    <49>   DW_AT_location    : 0x38     (location list)

Contents of the .debug_loc section:
    Offset   Begin    End      Expression
    00000038 00000000 0000000a (DW_OP_fbreg: 0)
    00000038 <End of list>
Offsets 0xb .. 0xf miss the A location.
The function must know it when it returns A.
Practical impact:
Backtrace missed parameters of elf_lookup_lib_symbol() in:
Comment 1 Jan Kratochvil 2010-01-17 23:23:18 UTC
Noticed it is a regression against: gcc (GCC) 4.4.3 20100117 (prerelease)
Comment 2 Jakub Jelinek 2010-01-18 10:13:58 UTC
Reproduced.  Works with -fno-var-tracking-assignments, and looks to be a var-tracking.c problem - the testcase doesn't contain (and doesn't need to contain) any DEBUG_INSNs.
Comment 3 Jakub Jelinek 2010-01-18 10:57:49 UTC
The problem is that dataflow_set_preserve_mem_locs and/or
dataflow_set_remove_mem_locs removes all MEMs (with the exception of those referring to decl with 0 MEM_OFFSET in the first function) upon encountering a CALL.  For parameters (ARG_POINTER_REGNUM based, or even HARD_FRAME_POINTER_REGNUM based ones I believe) we don't need to remove them, as long as the decl isn't addressable and thus the call shouldn't have modified them.
Comment 4 Alexandre Oliva 2010-01-19 08:44:33 UTC
Mine (testing a patch)
Comment 5 Jakub Jelinek 2010-01-20 22:57:34 UTC
Subject: Bug 42782

Author: jakub
Date: Wed Jan 20 22:57:20 2010
New Revision: 156092

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156092
	PR debug/42782
	* var-tracking.c: Include tree-flow.h.
	(mem_dies_at_call): New.
	(dataflow_set_preserve_mem_locs): Use it.
	(dataflow_set_remove_mem_locs): Likewise.
	(dump_var): Renamed from dump_variable.  Adjust all callers.
	(dump_var_slot): Renamed from dump_variable_slot.  Likewise.
	* Makefile.in (var-tracking.o): Adjust deps.

	* gcc.dg/guality/pr42782.c: New.


Comment 6 Jakub Jelinek 2010-01-22 17:02:59 UTC