This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
DW_AT_count is the same as DW_AT_upper_bound?
- From: Rouslan Korneychuk <rouslank at msn dot com>
- To: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Fri, 5 Jul 2013 14:41:02 -0400
- Subject: DW_AT_count is the same as DW_AT_upper_bound?
I'm working on a program which produces DWARF 4 debug information and
uses GDB's JIT interface. I have an array with a dynamic size with the
following description (taken from objdump):
...
<2><4e>: Abbrev Number: 7 (DW_TAG_variable)
<4f> DW_AT_type : <0x1d>
<50> DW_AT_name : (indirect string, offset: 0x2c): stack_len
<54> DW_AT_location : 0x0 (location list)
<2><58>: Abbrev Number: 8 (DW_TAG_array_type)
<59> DW_AT_type : <0x29>
<3><5a>: Abbrev Number: 9 (DW_TAG_subrange_type)
<5b> DW_AT_type : <0x1d>
<5c> DW_AT_lower_bound : 0
<5d> DW_AT_count : <0x4e>
<3><5e>: Abbrev Number: 0
<2><5f>: Abbrev Number: 10 (DW_TAG_variable)
<60> DW_AT_type : <0x58>
<61> DW_AT_name : (indirect string, offset: 0x36): stack
<65> DW_AT_location : 2 byte block: 91 18 (DW_OP_fbreg: 24)
<68> DW_AT_start_scope : 152
...
The array "stack" uses DW_AT_count which is a reference to the variable
"stack_len". I expected the length of the array to be equal to the value
of "stack_len", but when I use GDB to display these two variables (using
the command "display"), "stack" is always shown with 1 more element than
I expected. e.g.:
...
0x00007ffff7ff31f6 in $module$ (f=0x87f0a0 <small_ints+384>,
throwflag=-240094128)
3: stack = {0xc33aa0, 0xc33aa0}
2: stack_len = 1
1: x/i $pc
=> 0x7ffff7ff31f6 <$module$+422>: mov %rax,0x48(%rsp)
(gdb) nexti
0x00007ffff7ff31fb in $module$ (f=0x87f0a0 <small_ints+384>,
throwflag=-240094128)
3: stack = {0xc33aa0, 0xc33aa0, 0x7fffffffce00}
2: stack_len = 2
1: x/i $pc
=> 0x7ffff7ff31fb <$module$+427>: movabs $0x1,%rsi
(gdb)
I'm using DW_AT_count instead of DW_AT_upper_bound so that "stack" can
be empty (have 0 elements), but these two attributes appear to be
treated the same. Is this a bug or am I misunderstanding something? I'm
using GDB version 7.5.1.