[PATCH v2 5/9] GDB, gdbserver: aarch64-linux: Initial Guarded Control Stack support

Thiago Jung Bauermann thiago.bauermann@linaro.org
Thu Jun 19 15:19:02 GMT 2025


Luis Machado <luis.machado@arm.com> writes:

> On 6/18/25 06:54, 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 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 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 && feature_gcs == nullptr)
>> +    /* This feature depends on the GCS feature.  */
>> +    return nullptr;
>
> If we ever happen to have a malformed target description for Linux that has the
> general gcs feature but doesn't have the Linux-specific one, we will bail out
> here, and the target will likely be undebuggable/hard to debug, as we rely heavily
> on the target descriptions. With a bogus description, gdb won't budge.
>
> I'm wondering if we should instead just complain, semi-loudly, about it and ignore
> the general GCS feature if the Linux one is missing so we can carry on with a more useful
> debugging session.
>
> What do you think?

I think that's a good idea, and should be easy enough to do.
I'll send a v3 with the change.

> Of course, this is unlikely to happen, but you never know.

I agree it's better to be more resilient if possible. I'll try to make a
testcase exercising this scenario.

-- 
Thiago


More information about the Gdb-patches mailing list