Skip to content

Commit 1628e02

Browse files
khueytromey
authored andcommitted
gdb: Support DW_OP_constx (the standardized version of DW_OP_GNU_const_index).
Approved-By: Tom Tromey <tom@tromey.com>
1 parent ef54c7a commit 1628e02

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

gdb/dwarf2/expr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,8 +1593,9 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
15931593
uoffset)));
15941594
result_val = value_from_ulongest (address_type, result);
15951595
break;
1596+
case DW_OP_constx:
15961597
case DW_OP_GNU_const_index:
1597-
ensure_have_per_cu (this->m_per_cu, "DW_OP_GNU_const_index");
1598+
ensure_have_per_cu (this->m_per_cu, "DW_OP_constx");
15981599

15991600
op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
16001601
result = (ULONGEST) dwarf2_read_addr_index (this->m_per_cu,

gdb/dwarf2/loc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,7 @@ dwarf2_get_symbol_read_needs (gdb::array_view<const gdb_byte> expr,
19671967
case DW_OP_GNU_reinterpret:
19681968
case DW_OP_addrx:
19691969
case DW_OP_GNU_addr_index:
1970+
case DW_OP_constx:
19701971
case DW_OP_GNU_const_index:
19711972
case DW_OP_constu:
19721973
case DW_OP_plus_uconst:
@@ -3265,10 +3266,13 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream,
32653266
/* With -gsplit-dwarf a TLS variable can also look like this:
32663267
DW_AT_location : 3 byte block: fc 4 e0
32673268
(DW_OP_GNU_const_index: 4;
3268-
DW_OP_GNU_push_tls_address) */
3269+
DW_OP_GNU_push_tls_address) |
3270+
3 byte block a2 4 e0
3271+
(DW_OP_constx: 4;
3272+
DW_OP_form_tls_address) */
32693273
else if (data + 3 <= end
32703274
&& data + 1 + (leb128_size = skip_leb128 (data + 1, end)) < end
3271-
&& data[0] == DW_OP_GNU_const_index
3275+
&& (data[0] == DW_OP_constx || data[0] == DW_OP_GNU_const_index)
32723276
&& leb128_size > 0
32733277
&& (data[1 + leb128_size] == DW_OP_GNU_push_tls_address
32743278
|| data[1 + leb128_size] == DW_OP_form_tls_address)
@@ -3675,6 +3679,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
36753679
gdb_printf (stream, " 0x%s", phex_nz (ul, addr_size));
36763680
break;
36773681

3682+
case DW_OP_constx:
36783683
case DW_OP_GNU_const_index:
36793684
data = safe_read_uleb128 (data, end, &ul);
36803685
ul = (uint64_t) dwarf2_read_addr_index (per_cu, per_objfile, ul);

gdb/dwarf2/read.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21142,6 +21142,7 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu,
2114221142

2114321143
case DW_OP_addrx:
2114421144
case DW_OP_GNU_addr_index:
21145+
case DW_OP_constx:
2114521146
case DW_OP_GNU_const_index:
2114621147
stack[++stacki]
2114721148
= (CORE_ADDR) read_addr_index_from_leb128 (cu, &data[i],

0 commit comments

Comments
 (0)