[Bug debug/101669] error reading variable from debug information when compiling with -O2

2021-07-29 Thread guojiufu at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101669

Jiu Fu Guo  changed:

   What|Removed |Added

 Resolution|--- |WONTFIX
 Status|NEW |RESOLVED

--- Comment #8 from Jiu Fu Guo  ---
(In reply to Andrew Pinski from comment #6)
> Hmmm, maybe https://sourceware.org/bugzilla/show_bug.cgi?id=27999

Thanks, Andrew.

Great! With the latest gdb from the trunk, it is ok. 

(gdb) b sub
Breakpoint 1 at 0xa58: file /home/guojiufu/temp/gdb.f90, line 9.
(gdb) b 17
Breakpoint 2 at 0xafc: file /home/guojiufu/temp/gdb.f90, line 17.
(gdb) r
Starting program: /home/guojiufu/temp/gdb/binutils-gdb/arg1.exe

Breakpoint 1, 0x00010a58 in sub (a=..., n=10) at
/home/guojiufu/temp/gdb.f90:9
9   subroutine sub (a, n)
(gdb) c
Continuing.

Breakpoint 2, sub (a=..., n=10) at /home/guojiufu/temp/gdb.f90:17
17write (*,*) a
(gdb) p a
$1 = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
(gdb) 

So, it seems not to be an issue from GCC, and works fine on with the latest
binutils.

Thanks all!

[Bug debug/101669] error reading variable from debug information when compiling with -O2

2021-07-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101669

--- Comment #7 from Andrew Pinski  ---
(In reply to Jiu Fu Guo from comment #5)
> readelf --debug-dump arg1.exe |grep readelf
> readelf: Error: Invalid location list entry type 8

DW_LLE_start_length = 0x08,

Didn't make it into binutils until 2.35:
https://sourceware.org/pipermail/binutils/2020-November/114140.html


gdb support went in at
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;f=gdb/dwarf2/loc.c;h=3112ed9799124edf4d1f9c903da0d59f5a4ca102

Which did not make it until gdb 10.0.

[Bug debug/101669] error reading variable from debug information when compiling with -O2

2021-07-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101669

--- Comment #6 from Andrew Pinski  ---
Hmmm, maybe https://sourceware.org/bugzilla/show_bug.cgi?id=27999

[Bug debug/101669] error reading variable from debug information when compiling with -O2

2021-07-29 Thread guojiufu at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101669

--- Comment #5 from Jiu Fu Guo  ---
(In reply to Andrew Pinski from comment #4)
> What version of gdb are you using?

Tried gdb8.1/8.3/9.2 on ppc64le.
In gdb, the msg "error reading variable: dwarf2_find_location_expression:"
occurs when stopping at the breakpoint 'sub' on the tip message:

Breakpoint 1, 0x00010a58 in sub (a=, n=10) at
/home/guojiufu/temp/gdb.f90:7


readelf --debug-dump arg1.exe |grep readelf
readelf: Error: Invalid location list entry type 8
readelf: Warning: Hole and overlap detection requires adjacent view lists and
loclists.


readelf -v
GNU readelf (GNU Binutils for Ubuntu) 2.34
readelf 2.30 can also get the Error/Warning msg.


gfortran -O2 -g ~/temp/gdb.f90 -gdwarf-5 -o arg1.exe

On x86 is similar, readelf2.30/gdb8.1 can reproduce the msg at my side.

Before gcc11, need -gdwarf-5 to reproduce since we default to this dwarf
version in gcc11.

[Bug debug/101669] error reading variable from debug information when compiling with -O2

2021-07-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101669

--- Comment #4 from Andrew Pinski  ---
What version of gdb are you using?

[Bug debug/101669] error reading variable from debug information when compiling with -O2

2021-07-29 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101669

--- Comment #3 from Jakub Jelinek  ---
This is weird.  There is no .debug_loc section with DWARF 5 at all, only
.debug_loclists.
I don't see any complains from readelf:
readelf --debug-dump=loc pr101669 >/dev/null
(binutils 2.36.1).
And no errors from gdb (10.2).
So isn't this because of too old gdb or binutils?

[Bug debug/101669] error reading variable from debug information when compiling with -O2

2021-07-29 Thread guojiufu at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101669

--- Comment #2 from Jiu Fu Guo  ---
Similar to what Richard said,  tested with gdb, use -gdwarf-4 with trunk, the
msg also disappears.

[Bug debug/101669] error reading variable from debug information when compiling with -O2

2021-07-29 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101669

Richard Biener  changed:

   What|Removed |Added

 Ever confirmed|0   |1
Version|11.0|11.1.1
   Keywords||wrong-debug
 CC||jakub at gcc dot gnu.org
   Last reconfirmed||2021-07-29
 Status|UNCONFIRMED |NEW

--- Comment #1 from Richard Biener  ---
gdb doesn't complain for me but readelf does:

readelf: Warning: Location lists in .debug_loc section start at 0x10
readelf: Warning: Location list starting at offset 0x10 is not terminated.
readelf: Warning: Hole and overlap detection requires adjacent view lists and
loclists.
readelf: Warning: Location list starting at offset 0x2b is not terminated.
readelf: Warning: There is an overlap [0xe4 - 0x0] in .debug_loc section.

it doesn't happen with -gdwarf-4.  It also happens with GCC 9 and -gdwarf-5.
With GCC 7 and -gdwarf-5 there are many more complaints from readelf.