[PING][PATCH][gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as unittest

Tom de Vries via Gdb-patches
2021-10-07T14:37:00Z

On 9/22/21 12:17 PM, Tom de Vries wrote:
> On 9/11/21 2:02 PM, Tom de Vries wrote:
>> +#if GDB_SELF_TEST
>> +namespace selftests {
>> +extern void (*hook_set_active_ext_lang) (void);
>> +void (*hook_set_active_ext_lang) (void) = nullptr;
>> +}
>> +#endif
>> +
>> /* Set the currently active extension language to NOW_ACTIVE.
>> The result is a pointer to a malloc'd block of memory to pass to
>> restore_active_ext_lang.
>> @@ -708,6 +715,11 @@ install_gdb_sigint_handler (struct signal_handler *previous)
>> struct active_ext_lang_state *
>> set_active_ext_lang (const struct extension_language_defn *now_active)
>> {
>> +#if GDB_SELF_TEST
>> + if (selftests::hook_set_active_ext_lang)
>> + selftests::hook_set_active_ext_lang ();
>> +#endif
>
> In particular, I'd like feedback on whether this is acceptable.
>
> F.i., I could do instead the less intrusive (but also less flexible):
> ...
> #if GDB_SELF_TEST
> namespace selftests {
> extern int hook_raise_at_entry_active_ext_lang;
> int hook_raise_at_entry_active_ext_lang = 0;
> #endif
>
> struct active_ext_lang_state *
> set_active_ext_lang (const struct extension_language_defn *now_active)
> {
> #if GDB_SELF_TEST
> if (selftests::hook_raise_at_entry_active_ext_lang)
> raise (hook_raise_at_entry_active_ext_lang);
> #endif
> ...
>
> The hook that is a function pointer is the most flexible, but possibly
> less safe. OTOH, it is in the selftest code, which we disable by
> default in release branches, so by default this is not included in
> releases. OTOH, it's still possible to enable it in releases using
> --enable-unit-tests. Perhaps this could be handled using a
> DEVEL_GDB_SELF_TEST, which is disabled in release branches independent
> of --enable-unit-tests?
>
> Any comment appreciated.
>

Ping.

Thanks,
- Tom