Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Kamil Rytarowski <n54@gmx.com>, gdb-patches@sourceware.org
Cc: tom@tromey.com
Subject: Re: [PATCH v3] Add support for "info auxv" on NetBSD
Date: Sun, 29 Mar 2020 18:10:19 -0400	[thread overview]
Message-ID: <f6515121-96d6-6495-74a9-48991620fa5e@simark.ca> (raw)
In-Reply-To: <20200320172739.26705-1-n54@gmx.com>

On 2020-03-20 1:27 p.m., Kamil Rytarowski wrote:
> @@ -47,3 +48,40 @@ nbsd_pc_in_sigtramp (CORE_ADDR pc, const char *func_name)
>    return (func_name != NULL
>  	  && startswith (func_name, "__sigtramp"));
>  }
> +
> +/* NetBSD-specific parser for AUXV data with. NetBSD follows the ELF
> +   specification, contrary to some other ELF Operating Systems.  */
> +
> +static int
> +nbsd_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
> +		 gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
> +{
> +  struct type *int_type = builtin_type (gdbarch)->builtin_int;
> +  struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
> +  const int sizeof_auxv_type = TYPE_LENGTH (int_type);
> +  const int sizeof_auxv_val = TYPE_LENGTH (ptr_type);
> +  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> +  gdb_byte *ptr = *readptr;
> +
> +  if (endptr == ptr)
> +    return 0;
> +
> +  if (endptr - ptr < 2 * sizeof_auxv_val)
> +    return -1;
> +
> +  *typep = extract_unsigned_integer (ptr, sizeof_auxv_type, byte_order);
> +  ptr += sizeof_auxv_val;	/* Alignment.  */
> +  *valp = extract_unsigned_integer (ptr, sizeof_auxv_val, byte_order);
> +  ptr += sizeof_auxv_val;

From this code, I understand that on AMD64/NetBSD, an auxv entry looks like
(each character is a byte):

T T T T P P P P V V V V V V V V

Where T is the type value, P is padding and V is value.  Is that right?

> +
> +  *readptr = ptr;
> +  return 1;
> +}

Instead of defining this function that is very similar to default_auxv_parse, I would
strongly suggest making a parametrized version of default_auxv_parse (and make
default_auxv_parse use it).

Simon



      parent reply	other threads:[~2020-03-29 22:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-14 18:22 [PATCH] Correct decoding AUXV " Kamil Rytarowski
2020-03-16 13:25 ` Tom Tromey
2020-03-16 18:17   ` Kamil Rytarowski
2020-03-16 18:17 ` [PATCH v2] Add support for "info auxv" " Kamil Rytarowski
2020-03-19 13:11   ` Kamil Rytarowski
2020-03-20 15:43   ` Tom Tromey
2020-03-20 17:27     ` Kamil Rytarowski
2020-03-20 17:27   ` [PATCH v3] " Kamil Rytarowski
2020-03-26 23:26     ` Kamil Rytarowski
2020-03-27 16:31       ` John Baldwin
2020-03-27 17:04         ` Kamil Rytarowski
2020-03-27 19:22           ` John Baldwin
2020-03-29 20:35             ` Kamil Rytarowski
2020-03-29 22:10     ` 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=f6515121-96d6-6495-74a9-48991620fa5e@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=n54@gmx.com \
    --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