From: John Baldwin <jhb@FreeBSD.org>
To: Luis Machado <luis.machado@arm.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Update auxv cache when there is no auxv cached data
Date: Mon, 25 Jul 2022 09:05:43 -0700 [thread overview]
Message-ID: <76097707-ed9e-1556-fac2-1992ab3cabae@FreeBSD.org> (raw)
In-Reply-To: <20220719144542.1478037-1-luis.machado@arm.com>
On 7/19/22 7:45 AM, 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 a valid
> info struct, but with no auxv data.
>
> We've been doing the auxv caching for a while now, but sometime between
> enabling auxv data caching and now, we turned the auxv data into an optional
> value.
The commit to use gdb::optional<> was this one in 2018:
commit 9018be22e022e6db2ba07c4e407c7244022bc69a
Author: Simon Marchi <simon.marchi@ericsson.com>
Date: Sat Apr 7 13:19:12 2018 -0400
Make target_read_alloc & al return vectors
This patch started by changing target_read_alloc_1 to return a
byte_vector, to avoid manual memory management (in target_read_alloc_1
and in the callers). To communicate failures to the callers, it
actually returns a gdb::optional<gdb::byte_vector>.
Adjusting target_read_stralloc was a bit more tricky, since it wants to
return a buffer of char, and not gdb_byte. Since you can't just cast a
gdb::byte_vector into a gdb::def_vector<char>, I made
target_read_alloc_1 templated, so both versions (that return vectors of
gdb_byte and char) are generated. Since target_read_stralloc now
returns a gdb::char_vector instead of a gdb::unique_xmalloc_ptr<char>, a
few callers need to be adjusted.
But looking at it's diff, it was always caching negative results even
before this change. This is the relevant hunk of that commit:
@@ -358,9 +356,8 @@ get_auxv_inferior_data (struct target_ops *ops)
info = (struct auxv_info *) inferior_data (inf, auxv_inferior_data);
if (info == NULL)
{
- info = XCNEW (struct auxv_info);
- info->length = target_read_alloc (ops, TARGET_OBJECT_AUXV,
- NULL, &info->data);
+ info = new auxv_info;
+ info->data = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL);
set_inferior_data (inf, auxv_inferior_data, info);
}
So even before it seems that we would have cached a "negative" result.
I believe your change will mean that we will keep asking over and over
for the auxv data if a target doesn't support it and that it will only
support positive caching. I wonder if a recent change means that in
your test case something is trying to fetch the AUXV vector before the
target can read it, e.g. trying to fetch AT_HWCAP* when determining the
target description for a core file or the like? It seems like for
the core target in corelow.c it should be fine to fetch AUXV data in
the gdbarch_core_read_description hook though. Did you try setting a
breakpoint for when this function was called to see when it is being
cached?
I wonder if the issue is that parsing the symbol file without a core
is trying to fetch hwcap actually. Presumably a breakpoint would let
you see that case? Maybe the fetch of hwcap needs to be guarded by
something like "target_has_execution" or the like?
--
John Baldwin
next prev parent reply other threads:[~2022-07-25 16:05 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 14:45 Luis Machado
2022-07-25 9:42 ` [PING][PATCH] " Luis Machado
2022-07-25 16:05 ` John Baldwin [this message]
2022-07-25 18:03 ` [PATCH] " Luis Machado
2022-07-25 19:13 ` John Baldwin
2022-08-02 15:05 ` Luis Machado
2022-08-02 16:05 ` John Baldwin
2022-08-05 15:46 ` [PATCH] Update auxv cache when inferior pid is 0 (no inferior) Luis Machado
2022-08-11 9:05 ` [PING][PATCH] " Luis Machado
2022-08-18 15:48 ` Luis Machado
2022-09-01 9:29 ` Luis Machado
2022-09-07 8:20 ` Luis Machado
2022-09-12 12:48 ` Luis Machado
2022-09-12 13:30 ` [PATCH] " Simon Marchi
2022-09-12 13:53 ` John Baldwin
2022-09-12 13:59 ` Luis Machado
2022-09-20 12:28 ` [PATCH] Invalidate auxv cache before creating a core target Luis Machado
2022-09-20 17:49 ` John Baldwin
2022-10-07 20:44 ` [PATCH] gdb: fix auxv caching Simon Marchi
2022-10-07 21:43 ` John Baldwin
2022-10-09 0:39 ` Simon Marchi
2022-10-10 18:32 ` John Baldwin
2022-10-11 17:52 ` Simon Marchi
2022-10-11 20:31 ` Pedro Alves
2022-10-11 20:34 ` Pedro Alves
2022-10-11 20:42 ` John Baldwin
2022-10-12 1:11 ` Simon Marchi
2022-10-10 9:33 ` Luis Machado
2022-10-11 17:53 ` Simon Marchi
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=76097707-ed9e-1556-fac2-1992ab3cabae@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado@arm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).