From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id D1EEE385AC27 for ; Mon, 24 Oct 2022 18:24:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D1EEE385AC27 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.64] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 3C5541E0CB; Mon, 24 Oct 2022 14:24:43 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1666635883; bh=U+nIMGEMzumamkQZecYLu4tX0ba+2QncBBX25oLXH7U=; h=Date:Subject:To:References:From:In-Reply-To:From; b=VJgVcvn1oCE2siSSXS2fmt6FO2AkolyrfL8JIECG7D88rVdA880vbx8Cyw6Fzz2VU 583XzSo35FLkvQAG0cNRa1GL/1jNHuoCPvlI/jFGQdpFRFMCZMibpkS46XuRJCpeIr Ms9QXDqUTcX16rr+Xygoc0GIiuVRhqxtHUyxm9n4= Message-ID: <36cfc9eb-a939-7d76-4295-3c507a187961@simark.ca> Date: Mon, 24 Oct 2022 14:24:42 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [PATCH] gdb/disasm: mark functions passed to the disassembler noexcept Content-Language: fr To: Andrew Burgess , gdb-patches@sourceware.org References: <20221024125016.2823862-1-aburgess@redhat.com> <499ecf26-0f57-2376-a617-9b6214319b4a@simark.ca> <87r0yx6sr7.fsf@redhat.com> <87mt9l6rp8.fsf@redhat.com> From: Simon Marchi In-Reply-To: <87mt9l6rp8.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/24/22 13:45, Andrew Burgess via Gdb-patches wrote: > > I realise I made a bit of a mess, including the updated patch in the > previous email. I should have just posted both of these as a new V2 > series. > > Oh well! The patch below applies on top of the first patch (in the > parent email), and adds the noexcept keyword in a few places. > > Thanks, > Andrew > > --- > > commit b1e3243296084566baf443d9c5280918a9d784f3 > Author: Andrew Burgess > Date: Mon Oct 24 18:35:41 2022 +0100 > > gdb/disasm: mark functions passed to the disassembler noexcept > > While working on another patch, Simon pointed out that GDB could be > improved by marking the functions passed to the disassembler as > noexcept. > > https://sourceware.org/pipermail/gdb-patches/2022-October/193084.html > > The reason this is important is the on some hosts, libopcodes, being C > code, will not be compiled with support for handling exceptions. As > such, an attempt to throw an exception over libopcodes code will cause > GDB to terminate. > > See bug gdb/29712 for an example of when this happened. > > In this commit all the functions that are passed to the disassembler, > and which might be used as callbacks by libopcodes are marked > noexcept. > > Ideally, I would have liked to change these typedefs: > > using read_memory_ftype = decltype (disassemble_info::read_memory_func); > using memory_error_ftype = decltype (disassemble_info::memory_error_func); > using print_address_ftype = decltype (disassemble_info::print_address_func); > using fprintf_ftype = decltype (disassemble_info::fprintf_func); > using fprintf_styled_ftype = decltype (disassemble_info::fprintf_styled_func); > > which are declared in disasm.h, as including the noexcept keyword. > However, when I tried this, I ran into this warning/error: > > In file included from ../../src/gdb/disasm.c:25: > ../../src/gdb/disasm.h: In constructor ‘gdb_printing_disassembler::gdb_printing_disassembler(gdbarch*, ui_file*, gdb_disassemble_info::read_memory_ftype, gdb_disassemble_info::memory_error_ftype, gdb_disassemble_info::print_address_ftype)’: > ../../src/gdb/disasm.h:116:3: error: mangled name for ‘gdb_printing_disassembler::gdb_printing_disassembler(gdbarch*, ui_file*, gdb_disassemble_info::read_memory_ftype, gdb_disassemble_info::memory_error_ftype, gdb_disassemble_info::print_address_ftype)’ will change in C++17 because the exception specification is part of a function type [-Werror=noexcept-type] > 116 | gdb_printing_disassembler (struct gdbarch *gdbarch, > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > > So I've left that change out. This does mean that if somebody adds a > new use of the disassembler classes in the future, and forgets to mark > the callbacks as noexcept, this will compile fine. We'll just have to > manually check for that during review. Like I said in my other email, I think this warning could safely be ignored (silenced). We are not writing a library with a stable ABI, we don't care if the mangling is different in two different builds. Simon