[PATCH v3] Add support for "info auxv" on NetBSD

Simon Marchi simark@simark.ca
Sun Mar 29 22:10:19 GMT 2020


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



More information about the Gdb-patches mailing list