From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MktDFnVCl2ILrAkAWB0awg (envelope-from ) for ; Wed, 01 Jun 2022 06:41:57 -0400 Received: by simark.ca (Postfix, from userid 112) id 4E2831E221; Wed, 1 Jun 2022 06:41:57 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=FNgW3Ikf; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8AB471E143 for ; Wed, 1 Jun 2022 06:41:55 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2658E382FE45 for ; Wed, 1 Jun 2022 10:41:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2658E382FE45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1654080113; bh=p9+EweOxQsg2h8RlxRfeT/Dq6fm2B28r5VHhvhaLFZY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FNgW3Ikfu3odW7r3Jvm7vub6WleJmA5OqK5hxJ16l5tQD9MFoBPgydITzz31Zaj0c eaTzVpoIuUKFaCmGKt9c7j0uOi9goWtwYPqrf5Nvufc7W9mbGc8QuPcA0PykJSZMXj ozdin3YjRVt1INotIOSCdw5xHOq9SilhRQWG9kKE= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 4511038344C0 for ; Wed, 1 Jun 2022 10:41:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4511038344C0 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 5CBEE1F8C6 for ; Wed, 1 Jun 2022 10:41:33 +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 4A3B31330F for ; Wed, 1 Jun 2022 10:41:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id H9gBEV1Cl2IAGAAAMHmgww (envelope-from ) for ; Wed, 01 Jun 2022 10:41:33 +0000 Date: Wed, 1 Jun 2022 12:41:31 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb] Fix warning in foreach_arch selftests Message-ID: <20220601104130.GA24730@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, When running the selftests, I run into: ... $ gdb -q -batch -ex "maint selftest" ... Running selftest execute_cfa_program::aarch64:ilp32. warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration of GDB. Attempting to continue with the default aarch64:ilp32 settings. ... and likewise for execute_cfa_program::i8086 and execute_cfa_program::ia64-elf32. The warning can easily be reproduced outside the selftests by doing: ... $ gdb -q -batch -ex "set arch aarch64:ilp32" ... and can be prevented by first doing "set osabi none". Fix the warning by setting osabi to none while doing selftests that iterate over all architectures. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb] Fix warning in foreach_arch selftests --- gdb/osabi.c | 13 +++++++++++++ gdb/osabi.h | 6 ++++++ gdb/selftest-arch.c | 15 ++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gdb/osabi.c b/gdb/osabi.c index bbd7635532f..c3f221df969 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -633,6 +633,19 @@ set_osabi (const char *args, int from_tty, struct cmd_list_element *c) internal_error (__FILE__, __LINE__, _("Updating OS ABI failed.")); } +void +set_osabi (const char *arg) +{ + set_osabi_string = arg; + set_osabi (NULL, 0, NULL); +} + +const char * +get_osabi () +{ + return set_osabi_string; +} + static void show_osabi (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) diff --git a/gdb/osabi.h b/gdb/osabi.h index be016732cbc..eb5d88699e7 100644 --- a/gdb/osabi.h +++ b/gdb/osabi.h @@ -89,4 +89,10 @@ const char *osabi_triplet_regexp (enum gdb_osabi osabi); void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *, enum gdb_osabi *); +/* Set osabi to ARG. */ +extern void set_osabi (const char *arg); + +/* Return current osabi setting. */ +extern const char *get_osabi (); + #endif /* OSABI_H */ diff --git a/gdb/selftest-arch.c b/gdb/selftest-arch.c index f434da718d5..a631f52e31e 100644 --- a/gdb/selftest-arch.c +++ b/gdb/selftest-arch.c @@ -66,12 +66,25 @@ foreach_arch_test_generator (const std::string &name, auto test_fn = ([=] () { + /* Prevent warnings when setting architecture with current osabi + settings, like: + A handler for the OS ABI "GNU/Linux" is not built into this + configuration of GDB. Attempting to continue with the + default aarch64:ilp32 settings. */ + const char *save_osabi = get_osabi (); + set_osabi ("none"); + struct gdbarch_info info; info.bfd_arch_info = bfd_scan_arch (arch); struct gdbarch *gdbarch = gdbarch_find_by_info (info); SELF_CHECK (gdbarch != NULL); + function (gdbarch); - reset (); + + SCOPE_EXIT { + reset (); + set_osabi (save_osabi); + }; }); tests.emplace_back (string_printf ("%s::%s", name.c_str (), arch),