[PING][PATCH] Update auxv cache when inferior pid is 0 (no inferior)

Luis Machado luis.machado@arm.com
Mon Sep 12 12:48:04 GMT 2022


On 8/5/22 16:46, Luis Machado via Gdb-patches wrote:
> While adding support for MTE corefiles and running the MTE corefile tests,
> I noticed a strange situation where loading the symbol file + core file
> through the command line has a different behavior compared to firing up
> GDB, loading the symbol file with the "file" command and then loading the
> core file with the "core" command.
> 
> I tracked this down to gdb/auxv.c:get_auxv_inferior_data returning empty
> auxv data for pid 0, which gets cached. This is triggered by attempting to
> read auxv data for the exec target.
> 
> In the early stages of reading the core file, we're still using inferior pid
> 0, so when we attempt to read auxv to determine corefile features, we get the
> cached empty data vector again. This breaks core_gdbarch setup.
> 
> The fix, suggested by John Baldwin, prevents caching auxv data for pid 0.
> ---
>   gdb/auxv.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/auxv.c b/gdb/auxv.c
> index 6154988f6dd..33a829a7573 100644
> --- a/gdb/auxv.c
> +++ b/gdb/auxv.c
> @@ -361,7 +361,7 @@ get_auxv_inferior_data (struct target_ops *ops)
>     struct inferior *inf = current_inferior ();
>   
>     info = auxv_inferior_data.get (inf);
> -  if (info == NULL)
> +  if (info == NULL || inf->pid == 0)
>       {
>         info = auxv_inferior_data.emplace (inf);
>         info->data = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL);



More information about the Gdb-patches mailing list