Bug 41558 - gfortran -O code excessive DW_OP_deref's
Summary: gfortran -O code excessive DW_OP_deref's
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-03 19:10 UTC by Jan Kratochvil
Modified: 2009-10-12 19:09 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
gcc45-pr41558.patch (4.74 KB, patch)
2009-10-05 09:52 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2009-10-03 19:10:47 UTC
GNU Fortran (GCC) 4.5.0 20091003 (experimental)

  subroutine f(s)
  character*3 s
  s = s
  end
  call f ('foo')
  end

gdb -nx -ex 'b 3' -ex r -ex 'p s' ./file
->
Cannot access memory at address 0x6f6f66

 <2><4a>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <4b>   DW_AT_name        : s        
    <4f>   DW_AT_type        : <0x64>   
    <53>   DW_AT_location    : 4 byte block: 75 0 6 6   (DW_OP_breg5: 0; DW_OP_deref; DW_OP_deref)

If I patch those two DW_OP_deref -> DW_OP_nop then GDB prints:
$1 = 'foo'

gfortran -o 1 1.f90 -Wall -g -O1 

currently:
.LC0:
        .ascii  "foo"
...
        movl    $.LC0, %edi
...
        .byte   0x4     # DW_AT_location
        .byte   0x75    # DW_OP_breg5
        .sleb128 0
        .byte   0x6     # DW_OP_deref
        .byte   0x6     # DW_OP_deref
Comment 1 Jakub Jelinek 2009-10-05 09:52:24 UTC
Created attachment 18706 [details]
gcc45-pr41558.patch

Patch I'm going to bootstrap/regtest.

BTW, gdb 7.0.50.20091005-cvs doesn't work with the guality.exp testcases well, something broke in it recently.  6.8.91.20090917-1.fc12 works fine.
Comment 2 Jakub Jelinek 2009-10-05 19:51:12 UTC
Subject: Bug 41558

Author: jakub
Date: Mon Oct  5 19:50:57 2009
New Revision: 152467

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152467
Log:
	PR debug/41558
	* dwarf2out.c (loc_by_reference): Removed.
	(dw_loc_list_1): New function.
	(dw_loc_list): Remove toplev argument, add want_address argument.
	Don't look at decl_by_reference_p at all.  Use dw_loc_list_1.
	(loc_list_from_tree) <case VAR_DECL>: Pass want_address rather than
	want_address == 2 to dw_loc_list.  For successful dw_loc_list
	set have_address to 1 only if want_address is not 0.

	* gcc.dg/guality/guality.exp: Move gdb-test proc into...
	* lib/gcc-gdb-test.exp: ... here.  New file.
	* gfortran.dg/guality/guality.exp: New file.
	* gfortran.dg/guality/pr41558.f90: New test.
	* gfortran.dg/guality/arg1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/guality/
    trunk/gcc/testsuite/gfortran.dg/guality/arg1.f90
    trunk/gcc/testsuite/gfortran.dg/guality/guality.exp
    trunk/gcc/testsuite/gfortran.dg/guality/pr41558.f90
    trunk/gcc/testsuite/lib/gcc-gdb-test.exp
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/guality/guality.exp

Comment 3 Jan Kratochvil 2009-10-06 15:28:07 UTC
(In reply to comment #1)
> BTW, gdb 7.0.50.20091005-cvs doesn't work with the guality.exp testcases well,
> something broke in it recently.  6.8.91.20090917-1.fc12 works fine.

There is an array with variable size: integer :: a(n), n
VLA support is still missing in FSF GDB, it is present in Archer (+Fedora) branch archer-jankratochvil-vla:
http://sourceware.org/gdb/wiki/ArcherBranchManagement
Comment 4 Jakub Jelinek 2009-10-12 19:09:24 UTC
Fixed.