Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Turn value_field into a method
Date: Fri, 6 Feb 2026 13:55:27 -0500	[thread overview]
Message-ID: <92fa2fb3-f7a2-4bf7-ba6b-9f5fc288ba35@simark.ca> (raw)
In-Reply-To: <20260206184023.1848421-1-tom@tromey.com>



On 2026-02-06 13:40, Tom Tromey wrote:
> diff --git a/gdb/value.h b/gdb/value.h
> index 1ef3acd6054..201db773a84 100644
> --- a/gdb/value.h
> +++ b/gdb/value.h
> @@ -626,6 +626,14 @@ struct value
>    struct value *primitive_field (LONGEST offset, int fieldno,
>  				 struct type *arg_type);
>  
> +  /* Given that this value is of a struct or union type, extract and
> +     return the value of one of its (non-static) fields.  FIELDNO says
> +     which field.  */

For future work: that comment makes me think it would be nice to have an
assert (probably in value::primitive_field) to check that the type is
indeed a struct or union.  If calling with a non-struct/non-union type,
this assert in type::field would probably trigger:

  gdb_assert (idx >= 0 && idx < num_fields ());

But it would be nice to check the precondition in primitive_field too,
it would be clearer.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

      reply	other threads:[~2026-02-06 18:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06 18:40 Tom Tromey
2026-02-06 18:55 ` Simon Marchi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92fa2fb3-f7a2-4bf7-ba6b-9f5fc288ba35@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox