public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/111740] New: Incorrect DWARF expression generated at specific live range
@ 2023-10-09 15:09 king.chung at manchester dot ac.uk
  0 siblings, 0 replies; only message in thread
From: king.chung at manchester dot ac.uk @ 2023-10-09 15:09 UTC (permalink / raw)
  To: gcc-bugs

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`

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-09 15:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-09 15:09 [Bug debug/111740] New: Incorrect DWARF expression generated at specific live range king.chung at manchester dot ac.uk

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).