From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mbkQIKP8Amr1WjMAWB0awg (envelope-from ) for ; Tue, 12 May 2026 06:10:43 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GB4CSPMf; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7D1531E0C3; Tue, 12 May 2026 06:10:43 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3BBF41E093 for ; Tue, 12 May 2026 06:10:42 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D33D44BAE7EE for ; Tue, 12 May 2026 10:10:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D33D44BAE7EE Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GB4CSPMf Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 482714BAD16F for ; Tue, 12 May 2026 10:07:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 482714BAD16F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 482714BAD16F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778580465; cv=none; b=st3UkFojNMI40nL+MyD82Gk8LhjuX10fC41IoCOJFRHhAFEzTJCwWtIEyWJ7wafvMjrCU0jpSU6VO96+yH+hRfkv5+6S8RAn92GF3ZVYLiUm85Zr8n6SaPkm/uzcmSQso3sk7+Syyq0J9hoHI2wrT615HM4ityrATufhPS39Azw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778580465; c=relaxed/simple; bh=uf9qhaLvyA+zAOX8e3hjHq+rV3bSzXaW5KZCpjHN5P4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=jZ+v0dUXKul5UliEcABYdC7bFKMOidNf21Jo6nkGZtQo/De37RKNbrDHL9uV/viSAI7FojY895roWeZlF2TWhW/4J27f+O7uU8OJ4pK9RYWsnTAZOU2qV4nK4n3eGgrDOkg/tPvvw7gzh2IIOX8zWMtgcKBQtjVOUJ54e2nP9To= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GB4CSPMf DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 482714BAD16F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778580464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GFMccXDTU5kNirp7gEtLvdqvo7OjeRhDFNhwycLHNT4=; b=GB4CSPMf5hJjK3qTMvDySfCdLgmgH80vha4BMBDSDXFjz6LUE9wWU7XriUIeU+8rv7xnt2 j0APtKQ0CuQ/q9kWa9uQGbWaVxUsjjxobd5BbQ08oZEJa0ow6xkJdwULn46tzUE/+FPkah 4YX0olKbN+vE5QSiG1PVVEIB1v/sUzo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-Z5ApuRygN-KrJXeDBH-4og-1; Tue, 12 May 2026 06:07:43 -0400 X-MC-Unique: Z5ApuRygN-KrJXeDBH-4og-1 X-Mimecast-MFC-AGG-ID: Z5ApuRygN-KrJXeDBH-4og_1778580463 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-44a52d5e572so3285123f8f.3 for ; Tue, 12 May 2026 03:07:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778580462; x=1779185262; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=GFMccXDTU5kNirp7gEtLvdqvo7OjeRhDFNhwycLHNT4=; b=hCPVHaKZSsV92aZWS5n9MU2Yb3ZDicqqV2V3OTOmTTqBArhzD0h62Ibgk5+AK84Xb3 2XxYKjF5wlVaQ115yiJ7TsBzHA/vzF4ibQkWE3a9bkBr6MYWYVaR4H9X3QZLTFMX3lbH L5aaAheU8pK0v1K9/JbL4QwLY3edhIwoa3LVuuBd+mpg+0LIh6KuL4/40+RBbUGBH4qz UXOlC98GQZSeid0uBwGF9DFNOa765MoQMcx32D4PJ3grd0Chqv3Lr+zQDR9yOuCkpcOf 4WBFetVa03wkpdebungyb8om+9HnoZ3cqZhj8FmItGxboKuESRDEAfK9DK0WTOV8scJa B7eA== X-Gm-Message-State: AOJu0YzYYAccMmahLVMCK5liNnCCqmOIXibckdZvu41bnctdT+tFWq99 3H3rnvUhMTw27BQARYNsvN/CzxlepUJiEeJomIf6vvCC/CwO0kK2rdD2AFlAKMLEV8oRaShwRy2 t8PJQj0muFTeyYs0dpy0JIfL++N6evIeRUmhTDjEFWnggQ6tePBIgGgQMfSOXQX4uVGmWuho7Pv /LF8x5XfvH0W7L9lg6bpOhkDST6ybytXXvSVCF45kSRJCQ27Y= X-Gm-Gg: Acq92OFyEFyNXzG2rq7QG93DYh7o0VH6oQmTzh5SX5WG6ISKxDnl9uGdKPn5wXQN/iQ NK+67BwBeP/YykmtFxpVIK1AQfs7gZ3+B7xIKKpZkiNVu6Vj+fFzbWCiBGkjVRcaMHDJVYD+rMX oz2Jhfoo1ldzkdbz09RvqezD6/2cEHgjq6uJuKLTPX/pIgL5mmXOvF62LpP5k//gUftaGYtr4Sa 1+/pPoUHQ4dpP8TMmTKTJkeBWmVZw3QuV9FTCGbOqNJqm864pcQVS9+nY8LBCDUrKB5ysWkLD9C ceXiBRZy4j0v6np75ttvVdtb+QcFfeTuskcxk8hH3xf3lWmSfN9k3wonNBf1WK0nUQOXi+CooVP 2exfI5f6NSLgnR0fo X-Received: by 2002:a05:600c:5304:b0:48e:51f8:eb38 with SMTP id 5b1f17b1804b1-48e51f8eb70mr458659885e9.27.1778580462048; Tue, 12 May 2026 03:07:42 -0700 (PDT) X-Received: by 2002:a05:600c:5304:b0:48e:51f8:eb38 with SMTP id 5b1f17b1804b1-48e51f8eb70mr458659315e9.27.1778580461469; Tue, 12 May 2026 03:07:41 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e9067811dsm64030535e9.9.2026.05.12.03.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 03:07:40 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 5/6] gdb: remove embedded_offset argument that is always 0 Date: Tue, 12 May 2026 11:07:26 +0100 Message-Id: <1281d9563073d028c50690fa26bbe165b9c7beff.1778579473.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kKFuK2tUmygpwEp0wVaDnkHsHkpDSXlSjFN104IXi6I_1778580463 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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~public-inbox=simark.ca@sourceware.org For the background and motivation for this patch you should read the previous commit. The goal of this commit started as similar to the previous one; rename the embedded_offset argument to generic_val_print_ref. To do this I started tracing back which values are passed into this function so I could make sure the new argument name matched the usage. But it turns out that the only value that is ever passed to this function is zero. I believe that, like the last commit, the embedded_offset is actually representing the offset of a field within a value. However, in all of the use cases, the "field" being accessed is the entire value, hence why we always pass 0, we are asking about the whole value starting from the very beginning. Given this, I couldn't bring myself to rename the argument. Let's just remove it. It turns out that there's a bunch of functions in valprint.c that take an argument called embedded_offset, which are always zero. This commit removes the argument, and updates the code to assume zero. There should be no user visible changes after this commit. --- gdb/valprint.c | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/gdb/valprint.c b/gdb/valprint.c index ca4a064a7c5..482069fbbaa 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -59,7 +59,6 @@ static void set_output_radix_1 (int, unsigned); static void val_print_type_code_flags (struct type *type, struct value *original_value, - int embedded_offset, struct ui_file *stream); /* Start print_max at this value. */ @@ -561,14 +560,13 @@ generic_value_print_ptr (struct value *val, struct ui_file *stream, static void print_ref_address (struct type *type, const gdb_byte *address_buffer, - int embedded_offset, struct ui_file *stream) + struct ui_file *stream) { struct gdbarch *gdbarch = type->arch (); if (address_buffer != NULL) { - CORE_ADDR address - = extract_typed_address (address_buffer + embedded_offset, type); + CORE_ADDR address = extract_typed_address (address_buffer, type); gdb_printf (stream, "@"); fputs_styled (paddress (gdbarch, address), address_style.style (), @@ -598,15 +596,15 @@ get_value_addr_contents (struct value *deref_val) static void generic_val_print_ref (struct type *type, - int embedded_offset, struct ui_file *stream, int recurse, + struct ui_file *stream, int recurse, struct value *original_value, const struct value_print_options *options) { struct type *elttype = check_typedef (type->target_type ()); struct value *deref_val = NULL; const bool value_is_synthetic - = original_value->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * type->length ()); + = original_value->bits_synthetic_pointer (0, (TARGET_CHAR_BIT + * type->length ())); const bool must_coerce_ref = ((options->addressprint && value_is_synthetic) || options->deref_ref); const bool type_is_defined = elttype->code () != TYPE_CODE_UNDEF; @@ -616,14 +614,9 @@ generic_val_print_ref (struct type *type, { deref_val = coerce_ref_if_computed (original_value); - if (deref_val != NULL) - { - /* More complicated computed references are not supported. */ - gdb_assert (embedded_offset == 0); - } - else + if (deref_val == nullptr) deref_val = value_at (type->target_type (), - unpack_pointer (type, valaddr + embedded_offset)); + unpack_pointer (type, valaddr)); } /* Else, original_value isn't a synthetic reference or we don't have to print the reference's contents. @@ -643,7 +636,7 @@ generic_val_print_ref (struct type *type, ? get_value_addr_contents (deref_val) : valaddr); - print_ref_address (type, address, embedded_offset, stream); + print_ref_address (type, address, stream); if (options->deref_ref) gdb_puts (": ", stream); @@ -747,20 +740,15 @@ generic_val_print_enum_1 (struct type *type, LONGEST val, /* generic_val_print helper for TYPE_CODE_ENUM. */ static void -generic_val_print_enum (struct type *type, - int embedded_offset, struct ui_file *stream, +generic_val_print_enum (struct type *type, struct ui_file *stream, struct value *original_value, const struct value_print_options *options) { - LONGEST val; - struct gdbarch *gdbarch = type->arch (); - int unit_size = gdbarch_addressable_memory_unit_size (gdbarch); - gdb_assert (!options->format); const gdb_byte *valaddr = original_value->contents_for_printing ().data (); - val = unpack_long (type, valaddr + embedded_offset * unit_size); + LONGEST val = unpack_long (type, valaddr); generic_val_print_enum_1 (type, val, stream); } @@ -768,8 +756,7 @@ generic_val_print_enum (struct type *type, /* generic_val_print helper for TYPE_CODE_FUNC and TYPE_CODE_METHOD. */ static void -generic_val_print_func (struct type *type, - int embedded_offset, CORE_ADDR address, +generic_val_print_func (struct type *type, CORE_ADDR address, struct ui_file *stream, struct value *original_value, const struct value_print_options *options) @@ -980,7 +967,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, case TYPE_CODE_REF: case TYPE_CODE_RVALUE_REF: - generic_val_print_ref (type, 0, stream, recurse, + generic_val_print_ref (type, stream, recurse, val, options); break; @@ -988,14 +975,14 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, if (options->format) value_print_scalar_formatted (val, options, 0, stream); else - generic_val_print_enum (type, 0, stream, val, options); + generic_val_print_enum (type, stream, val, options); break; case TYPE_CODE_FLAGS: if (options->format) value_print_scalar_formatted (val, options, 0, stream); else - val_print_type_code_flags (type, val, 0, stream); + val_print_type_code_flags (type, val, stream); break; case TYPE_CODE_FUNC: @@ -1003,7 +990,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, if (options->format) value_print_scalar_formatted (val, options, 0, stream); else - generic_val_print_func (type, 0, val->address (), stream, + generic_val_print_func (type, val->address (), stream, val, options); break; @@ -1257,10 +1244,9 @@ debug_val (struct value *val) static void val_print_type_code_flags (struct type *type, struct value *original_value, - int embedded_offset, struct ui_file *stream) + struct ui_file *stream) { - const gdb_byte *valaddr = (original_value->contents_for_printing ().data () - + embedded_offset); + const gdb_byte *valaddr = (original_value->contents_for_printing ().data ()); ULONGEST val = unpack_long (type, valaddr); int field, nfields = type->num_fields (); struct gdbarch *gdbarch = type->arch (); @@ -2626,7 +2612,7 @@ test_print_flags (gdbarch *arch) store_unsigned_integer (contents, 4, gdbarch_byte_order (arch), 0xaa); string_file out; - val_print_type_code_flags (flags_type, val, 0, &out); + val_print_type_code_flags (flags_type, val, &out); SELF_CHECK (out.string () == "[ A=2 B=1 C=5 ]"); } -- 2.25.4