Hello, When compiling simple test programs with -g3 and input from the console (- (stdin)), the .debug_line section is wrong. Steps to reproduce this issue: 1. In your console type: arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -g3 -c -o test.o -x c - 2. Copy and paste: #include <stdio.h> int main(void) { printf("Hello World\n"); return 0; } 3. Ctrl+Z and Return 4. If you type: arm-none-eabi-readelf --debug-dump=decodedline test.o You get the following: Contents of the .debug_line section: CU: ./<stdin>: File name Line number Starting address View readelf: Warning: Badly formed extended line op encountered! readelf: Warning: Badly formed extended line op encountered! UNKNOWN (116): length 115 <stdin> 0 0xc <stdin> -1 0x1a <stdin> -1 0x1e <stdin> 1 0x2a UNKNOWN (0): length 4 <stdin> -1 0x36 <stdin> -6 0x42 <stdin> -8 0x50 <stdin> -7 0x5c <stdin> -7 0x60 <stdin> -5 0x6c UNKNOWN (0): length 2 <stdin> 2 0x76 <stdin> 2 0x84 <stdin> 7 0x92 <stdin> 3 0xa0 <stdin> 2 0xac <stdin> 1 0xba <stdin> 1 0xbe <stdin> 3 0xca UNKNOWN (0): length 4 <stdin> -1 0xd8 <stdin> -2 0xe4 <stdin> -3 0xf2 <stdin> -3 0xf6 <stdin> -1 0x102 UNKNOWN (0): length 1 UNKNOWN (115): length 95 <stdin> -2 0x110 <stdin> -6 0x11e <stdin> -7 0x12a <stdin> -10 0x136 <stdin> -10 0x13a <stdin> -8 0x146 UNKNOWN (0): length 1 UNKNOWN (112): length 95 5. Repeating the steps with -g instead of -g3 we get the right .debug_line section: Contents of the .debug_line section: CU: ./<stdin>: File name Line number Starting address View <stdin> 3 0 <stdin> 4 0x4 <stdin> 5 0xa <stdin> 6 0xc <stdin> 6 0x14
[insert "doctor it hurts when I do this ..." here ;)] Not specific to arm or cross-compiling, confirmed with GCC 9.2 on x86_64.
Created attachment 47359 [details] gcc10-pr92664.patch Untested fix.
Author: jakub Date: Wed Nov 27 00:23:39 2019 New Revision: 278752 URL: https://gcc.gnu.org/viewcvs?rev=278752&root=gcc&view=rev Log: PR debug/92664 * dwarf2out.c (lookup_filename): Use "<stdin>" instead of "". Modified: trunk/gcc/ChangeLog trunk/gcc/dwarf2out.c
Author: jakub Date: Fri Dec 20 17:23:34 2019 New Revision: 279658 URL: https://gcc.gnu.org/viewcvs?rev=279658&root=gcc&view=rev Log: Backported from mainline 2019-11-27 Jakub Jelinek <jakub@redhat.com> PR debug/92664 * dwarf2out.c (lookup_filename): Use "<stdin>" instead of "". Modified: branches/gcc-9-branch/gcc/ChangeLog branches/gcc-9-branch/gcc/dwarf2out.c
The releases/gcc-8 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:5c265f5f1977f7c935b8b54cfdb23c862f686f20 commit r8-9987-g5c265f5f1977f7c935b8b54cfdb23c862f686f20 Author: Jakub Jelinek <jakub@redhat.com> Date: Fri Feb 14 12:49:07 2020 +0100 backport: re PR debug/92664 (Wrong .debug_line section information when compiling stdin input with -g3) Backported from mainline 2019-11-27 Jakub Jelinek <jakub@redhat.com> PR debug/92664 * dwarf2out.c (lookup_filename): Use "<stdin>" instead of "".
Fixed for 8.4+ and 9.3+.