From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DB7A33858C78; Mon, 9 Oct 2023 15:09:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB7A33858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696864183; bh=TYxvBH3CYU5wcrD8+ICQkdd2LTT1GT/krsVwaEV8Llk=; h=From:To:Subject:Date:From; b=ZO3KpZybK768D52/VEZbJYy1zCgY7jjr3k9kDlBnkZfRetBGlEdLNDCh/NUX5Y+yz C1thqaGt6aElDYPLgHwOiFPMuxk3pOmABxgTK/rwV2KggabxmNc52wysDwcYPhU9oq B+uRmdKNZMAeBRw/KtrJedAN7WMu/86Bi+Ug+K9g= From: "king.chung at manchester dot ac.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/111740] New: Incorrect DWARF expression generated at specific live range Date: Mon, 09 Oct 2023 15:09:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: king.chung at manchester dot ac.uk X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111740 Bug ID: 111740 Summary: Incorrect DWARF expression generated at specific live range Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: king.chung at manchester dot ac.uk Target Milestone: --- Created attachment 56080 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D56080&action=3Dedit Source code The DWARF expression between the range 0x10984 to 0x1098c is not correct.=20 The following is the variable I am trying to test: <5><76c>: Abbrev Number: 3 (DW_TAG_variable) <76d> DW_AT_name : (indirect string, offset: 0x436): tmp_level <771> DW_AT_decl_file : 1 <771> DW_AT_decl_line : 60 <772> DW_AT_decl_column : 17 <773> DW_AT_type : <0x641> <777> DW_AT_location : 0x1b4 (location list) 000001b4 0000000000010974 0000000000010980 (DW_OP_reg12 (a2)) 000001c7 0000000000010980 0000000000010984 (DW_OP_breg17 (a7): 0) 000001db 0000000000010984 000000000001098c (DW_OP_breg13 (a3): 0; DW_OP_breg16 (a6): 0; DW_OP_plus) 000001f2 The following log of running the binary with GDB: +b *0x10984 Breakpoint 1 at 0x10984: file bfs.c, line 62. +continue=20 Continuing. Breakpoint 1, 0x0000000000010984 in bfs (nodes=3Dnodes@entry=3D0x9af00, edges=3Dedges@entry=3D0x9bf00, starting_node=3D, level=3Dlevel@entry=3D0xa3f08 "\177\177\177\177\177\177\001", '\177' , level_counts=3Dlevel_counts@entry=3D0xa4008) at bfs.c:62 +si +info registers a3 a6 a3 0xa3f08 671496 a6 0x6 6 +x 0xa3f08 0xa3f08: 0x7f7f7f7f +x 0x6 0x6: Cannot access memory at address 0x6 +print tmp_level $1 =3D 1 '\001' By purely using the DWARF expression, the correct value of the variable cou= ld not be found manually.=20 Interestingly, GDB is still able to compute a value despite the DWARF expression is not correct.=20 This again uses the same file and binary from bug111680 and bug111716 with = the same command. `riscv64-unknown-linux-gnu-gcc -static -O3 -Wall -Wno-unused-label -march=3Drv64imafd -g -fno-reorder-blocks -o bfs bfs.c local_support.c supp= ort.c harness.c`=