From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by sourceware.org (Postfix) with ESMTPS id 884F7382FC1F for ; Wed, 1 Jun 2022 14:32:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 884F7382FC1F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f50.google.com with SMTP id o9so1105217wmd.0 for ; Wed, 01 Jun 2022 07:32:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=PNmBITO89FyEwZSQUTL7msqaSJLIHhM9yJWzcJKUCgM=; b=M6hXceuxaWUQoQVAs/cWZPjMYbpC5LewduwoILahdt//YHdY0vtBUdIBBY8b0dAkUl RXiPh3oHB8BI12fVYyCwRelLY5EREuXieNTx3zfQ032DbumJ1Vr1Ucu0KL+KFlIblY26 Q4KQC1pgbGLid+61bmJFC2v4UGUP2WsTNiMcP29dRs6b1CtoJiF7B6kfGo7NMXss0F5v 56s506Az4ox0BYu1zr8KeGHEt26yFr6VU74hSUeX63HE26UKutQynO7/MmKXFCFvfxfg t0BdO11OIpCmiqnuTEB7CCzMEnI4lZ4lzhwbPdXIqsKLNLBHeP/oE1rwy/GZ9CXhIJfk 40Bw== X-Gm-Message-State: AOAM532Db4GtyuTf+S92u1hvPwCu9TK0uhdmJ5Im1eQKEjGqN+o9qJKp U2dOWmYuA077F35OezJuyVc= X-Google-Smtp-Source: ABdhPJy5/DI0Y4t6Of8slzvYWsjt55ODw1bqLKzGhYuEewLAfikWRlxzyeety84W930NnBIuYOht3Q== X-Received: by 2002:a05:600c:19cd:b0:397:83f8:ec5c with SMTP id u13-20020a05600c19cd00b0039783f8ec5cmr28103631wmq.9.1654093939296; Wed, 01 Jun 2022 07:32:19 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id z14-20020adfd0ce000000b0020e68dd2598sm1710946wrh.97.2022.06.01.07.32.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Jun 2022 07:32:18 -0700 (PDT) Message-ID: <45511000-6883-53f4-cec6-395cd0c5b216@palves.net> Date: Wed, 1 Jun 2022 15:32:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH][gdb] Fix warning in foreach_arch selftests Content-Language: en-US To: Tom de Vries , gdb-patches@sourceware.org References: <20220601104130.GA24730@delia.home> From: Pedro Alves In-Reply-To: <20220601104130.GA24730@delia.home> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Wed, 01 Jun 2022 14:32:22 -0000 On 2022-06-01 11:41, Tom de Vries via Gdb-patches wrote: > 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; > +} Missing usual "see foo.h" comments. > + > 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"); > + A bit of an odd API to have to pass the string name in. I'd think an API that takes an enum gdb_osabi would be better, as that way you don't have to worry about either passing the wrong string, or even worry about whether it's the string contents that counts (whether the function internally uses strcmp), or the string's address (the function internally compares pointers, assuming the only strings that will be passed down are the ones in the command's enum strings array). > 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); > + }; Please format as: SCOPE_EXIT { reset (); set_osabi (save_osabi); }; And you'll also need to move this to right after the set_osabi("none") call. Doing it here is too late. SCOPE_EXIT creates a RAII object on the stack, which needs to exist before any of the code that may throw right after set_osabi("none"). > }); > > tests.emplace_back (string_printf ("%s::%s", name.c_str (), arch),