https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103436
Bug ID: 103436 Summary: gnatD debug info refers to original rather than generated file Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider gdb test-case: ... $ cat src/gdb/testsuite/gdb.ada/dgopt/x.adb -- Copyright 2019-2021 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. procedure X is begin null; end X; ... Compiled with gnatmake: ... $ gnatmake x.adb -gnatDG -f -I/home/vries/gdb_versions/devel/src/gdb/testsuite/gdb.ada/dgopt -g -lm -o x gcc -c -I./ -gnatDG -I/home/vries/gdb_versions/devel/src/gdb/testsuite/gdb.ada/dgopt -g -lm -I- /home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/dgopt/x.adb gnatbind -I/home/vries/gdb_versions/devel/src/gdb/testsuite/gdb.ada/dgopt -x x.ali gnatlink x.ali -g -o x ... We find a compile unit in .debug_info with: ... <7bf> DW_AT_name : /home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/dgopt/x.adb <7c3> DW_AT_comp_dir : /home/vries/gdb_versions/devel ... and a corresponding .debug_line contribution: ... The Directory Table is empty. The File Name Table (offset 0x1a9): Entry Dir Time Size Name 1 0 0 0 x.adb.dg ... The documentation for gnatD ( https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gnat_ugn/Debugging-Control.html#index--gnatD-_0028gcc_0029 ) states that: ... The debugging information generated by the gcc -g switch will refer to the generated xxx.dg file. ... For the .debug_line part, that seems to be the case. For the .debug_info part, not so. So AFAIU the option doesn't match the spec. My understanding is that this should be fixed in the compiler. If not, then the documentation should be updated to clarify that it's related to line information.