public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified
@ 2011-06-12 11:15 jan.kratochvil at redhat dot com
  2011-06-13 19:32 ` [Bug debug/49382] " jakub at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-06-12 11:15 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: -O2 -g: DW_AT_location at the very first PC is already
                    modified
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jan.kratochvil@redhat.com
                CC: jakub@gcc.gnu.org
            Target: x86_64-unknown-linux-gnu


int i;
void __attribute__((noinline, noclone))
clobber (int x)
{
  i = x;
}
void __attribute__((noinline, noclone))
func (int x)
{
  clobber (x++);
  i = 1;    /* line 11 */
}
int main (void) { func (5); return 0; }

gcc -c -Wall -g -O2

PASS gcc (GCC) 4.4.7 20110611 (prerelease)
FAIL gcc (GCC) 4.5.4 20110612 (prerelease)
FAIL gcc (GCC) 4.6.1 20110612 (prerelease)
FAIL gcc (GCC) 4.7.0 20110612 (experimental)

 <1><5c>: Abbrev Number: 2 (DW_TAG_subprogram)
    <5e>   DW_AT_name        : (indirect string, offset: 0x3d): func
    <65>   DW_AT_low_pc      : 0x10
    <6d>   DW_AT_high_pc     : 0x20
 <2><7c>: Abbrev Number: 5 (DW_TAG_formal_parameter)
    <7d>   DW_AT_name        : x
    <85>   DW_AT_location    : 0x0      (location list)

FAIL:
Offset Begin          End              Expression
000000 00000000000010 0000000000000014 (DW_OP_breg5 (rdi): 1;
DW_OP_stack_value)
000000 <End of list>
+
0000000000000010 <func>:
void __attribute__((noinline, noclone))
func (int x)
{
  clobber (x++);
  10:   e8 00 00 00 00          callq  15 <func+0x5>
                        11: R_X86_64_PC32       clobber-0x4

PASS:
Offset Begin          End              Expression
000000 00000000000010 0000000000000015 (DW_OP_reg5 (rdi))
000000 <End of list>

One should see X and not X + 1.
(gdb) break *func
Breakpoint 1 at 0x400480: file /home/jkratoch/t/entrypc.c, line 10.
(gdb) run
FAIL:
Breakpoint 1, func (x=6) at /home/jkratoch/t/entrypc.c:10
PASS:
Breakpoint 1, func (x=5) at /home/jkratoch/t/entrypc.c:10

Also at the very first PC one needs to know the register to match it
DW_TAG_GNU_call_site_parameter->DW_AT_location in the caller.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/49382] -O2 -g: DW_AT_location at the very first PC is already modified
  2011-06-12 11:15 [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified jan.kratochvil at redhat dot com
@ 2011-06-13 19:32 ` jakub at gcc dot gnu.org
  2011-06-13 19:37 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-13 19:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aoliva at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-13 19:27:51 UTC ---
I'm afraid that without statement frontiers there is nothing that can be done
about it, and it is a question whether to call it a bug at all.
The side effect (which has been optimized away) just happens so early that
there are no real insns left before it.
  x_2 = x_1(D);
  # DEBUG x => x_1(D) + 1
  clobber (x_2);
  i = 1;
  return;
simply becomes:
  # DEBUG x => x_1(D) + 1
  clobber (x_1(D));
  i = 1;
  return;

Claiming the side effect happens after the call wouldn't be correct, the side
effect really happens before the call and the call is the first insn.
With statement frontiers you could step through the zero-length insn between
start of the function (where x would be live in DW_OP_reg5) to the location
before the first call (where x would be already DW_OP_breg5 <1>
DW_OP_stack_value).


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/49382] -O2 -g: DW_AT_location at the very first PC is already modified
  2011-06-12 11:15 [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified jan.kratochvil at redhat dot com
  2011-06-13 19:32 ` [Bug debug/49382] " jakub at gcc dot gnu.org
@ 2011-06-13 19:37 ` jakub at gcc dot gnu.org
  2011-06-13 19:53 ` jan.kratochvil at redhat dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-13 19:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-13 19:36:42 UTC ---
Alternatively, even before statement frontiers we could special case parameters
(PARM_DECLs and vars with PARM_DECL DECL_ABSTRACT_ORIGIN) before the first insn
in a function and just emit a zero-length location range for those.  So you
would get:
.LLST0:
        .quad   .LVL1   # Location list begin address (*.LLST0)
        .quad   .LVL1   # Location list end address (*.LLST0)
        .value  0x1     # Location expression size
        .byte   0x55    # DW_OP_reg5
        .quad   .LVL1   # Location list begin address (*.LLST0)
        .quad   .LVL2-1 # Location list end address (*.LLST0)
        .value  0x3     # Location expression size
        .byte   0x75    # DW_OP_breg5
        .sleb128 1
        .byte   0x9f    # DW_OP_stack_value
        .quad   .LVL2-1 # Location list begin address (*.LLST0)
        .quad   .LFE1   # Location list end address (*.LLST0)
        .value  0x6     # Location expression size
        .byte   0xf3    # DW_OP_GNU_entry_value
        .uleb128 0x1
        .byte   0x55    # DW_OP_reg5
        .byte   0x23    # DW_OP_plus_uconst
        .uleb128 0x1
        .byte   0x9f    # DW_OP_stack_value
        .quad   0       # Location list terminator begin (*.LLST0)
        .quad   0       # Location list terminator end (*.LLST0)

Wonder how many dwarflints etc. would complain about it loudly though.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/49382] -O2 -g: DW_AT_location at the very first PC is already modified
  2011-06-12 11:15 [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified jan.kratochvil at redhat dot com
  2011-06-13 19:32 ` [Bug debug/49382] " jakub at gcc dot gnu.org
  2011-06-13 19:37 ` jakub at gcc dot gnu.org
@ 2011-06-13 19:53 ` jan.kratochvil at redhat dot com
  2011-06-14 10:30 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-06-13 19:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-06-13 19:52:45 UTC ---
(In reply to comment #2)
> we could special case parameters (PARM_DECLs and vars with PARM_DECL
> DECL_ABSTRACT_ORIGIN) before the first insn

At least temporarily it would be needed to get the entry values working in more
cases.  While some dwarflints may complain re-stating it is allowed by DWARF-4:

# A location list entry (but not a base address selection or end of list entry)
# whose beginning and ending addresses are equal has no effect because the size
# of the range covered by such an entry is zero.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/49382] -O2 -g: DW_AT_location at the very first PC is already modified
  2011-06-12 11:15 [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified jan.kratochvil at redhat dot com
                   ` (2 preceding siblings ...)
  2011-06-13 19:53 ` jan.kratochvil at redhat dot com
@ 2011-06-14 10:30 ` jakub at gcc dot gnu.org
  2011-06-14 12:51 ` jan.kratochvil at redhat dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-14 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.06.14 10:28:52
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-14 10:28:52 UTC ---
Created attachment 24518
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24518
gcc47-pr49382.patch

Untested patch to implement that.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/49382] -O2 -g: DW_AT_location at the very first PC is already modified
  2011-06-12 11:15 [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified jan.kratochvil at redhat dot com
                   ` (3 preceding siblings ...)
  2011-06-14 10:30 ` jakub at gcc dot gnu.org
@ 2011-06-14 12:51 ` jan.kratochvil at redhat dot com
  2011-06-14 12:55 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-06-14 12:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-06-14 12:50:22 UTC ---
../../../gccemptyrange/libgcc/../gcc/config/soft-fp/floattitf.c:34:8: warning:
no previous prototype for ‘__floattitf’ [-Wmissing-prototypes]
../../../gccemptyrange/libgcc/../gcc/config/soft-fp/floattitf.c: In function
‘__floattitf’:
../../../gccemptyrange/libgcc/../gcc/config/soft-fp/floattitf.c:45:1: internal
compiler error: Segmentation fault

Program received signal SIGSEGV, Segmentation fault.
0x0000000000be4403 in add_var_loc_to_decl (decl=0x7ffff1fa3b28,
loc_note=0x7ffff1de7a80, label=0x7ffff1f63b88 "*.LVL2") at
../../gccemptyrange/gcc/dwarf2out.c:8633
8633          && GET_CODE (NOTE_VAR_LOCATION_LOC (temp->first->loc))

(I did not have -g3 to say more.)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/49382] -O2 -g: DW_AT_location at the very first PC is already modified
  2011-06-12 11:15 [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified jan.kratochvil at redhat dot com
                   ` (4 preceding siblings ...)
  2011-06-14 12:51 ` jan.kratochvil at redhat dot com
@ 2011-06-14 12:55 ` jakub at gcc dot gnu.org
  2011-06-15  9:57 ` jakub at gcc dot gnu.org
  2011-06-15  9:59 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-14 12:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-14 12:54:34 UTC ---
Yeah, sure, I've noticed that an hour ago too.  Fixed in my copy, but now libgo
build failed for unrelated reason :(.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/49382] -O2 -g: DW_AT_location at the very first PC is already modified
  2011-06-12 11:15 [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified jan.kratochvil at redhat dot com
                   ` (5 preceding siblings ...)
  2011-06-14 12:55 ` jakub at gcc dot gnu.org
@ 2011-06-15  9:57 ` jakub at gcc dot gnu.org
  2011-06-15  9:59 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-15  9:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-15 09:56:36 UTC ---
Author: jakub
Date: Wed Jun 15 09:56:33 2011
New Revision: 175076

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175076
Log:
    PR debug/49382
    * dwarf2out.c (dw_loc_list_node): Add force field.
    (add_var_loc_to_decl): For PARM_DECL, attempt to keep
    the incoming location in the list, even if it is modified
    before first real insn.
    (output_loc_list): Emit empty ranges with force flag set.
    (dw_loc_list): If first range of a PARM_DECL is empty,
    set force flag.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug debug/49382] -O2 -g: DW_AT_location at the very first PC is already modified
  2011-06-12 11:15 [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified jan.kratochvil at redhat dot com
                   ` (6 preceding siblings ...)
  2011-06-15  9:57 ` jakub at gcc dot gnu.org
@ 2011-06-15  9:59 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-15  9:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-15 09:59:15 UTC ---
Should be fixed on the trunk.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-06-15  9:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-12 11:15 [Bug debug/49382] New: -O2 -g: DW_AT_location at the very first PC is already modified jan.kratochvil at redhat dot com
2011-06-13 19:32 ` [Bug debug/49382] " jakub at gcc dot gnu.org
2011-06-13 19:37 ` jakub at gcc dot gnu.org
2011-06-13 19:53 ` jan.kratochvil at redhat dot com
2011-06-14 10:30 ` jakub at gcc dot gnu.org
2011-06-14 12:51 ` jan.kratochvil at redhat dot com
2011-06-14 12:55 ` jakub at gcc dot gnu.org
2011-06-15  9:57 ` jakub at gcc dot gnu.org
2011-06-15  9:59 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).