From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 72C9E3858D35; Sun, 29 Jan 2023 10:23:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72C9E3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674987838; bh=k945AzrBBsIXBW039q79IZVA7/Dko4KAhCjDbdv0/vA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JNAkLhLJsHkNpkX5/8XyzGSQUIkuz5uO1qTBLg1sUCxREyVvIQhUl8g6BpHfZ9zPh CgCQc5Hv2ZnknDVFHxnoBSPfiHG9Nq4xbTRj2jtPdCAV+hwti3FgmeYkyLyj0q2DJM V/hJewjc9c0INwx+aNdFhlPZJ/TzDDTVxVFX6jiA= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/21470] gdb producer-sniffs for "clang" Date: Sun, 29 Jan 2023 10:23:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: symtab X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D21470 Tom de Vries changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vries at gcc dot gnu.org --- Comment #4 from Tom de Vries --- In commit 154f2735ad4 ("[gdb/testsuite] Fix gdb.ada/access_tagged_param.exp= for aarch64") I did: ... -if ![runto call_me] then { +if ![runto pck.adb:20] then { ... to make the test-case robust against problems in prologue analysis. Of course problems in prologue analysis need to be fixed, but we don't want= to be exposed to this in lots of unrelated test-cases, which then fail on some= but not on other architectures, hence the fix. Anyway, let's change this back, and look at what's generated: ... (gdb) break call_me^M Breakpoint 1 at 0x401f9a: file /home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/ref_p= aram/pck.adb, line 20.^M ... So, it looks like gdb decided that the first 3 insns are prologue: ... 0000000000401f92 : 401f92: 55 push %rbp 401f93: 48 89 e5 mov %rsp,%rbp 401f96: 48 89 7d f8 mov %rdi,-0x8(%rbp) 401f9a: 48 8b 45 f8 mov -0x8(%rbp),%rax ... Using additional_flags=3D-fdump-rtl-all and looking at pck.adb.309r.final w= e can confirm that the first 2 insns are prologue: ... (note 4 1 32 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (insn/f 32 4 33 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0 S8 A8]) (reg/f:DI 6 bp)) "/home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/ref_= param/pck.adb":18 57 {*pushdi2_rex64} (nil)) (insn/f 33 32 34 2 (set (reg/f:DI 6 bp) (reg/f:DI 7 sp)) "/home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/ref_= param/pck.adb":18 81 {*movdi_internal} (nil)) (insn 34 33 35 2 (set (mem/v:BLK (scratch:DI) [0 A8]) (unspec:BLK [ (mem/v:BLK (scratch:DI) [0 A8]) ] UNSPEC_MEMORY_BLOCKAGE)) "/home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/ref_= param/pck.adb":18 687 {*memory_blockage} (nil)) (note 35 34 2 2 NOTE_INSN_PROLOGUE_END) (insn 2 35 3 2 (set (mem/f/c:DI (plus:DI (reg/f:DI 6 bp) (const_int -8 [0xfffffffffffffff8])) [5 d+0 S8 A64]) (reg:DI 5 di [ d ])) "/home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/ref_= param/pck.adb":18 81 {*movdi_internal} (nil)) (note 3 2 6 2 NOTE_INSN_FUNCTION_BEG) ... and the third insn is in the twilight zone between prologue end and function begin, and depending on your definition of prologue, can be still considered part of the prologue. Note that due to compiling at -O0, there's no .debug_loc contribution, so t= he DW_AT_location expression for the function parameter 'D' is consider only v= alid after the prologue, and in this sense the third insn is certainly part of t= he prologue: ... (gdb) si pck.call_me (d=3D...) at pck.adb:18 18 procedure Call_Me (D : in out Data) is (gdb) p d $1 =3D (null) (gdb) si 0x0000000000401f93 18 procedure Call_Me (D : in out Data) is (gdb) p d $2 =3D (null) (gdb) si 0x0000000000401f96 18 procedure Call_Me (D : in out Data) is (gdb) p d $3 =3D (null) (gdb) si 20 if D.One > D.Two then (gdb) p d $4 =3D (one =3D> 1, two =3D> 2, three =3D> 3, four =3D> 4, five =3D> 5, six= =3D> 6) (gdb)=20 ... So, say we start to trust the dwarf line table (to be in a certain format t= hat allows us to determine where the prologue ends). Let's do that using "maint set skip-prologue line" (https://sourceware.org/pipermail/gdb-patches/2022-August/191343.html): ... clean_restart gdb_test_no_output "maint set skip-prologue line" gdb_load ${binfile} ... Now we have the incorrect: ... (gdb) break call_me^M Breakpoint 1 at 0x401f92: file /home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/ref_p= aram/pck.adb, line 18.^M ... The line table as decoded by readelf is: ... File name Line number Starting address View Stmt pck.adb 18 0x401f92 x pck.adb 18 0x401f92 1 x pck.adb 20 0x401f9a x pck.adb 21 0x401fab x pck.adb 23 0x401fb9 x pck.adb - 0x401fbd ... and the summary of that by gdb is: ... INDEX LINE ADDRESS IS-STMT PROLOGUE-END=20 0 18 0x0000000000401f92 Y=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 1 18 0x0000000000401f92 Y=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 2 20 0x0000000000401f9a Y=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 3 21 0x0000000000401fab Y=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 4 23 0x0000000000401fb9 Y=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 5 END 0x0000000000401fbd Y=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 ... This is with gcc 7.5.0. With gcc 12.2.1, I get a line table without the en= try at index 1, and things do work as expected. My hunch at this point is that this is due to gcc commit c029fcb5680 ("Reset force_source_line in final.c"), which is first present in release 11.1.0. --=20 You are receiving this mail because: You are on the CC list for the bug.=