Bug 30345 - GDB shows "That operation is not available on integers of more than 8 bytes." when printing regular variables.
Summary: GDB shows "That operation is not available on integers of more than 8 bytes."...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 13.1
: P2 normal
Target Milestone: 14.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 26909
  Show dependency treegraph
 
Reported: 2023-04-13 12:07 UTC by LU Hongyi
Modified: 2023-04-13 17:10 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description LU Hongyi 2023-04-13 12:07:37 UTC
Given the following code:
#pragma pack(1)
struct {
  unsigned : 6;
  signed : 8;
  signed : 27;
  signed : 6;
  unsigned b : 14;
  signed : 4;
} c, d;
int d_1, e, f, k, aa, l, af, ag, ah, h, iab, i_5;
long m;

int main() {
  int l_212;
  int *r[42] = {&e, &l_212, &f, &e, &f, &f, &l_212, &e, &f, &l_212, &f};
  l_212 = (m = (d.b |= 0) | 0);
}

Compiled with Clang 15.0.7 with -O1 -g.

l_212 is then with the following DWARF information:
  Range 0x55555555461d-0x555555554628: a complex DWARF expression:
     0: DW_OP_breg0 0 [$rax]
     2: DW_OP_constu 4294967295
     8: DW_OP_and
     9: DW_OP_convert<DW_ATE_unsigned_72 [0x27]>
    14: DW_OP_convert<DW_ATE_unsigned_32 [0x2b]>
    19: DW_OP_stack_value
    [4-byte piece]
.

Break at 0x55555555461d where this DWARF expression takes effect:
(gdb) b *0x55555555461d
Breakpoint 1 at 0x55555555461d
(gdb) r
Starting program: /home/hluaw/debugger-bugs/unavail_op/a.out

Breakpoint 1, 0x000055555555461d in main () at r.c:16
16        l_212 = (m = (d.b |= 0) | 0);
(gdb) p l_212
That operation is not available on integers of more than 8 bytes.

To my understanding, this error message should only appear when using something like print ((int128_t)1) << 64

It seems not right to yield this error when evaluating a normal variable.
Comment 1 Tom Tromey 2023-04-13 12:21:52 UTC
This sequence:
     9: DW_OP_convert<DW_ATE_unsigned_72 [0x27]>
    14: DW_OP_convert<DW_ATE_unsigned_32 [0x2b]>

...probably is the problem, and is also somewhat pointless.
Arguably perhaps the GMP support should be extended into DWARF
expressions, but at the same time, doing it just to support
this kind of thing seems like a lot of work for little benefit.
Comment 2 LU Hongyi 2023-04-13 12:38:56 UTC
(In reply to Tom Tromey from comment #1)
> This sequence:
>      9: DW_OP_convert<DW_ATE_unsigned_72 [0x27]>
>     14: DW_OP_convert<DW_ATE_unsigned_32 [0x2b]>
> 
> ...probably is the problem, and is also somewhat pointless.
> Arguably perhaps the GMP support should be extended into DWARF
> expressions, but at the same time, doing it just to support
> this kind of thing seems like a lot of work for little benefit.

GDB seems to have a loose support for DW_OP_convert?

Another bug #30319 I found also relates to this operator, which reports Type Incompatible when it (actually?) compatible.
Comment 3 Tom Tromey 2023-04-13 14:42:57 UTC
(In reply to LU Hongyi from comment #2)

> GDB seems to have a loose support for DW_OP_convert?

It's more that gdb supports 64 bit types in DWARF expressions,
but nothing wider.  This is done primarily because, until
this bug report, nobody ever saw a wider type in a DWARF
expression.
 
> Another bug #30319 I found also relates to this operator, which reports Type
> Incompatible when it (actually?) compatible.

I've commented on that one now.
Comment 4 Tom Tromey 2023-04-13 14:50:29 UTC
Ah, I forgot that when implementing DW_OP_convert,
we converted the DWARF expression evaluator to be value-based.
With that and the work to make 128-bit values work, 
I think this may be fixed on git master.

I can't try it though as my clang emits different DWARF:

     0: DW_OP_breg0 0 [$rax]
     2: DW_OP_constu 4294967295
     8: DW_OP_and
     9: DW_OP_stack_value
    10: DW_OP_piece 4 (bytes)

Anyway this is probably a dup of bug# 30190.
Could you try your example with git master gdb?
Comment 5 LU Hongyi 2023-04-13 15:01:49 UTC
I tried master gdb, it works now.