From patchwork Sat Sep 7 15:20:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Huey X-Patchwork-Id: 97302 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 200F83858430 for ; Sat, 7 Sep 2024 15:20:31 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id D4EEB3858D35 for ; Sat, 7 Sep 2024 15:20:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D4EEB3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kylehuey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kylehuey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D4EEB3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725722411; cv=none; b=kIru7J0FrPaIi9GwCdvjx4vshQl9uYGGdGbVhafYMnZA/TnognIIyFfz3MMP91lghWkHFRyAkcgPiY+/t3CKnjURoEGSFPmBu1wo26SbAqsudTkYoXK7pAkddKpF4mroIaHDDzttq/zXrpNpBqT6jJQvdJn18TitdBWF51zF+q4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725722411; c=relaxed/simple; bh=U1vf2DW/cV/FmAr9hiQkglZTBn7JXWHPd5ZSjepVYe8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=XG2fWYg5G2QW/xB+FeqY7KoEmuDqQ/EauHVxYoSM5LSA7FjzBpYer6xwQRf9NFM+UsByhfnydStMkO8Sh8Dd7dtqLRcBXVFsFHSUbA45qNr+/luDNF6rVFgAJfa7bMHZlunVqKSmzYIzNUitSzgqDdyV8uttC6P6X/bUsUCxESY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-277c28fac92so2911561fac.3 for ; Sat, 07 Sep 2024 08:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1725722408; x=1726327208; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=M/Fgh3T+YXYQXDoPC6iun0mgr2SbAYh88lQQcZ5G+t0=; b=XXTD0fwG16qo/SC/jCE65wgfR6GXgk8IK81OYG24dFoFz5Uldk2HDZ/n++Zzd0wO02 YH/xiCymji/CmEMe8X0IHejY9/K5k2VGvzmLyD/8AJqqlQuToLx7TtL8l67GUdJ+smAN 06S9fVSie3+iRyYlmF88L1wMV9Nt39EaBJqEXnU0kXgj+dDFnyazEjcNIFs9DnoWe5sN vyBUWhO3lA+mT8Gy/Rc3PqxbO2WBe0TcXHU2W7lwTGiggQx/BgXYvOLxQ3ExosJS8RKB smD7io4dpSpMYnl2tDdb2D4CrtEG3Sb0s8pJ6HRjqbzys+BstVe69uoycju68HiHPyR6 qOKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725722408; x=1726327208; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=M/Fgh3T+YXYQXDoPC6iun0mgr2SbAYh88lQQcZ5G+t0=; b=bdUz3l19PqHfAhdm5wl1mkVid+It5QxfByDhcafTWqtlsFx+mV34JaigOJhmJ8uyal q1ISLgqXkk3hQURV4vCn4NvZe2NwVlwLJnDQp9eiUqgcABJb19qLmkSlSwP++z9z59/Z rijNjfDFU/ESVt9IMNlPwb5tAeFoqTazMSwUyExnNvbaKYxEe3X4fwRXS/u3FExfFuEf votuLkL9zxbK3mthT1h/divqQm+RGgzEz0XxzRdQeh1gEz0ZaQmNk3FPkJvQ4VK4uHfd zALBxY04xcNLL8ni3cULjf8Vik7KswKUQSl6MHsEhV5WDBQe7XXiplJ4bNZDTJW9sVFE icDw== X-Gm-Message-State: AOJu0YzKJb9+78V1aCnTCMXBKUIbWOxWbX6S1sCkk6DoTNE2qXPJWwgi juDkv/HmSIiCf4vyAtICKDJayZS81zfNtHzfdd62jPQZJVP8VD7PRFN0s41Ts4FhpG+G7E5hTlo = X-Google-Smtp-Source: AGHT+IF5tAmp89qkn9E/afCssDQn0VvB1VTo2fJ+0WYAlsvsgukrtwLC3615KdYquNAk/hvzUSPQLQ== X-Received: by 2002:a05:6870:392a:b0:278:1f2:a23f with SMTP id 586e51a60fabf-27b82e59c79mr7120877fac.13.1725722408105; Sat, 07 Sep 2024 08:20:08 -0700 (PDT) Received: from zhadum.home.kylehuey.com (c-71-202-124-49.hsd1.ca.comcast.net. [71.202.124.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58c167csm990910b3a.51.2024.09.07.08.20.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 08:20:07 -0700 (PDT) From: Kyle Huey X-Google-Original-From: Kyle Huey To: gdb-patches@sourceware.org Subject: [PATCH] gdb: Support DW_OP_constx (the standardized version of DW_OP_GNU_const_index). Date: Sat, 7 Sep 2024 08:20:05 -0700 Message-Id: <20240907152005.6608-1-khuey@kylehuey.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org --- gdb/dwarf2/expr.c | 3 ++- gdb/dwarf2/loc.c | 9 +++++++-- gdb/dwarf2/read.c | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index cb80dbf60b1..5ad17eaaaff 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1593,8 +1593,9 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, uoffset))); result_val = value_from_ulongest (address_type, result); break; + case DW_OP_constx: case DW_OP_GNU_const_index: - ensure_have_per_cu (this->m_per_cu, "DW_OP_GNU_const_index"); + ensure_have_per_cu (this->m_per_cu, "DW_OP_constx"); op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset); result = (ULONGEST) dwarf2_read_addr_index (this->m_per_cu, diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 3a47805ab3a..5d1a557cb98 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1967,6 +1967,7 @@ dwarf2_get_symbol_read_needs (gdb::array_view expr, case DW_OP_GNU_reinterpret: case DW_OP_addrx: case DW_OP_GNU_addr_index: + case DW_OP_constx: case DW_OP_GNU_const_index: case DW_OP_constu: case DW_OP_plus_uconst: @@ -3265,10 +3266,13 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, /* With -gsplit-dwarf a TLS variable can also look like this: DW_AT_location : 3 byte block: fc 4 e0 (DW_OP_GNU_const_index: 4; - DW_OP_GNU_push_tls_address) */ + DW_OP_GNU_push_tls_address) | + 3 byte block a2 4 e0 + (DW_OP_constx: 4; + DW_OP_form_tls_address) */ else if (data + 3 <= end && data + 1 + (leb128_size = skip_leb128 (data + 1, end)) < end - && data[0] == DW_OP_GNU_const_index + && (data[0] == DW_OP_constx || data[0] == DW_OP_GNU_const_index) && leb128_size > 0 && (data[1 + leb128_size] == DW_OP_GNU_push_tls_address || data[1 + leb128_size] == DW_OP_form_tls_address) @@ -3675,6 +3679,7 @@ disassemble_dwarf_expression (struct ui_file *stream, gdb_printf (stream, " 0x%s", phex_nz (ul, addr_size)); break; + case DW_OP_constx: case DW_OP_GNU_const_index: data = safe_read_uleb128 (data, end, &ul); ul = (uint64_t) dwarf2_read_addr_index (per_cu, per_objfile, ul); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 769ca91facc..e0dcf940402 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -21142,6 +21142,7 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu, case DW_OP_addrx: case DW_OP_GNU_addr_index: + case DW_OP_constx: case DW_OP_GNU_const_index: stack[++stacki] = (CORE_ADDR) read_addr_index_from_leb128 (cu, &data[i],