https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70645

            Bug ID: 70645
           Summary: [4.9/5/6 Regression] -fguess-branch-probability breaks
                    debug-information, only in Ada
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

I can not debug some executable files generated by recent gcc Ada frontend,
with all optimization-levels including -fguess-branch-probability.
(I'm troubled with -Og. I've understood that -Og is intended to debug.)

gcc-4.9, gcc-5, and gcc-6 have failed.
However, gcc-4.8 works well.

C/C++ and Fortran frontends work well on all versions.

Note, I tried gdb from 7.9 to 7.11 as debugger.

% cat hello.adb
with Ada.Text_IO;
procedure Hello is
begin
   Ada.Text_IO.Put_Line ("Hello.");
end Hello;

% gcc -v
gcc (GCC) 6.0.0 20160401 (experimental)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% gnatmake -g -Og hello
gcc -c -g -Og hello.adb
gnatbind -x hello.ali
gnatlink hello.ali -g -Og

% gdb hello     
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10.8.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello...Reading symbols from
hello.dSYM/Contents/Resources/DWARF/hello...done.
done.
(gdb) start
Temporary breakpoint 1 at 0x1000014f1
Starting program: hello 

Temporary breakpoint 1, 0x00000001000014f1 in hello ()
(gdb) s
Single stepping until exit from function _ada_hello,
which has no line number information. # <<<< Please look here !!!!
Hello.
main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>)
    at b~hello.adb:197
197           adafinal;
(gdb) quit
A debugging session is active.

        Inferior 1 [process 45663] will be killed.

Quit anyway? (y or n) y

% gnatmake -f -g -Og -fno-guess-branch-probability hello
gcc -c -g -Og -fno-guess-branch-probability hello.adb
gnatbind -x hello.ali
gnatlink hello.ali -g -Og -fno-guess-branch-probability

% gdb hello                                             
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10.8.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello...Reading symbols from
hello.dSYM/Contents/Resources/DWARF/hello...done.
done.
(gdb) start
Temporary breakpoint 1 at 0x10000154e: file hello.adb, line 2.
Starting program: hello 

Temporary breakpoint 1, _ada_hello () at hello.adb:2
2       procedure Hello is
(gdb) s
4          Ada.Text_IO.Put_Line ("Hello."); # <<<< It works fine.
(gdb) s
ada__text_io__put_line__2 (item=...) at a-textio.adb:1424
1424       procedure Put_Line (Item : String) is
(gdb) quit
A debugging session is active.

        Inferior 1 [process 45704] will be killed.

Quit anyway? (y or n) y


# **** Example of gcc-4.8 from here: ****


% gcc --version
gcc (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% gnatmake -f -g -Og hello
gcc -c -g -Og hello.adb
gnatbind -x hello.ali
gnatlink hello.ali -g -Og

% gdb hello               
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10.8.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello...
warning: dsym file UUID doesn't match the one in hello
done.
(gdb) start
Temporary breakpoint 1 at 0x100001648: file hello.adb, line 2.
Starting program: hello 

Temporary breakpoint 1, _ada_hello () at hello.adb:2
2       procedure Hello is
(gdb) s
4          Ada.Text_IO.Put_Line ("Hello."); # <<<< It works, too.
(gdb) s
ada__text_io__put_line__2 (item=...) at a-textio.adb:1426
1426    a-textio.adb: No such file or directory.
(gdb) quit
A debugging session is active.

        Inferior 1 [process 45793] will be killed.

Quit anyway? (y or n) y

Reply via email to