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 6EE623858412 for ; Mon, 24 Oct 2022 16:49:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6EE623858412 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) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 1160C1E0D3; Mon, 24 Oct 2022 12:48:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1666630140; bh=AchWwOwoFOPp82APNYUl128KrZsvE9Jv5SvjQ/4ISA4=; h=Date:Subject:To:References:From:In-Reply-To:From; b=oP0mHr4bs6rqiuBWK0Pqdzyh4tXYDS4jIKNy6p8f6EzG1ZnqLhbaPMXp4bl2bKx3o cMSPfEJW25Pdgtuf69cItlOjMHiTHs0iR6RjFlJhtKBEjItH34uuDpFYJXb+l7sfxS Hzlkb36ZXhR2+xnm2RLK6czNoulwRmjGVP7Rj4go= Message-ID: Date: Mon, 24 Oct 2022 12:48:59 -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 2/2] [gdb] Fix rethrow exception slicing in insert_bp_location Content-Language: fr To: Tom de Vries , Pedro Alves , gdb-patches@sourceware.org References: <20221024084913.19429-1-tdevries@suse.de> <20221024084913.19429-3-tdevries@suse.de> <02ad6f69-2a1b-b938-0ab4-ba6288f10fde@suse.de> From: Simon Marchi In-Reply-To: <02ad6f69-2a1b-b938-0ab4-ba6288f10fde@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,BODY_8BITS,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 12:43, Tom de Vries via Gdb-patches wrote: > On 10/24/22 18:36, Pedro Alves wrote: >> On 2022-10-24 9:49 a.m., Tom de Vries via Gdb-patches wrote: >> >>> +#define RETHROW_ON_TARGET_CLOSE_ERROR(E)                \ >>> +  do                                    \ >>> +    {                                    \ >>> +      if ((E).reason != 0)                        \ >>> +    {                                \ >>> +      /* Can't set the breakpoint.  */                \ >>> +                                    \ >>> +      if ((E).error == TARGET_CLOSE_ERROR)                \ >>> +        /* If the target has closed then it will have deleted any    \ >>> +           breakpoints inserted within the target inferior, as a    \ >>> +           result any further attempts to interact with the        \ >>> +           breakpoint objects is not possible.  Just rethrow the    \ >>> +           error.  Don't use E to rethrow, to prevent object    \ >>> +           slicing of the exception.  */                \ >>> +        throw;                            \ >>> +    }                                \ >>> +    } while (0) >> >> Is there a reason this is a macro instead of a function? > > yes, the throw without expression. > > Do you know of a way to do this using a function? Maybe by passing the exception object as a parameter and using: https://en.cppreference.com/w/cpp/error/rethrow_exception ? Simon