https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111958
Bug ID: 111958 Summary: Line number debugging information indicates wrong file Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: shelmer.gcc at gmail dot com Target Milestone: --- Created attachment 56188 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56188&action=edit Preprocessed file for getgid.c The line number debugging information is incorrect for versions 12.2.0 and 13.2.0. Sometimes the wrong file is used in the ".loc" assembler directives which causes issues with GDB then debugging application. This does not happen with version 4.8.5 or 4.8.9 (which come with REHL7). Command line to reproduce: gcc -v --save-temps -c -g -O2 getgid.c Output from gcc-13.2.0: Using built-in specs. COLLECT_GCC=gcc Target: x86_64-pc-linux-gnu Configured with: /export/wildstar1/helmers/toolset_test/TCore_Toolset/src/gcc-13.2.0/configure --disable-maintainer-mode --disable-multilib --prefix=/export/wildstar1/helmers/toolset_test/TCore_Toolset --datarootdir=/export/wildstar1/helmers/toolset_test/TCore_Toolset --disable-bootstrap --with-gmp=/export/wildstar1/helmers/toolset_test/TCore_Toolset --with-mpfr=/export/wildstar1/helmers/toolset_test/TCore_Toolset --with-mpc=/export/wildstar1/helmers/toolset_test/TCore_Toolset Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-O2' '-mtune=generic' '-march=x86-64' /export/wildstar1/helmers/toolset_test/TCore_Toolset/libexec/gcc/x86_64-pc-linux-gnu/13.2.0/cc1 -E -quiet -v getgid.c -mtune=generic -march=x86-64 -g -fworking-directory -O2 -fpch-preprocess -o getgid.i ignoring nonexistent directory "/export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/include /usr/local/include /export/wildstar1/helmers/toolset_test/TCore_Toolset/include /export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-O2' '-mtune=generic' '-march=x86-64' /export/wildstar1/helmers/toolset_test/TCore_Toolset/libexec/gcc/x86_64-pc-linux-gnu/13.2.0/cc1 -fpreprocessed getgid.i -quiet -dumpbase getgid.c -dumpbase-ext .c -mtune=generic -march=x86-64 -g -O2 -version -o getgid.s GNU C17 (GCC) version 13.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 4.8.5 20150623 (Red Hat 4.8.5-44), GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 39ec987cd36af7de9356af0202288cf7 COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-O2' '-mtune=generic' '-march=x86-64' /export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/../../../../x86_64-pc-linux-gnu/bin/as -v --gdwarf-5 --64 -o getgid.o getgid.s GNU assembler version 2.41 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.41 COMPILER_PATH=/export/wildstar1/helmers/toolset_test/TCore_Toolset/libexec/gcc/x86_64-pc-linux-gnu/13.2.0/:/export/wildstar1/helmers/toolset_test/TCore_Toolset/libexec/gcc/x86_64-pc-linux-gnu/13.2.0/:/export/wildstar1/helmers/toolset_test/TCore_Toolset/libexec/gcc/x86_64-pc-linux-gnu/:/export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/:/export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/:/export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/../../../../x86_64-pc-linux-gnu/bin/ LIBRARY_PATH=/export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/:/export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/../../../../x86_64-pc-linux-gnu/lib/:/export/wildstar1/helmers/toolset_test/TCore_Toolset/lib/gcc/x86_64-pc-linux-gnu/13.2.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-O2' '-mtune=generic' '-march=x86-64' If you look at the assembly file generated by versions 4.8.5 and 13.2.0 you can clearly see that some of the ".loc" directives from version 13.2.0 show that a couple of the functions are located in unistd.h. When using version 4.8.5 all ".loc" directives indicate that all functions are located in getgid.c (as expected).