From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 9D8DF385840B for ; Thu, 7 Oct 2021 14:36:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9D8DF385840B Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D703B1FE6F; Thu, 7 Oct 2021 14:36:39 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BC48613CE5; Thu, 7 Oct 2021 14:36:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cmDQLPcFX2HQXgAAMHmgww (envelope-from ); Thu, 07 Oct 2021 14:36:39 +0000 Subject: [PING][PATCH][gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as unittest From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey , Simon Marchi References: <20210911120254.GA19083@delia.home> Message-ID: Date: Thu, 7 Oct 2021 16:36:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Oct 2021 14:36:41 -0000 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