From: Simon Marchi <simark@simark.ca>
To: Alan Hayward <Alan.Hayward@arm.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>
Subject: Re: [PATCH 2/2] gdbserver: Add linux_get_hwcap
Date: Mon, 25 Mar 2019 15:41:00 -0000 [thread overview]
Message-ID: <c35bf474-2d6e-9a6b-080f-08a59bd186a3@simark.ca> (raw)
In-Reply-To: <20190325120542.92123-2-alan.hayward@arm.com>
On 2019-03-25 8:05 a.m., Alan Hayward wrote:
> In gdbserver, Tidy up calls to read HWCAP (and HWCAP2) by adding common
> functions, removing the Arm, AArch64, PPC and S390 specific versions.
>
> No functionality differences.
>
> [ I wasn't sure in gdbserver when to use CORE_ADDR and when to use int/long.
> I'm assuming CORE_ADDR is fairly recent to gdbserver? ]
I don't know if CORE_ADDR is a recent addition to gdbserver. But I
suppose CORE_ADDR was chosen as the return type for functions reading
arbitrary AUXV values, since some of them may be pointers. With
CORE_ADDR, we know those values will fit in the data type. When we
return the HWCAP value, we know it won't be a pointer though, so
returning a CORE_ADDR is a bit confusing, IMO. Those functions
returning the HWCAP value could return something else, an uint64_t
maybe. But then I would change it in the gdb version as well to match.
> /* Implementation of linux_target_ops method "arch_setup". */
>
> static void
> @@ -545,8 +521,8 @@ aarch64_arch_setup (void)
> if (is_elf64)
> {
> uint64_t vq = aarch64_sve_get_vq (tid);
> - unsigned long hwcap = 0;
> - bool pauth_p = aarch64_get_hwcap (&hwcap) && (hwcap & AARCH64_HWCAP_PACA);
> + unsigned long hwcap = linux_get_hwcap (8);
> + bool pauth_p = hwcap & AARCH64_HWCAP_PACA;
Just wondering, can the linux-aarch64-low.c code be used to debug a process
> diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
> index 6f703f589f..481919c205 100644
> --- a/gdb/gdbserver/linux-low.c
> +++ b/gdb/gdbserver/linux-low.c
> @@ -7423,6 +7423,64 @@ linux_get_pc_64bit (struct regcache *regcache)
> return pc;
> }
>
> +/* Extract the auxiliary vector entry with a_type matching MATCH, storing the
> + value in VALP and returning true. If no entry was found, return false. */
> +
> +static bool
> +linux_get_auxv (int wordsize, CORE_ADDR match, CORE_ADDR *valp)
I think this function could return the result (CORE_ADDR) directly,
returning 0 on failure.
If 4 and 8 are the only supported wordsize values, I would suggest
adding an assert to verify it.
> +{
> + gdb_byte *data = (gdb_byte *) alloca (2 * wordsize);
> + int offset = 0;
> +
> + while ((*the_target->read_auxv) (offset, data, 2 * wordsize) == 2 * wordsize)
> + {
> + if (wordsize == 4)
> + {
> + unsigned int *data_p = (unsigned int *)data;
> + if (data_p[0] == match)
> + {
> + *valp = data_p[1];
> + return true;
> + }
> + }
> + else
> + {
> + unsigned long *data_p = (unsigned long *)data;
> + if (data_p[0] == match)
> + {
> + *valp = data_p[1];
> + return true;
> + }
> + }
I am a bit worried about relying on the size of the "int" and "long"
types in architecture-independent code. Could we use uint32_t and
uint64_t instead?
Simon
next prev parent reply other threads:[~2019-03-25 15:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-25 12:05 [PATCH 1/2] " Alan Hayward
2019-03-25 12:05 ` [PATCH 2/2] gdbserver: " Alan Hayward
2019-03-25 15:41 ` Simon Marchi [this message]
2019-03-26 13:17 ` Alan Hayward
[not found] ` <353e83d9-efb3-c485-9ae6-6fc0a1f54553@simark.ca>
[not found] ` <57CEBD0C-44A5-48D1-8CEB-54584E1A1A21@arm.com>
[not found] ` <59A457A2-F464-4A05-A471-700F066114AD@arm.com>
2019-03-26 14:34 ` FW: " Alan Hayward
2019-03-28 9:50 ` Ulrich Weigand
2019-03-28 11:35 ` Alan Hayward
2019-03-29 23:12 ` Ulrich Weigand
2019-04-03 19:13 ` Pedro Franco de Carvalho
2019-04-04 13:49 ` Ulrich Weigand
2019-04-05 16:26 ` Pedro Franco de Carvalho
2019-04-05 16:39 ` Ulrich Weigand
2019-04-05 17:23 ` Pedro Franco de Carvalho
2019-04-08 9:38 ` Alan Hayward
2019-04-11 14:12 ` Pedro Franco de Carvalho
2019-03-26 14:56 ` FW: " Simon Marchi
2019-04-02 22:00 ` Peter Bergner
2019-04-04 21:22 ` Pedro Franco de Carvalho
2019-03-25 15:18 ` [PATCH 1/2] " Simon Marchi
2019-03-25 16:51 ` Alan Hayward
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=c35bf474-2d6e-9a6b-080f-08a59bd186a3@simark.ca \
--to=simark@simark.ca \
--cc=Alan.Hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@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