public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30319] New: GDB shows "Incompatible DWARF Stack" when it's actually compatible
@ 2023-04-06  6:13 hluaw at connect dot ust.hk
  2023-04-13 14:39 ` [Bug gdb/30319] " tromey at sourceware dot org
  0 siblings, 1 reply; 2+ messages in thread
From: hluaw at connect dot ust.hk @ 2023-04-06  6:13 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30319

            Bug ID: 30319
           Summary: GDB shows "Incompatible DWARF Stack" when it's
                    actually compatible
           Product: gdb
           Version: 13.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: hluaw at connect dot ust.hk
  Target Milestone: ---

Given the following code:
#include "stdint.h"
int a, b = 9067;
volatile uint16_t *c = (volatile uint16_t*)&b;
int *d = &a;
int func_1() {
  uint16_t e[7][2][8];
  uint32_t f = 37455;
  int32_t l_146;
  a = 0;
  l_146 = *c * f;
  *d = e[3][1][5];
  return l_146;
}
int main() { func_1(); return 0; }

Compiled with clang 15.0.7 and -O1 -g.

For l_146, the following DWARF is generated.

(gdb) info addr l_146
Symbol "l_146" is multi-location:
  Range 0x555555554674-0x55555555467b: a complex DWARF expression:
     0: DW_OP_breg0 0 [$rax]
     2: DW_OP_constu 65535
     6: DW_OP_and
     7: DW_OP_convert<DW_ATE_unsigned_16 [0x27]>
    12: DW_OP_convert<DW_ATE_unsigned_32 [0x2b]>
    17: DW_OP_constu 37455
    21: DW_OP_mul
    22: DW_OP_stack_value
(gdb) p l_146
Incompatible types on DWARF stack

GDB complaining that this DWARF expression is invalid since on DW_OP_mul, but
this DWARF is in fact valid since it performs a explicit conversion, and
DW_OP_constu 37455 is automatically unsigned.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug gdb/30319] GDB shows "Incompatible DWARF Stack" when it's actually compatible
  2023-04-06  6:13 [Bug gdb/30319] New: GDB shows "Incompatible DWARF Stack" when it's actually compatible hluaw at connect dot ust.hk
@ 2023-04-13 14:39 ` tromey at sourceware dot org
  0 siblings, 0 replies; 2+ messages in thread
From: tromey at sourceware dot org @ 2023-04-13 14:39 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30319

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
I think this is invalid DWARF.

The default type of a stack element is the so-called "generic type".
See DWARF 5 section 2.5.1.

Arithmetic operations are only defined when the types match;
either both operations must have the same base type, or be
of the generic type.  See DWARF 5 section 2.5.1.4:

  Operands of an
  operation with two operands must have the same type, either the same base
type
  or the generic type.

DW_OP_constu is not actually automatically unsigned.
Instead it pushes a value of the generic type.  This
is documented in DWARF 5 section 2.5.1.1.

So, I think this is a compiler bug.
I'm going to close this PR; if you think this is in error,
feel free to comment with an explanation and I'll be
happy to reopen it.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-13 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06  6:13 [Bug gdb/30319] New: GDB shows "Incompatible DWARF Stack" when it's actually compatible hluaw at connect dot ust.hk
2023-04-13 14:39 ` [Bug gdb/30319] " tromey at sourceware dot org

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