[PATCH 3/8] GDB, gdbserver: aarch64-linux: Initial Guarded Control Stack support
Thiago Jung Bauermann
thiago.bauermann@linaro.org
Wed Jun 18 06:16:06 GMT 2025
Hello Luis,
Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
> Luis Machado <luis.machado@arm.com> writes:
>
>> On 6/8/25 02:03, Thiago Jung Bauermann wrote:
>>> @@ -4590,6 +4643,46 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct
>> gdbarch_list *arches)
>>> int first_w_regnum = num_pseudo_regs;
>>> num_pseudo_regs += 31;
>>>
>>> + const struct tdesc_feature *feature_gcs
>>> + = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.gcs");
>>> + int first_gcs_regnum = -1;
>>> + /* Add the GCS registers. */
>>> + if (feature_gcs != nullptr)
>>> + {
>>> + first_gcs_regnum = num_regs;
>>> + /* Validate the descriptor provides the mandatory GCS registers and
>>> + allocate their numbers. */
>>> + for (i = 0; i < ARRAY_SIZE (aarch64_gcs_register_names); i++)
>>> + valid_p &= tdesc_numbered_register (feature_gcs, tdesc_data.get (),
>>> + first_gcs_regnum + i,
>>> + aarch64_gcs_register_names[i]);
>>> +
>>> + num_regs += i;
>>> + }
>>> +
>>> + if (!valid_p)
>>> + return nullptr;
>>> +
>>> + const struct tdesc_feature *feature_gcs_linux
>>> + = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.gcs.linux");
>>> + int first_gcs_linux_regnum = -1;
>>> + /* Add the GCS Linux registers. */
>>> + if (feature_gcs_linux != nullptr)
>>> + {
>>> + first_gcs_linux_regnum = num_regs;
>>> + /* Validate the descriptor provides the mandatory GCS Linux registers
>>> + and allocate their numbers. */
>>> + for (i = 0; i < ARRAY_SIZE (aarch64_gcs_linux_register_names); i++)
>>> + valid_p &= tdesc_numbered_register (feature_gcs_linux, tdesc_data.get (),
>>> + first_gcs_linux_regnum + i,
>>> + aarch64_gcs_linux_register_names[i]);
>>> +
>>> + /* This feature depends on the GCS feature. */
>>> + valid_p &= feature_gcs != nullptr;
>>> +
>>> + num_regs += i;
>>> + }
>>> +
>>
>> Given we have a Linux-specific part of the target description XML,
>> shouldn't it be handled in aarch64-linux-tdep.c instead? That's what
>> amd64 seems to do. Though s390 opted to do it in s390-tdep.c as
>> well. No strong preference here, as long as the Linux-specific bit
>> doesn't get in the way of bare metal handling.
>
> Do you mean handling it in aarch64_linux_init_abi? I'll try it out and
> see how it looks. I agree it makes more sense to do it in
> aarch64-linux-tdep.c
I gave up on this because I don't fully understand how
aarch64_gdbarch_init and aarch64_linux_init_abi interact (and also
tdesc_use_registers, which I think is also relevant here). I prefer to
be a bit conservative at this point.
--
Thiago
More information about the Gdb-patches
mailing list