public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "king.chung at manchester dot ac.uk" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-111740-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111740

            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=56080&action=edit
Source code

The DWARF expression between the range 0x10984 to 0x1098c is not correct. 

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 <End of list>

The following log of running the binary with GDB:

+b *0x10984
Breakpoint 1 at 0x10984: file bfs.c, line 62.

+continue 
Continuing.

Breakpoint 1, 0x0000000000010984 in bfs (nodes=nodes@entry=0x9af00,
edges=edges@entry=0x9bf00, starting_node=<optimized out>,
level=level@entry=0xa3f08 "\177\177\177\177\177\177\001", '\177' <repeats 31
times>, level_counts=level_counts@entry=0xa4008) 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 = 1 '\001'

By purely using the DWARF expression, the correct value of the variable could
not be found manually. 
Interestingly, GDB is still able to compute a value despite the DWARF
expression is not correct. 

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=rv64imafd -g -fno-reorder-blocks -o bfs bfs.c local_support.c support.c
harness.c`

                 reply	other threads:[~2023-10-09 15:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111740-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).