From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by sourceware.org (Postfix) with ESMTPS id 0BAB53858C83 for ; Mon, 17 Oct 2022 19:26:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0BAB53858C83 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-f44.google.com with SMTP id y10so9343409wma.0 for ; Mon, 17 Oct 2022 12:26:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ByvnkY1kRxcAsBmZ9e3EWKOfuj/8ZnGeoJflPPFjXpU=; b=P4QtP00jf8+0RYJ6bLnnpjy5rcHOl0rZdS3rq3zbT9gBbiEEWxjhNoz5NkbDAgXw3L D6ExKJJ9P2mLJYxyRcvW8/7HRO+k28c750yX0h0l2eRbZMcd7cuYKreACLVvePXOYGCm jjv2huWmGdBJ6FohICeLtr71eFil5k/tF02fhrkFTnhi4aoZcN74LxQKFb9J5zQWfNmn QSthsrkF+BLIgorZtCxexFKLcA3anSBDJqNpH5XxDoKxDCx59B3S/9FFoek5DPFNbWnl PGdmhBT0Z/rmWZiDDs5BZ85f4z2zt5ftA2BtmuweZpk8Al2Gb3Xe5aZpBHYCew1TvLwt MpZw== X-Gm-Message-State: ACrzQf39ZlOjZg2Qrvh4iwMkPzk4w/05Crgn1a7U28mpOLCMnnHfB3Ox FPOIMBIk7wYx+kePlYYN9kig+t7oA8Pu7g== X-Google-Smtp-Source: AMsMyM6E/xNkoCfzf+oa0je9CWkNaDTCmMwFj5uGN43s3Vcv9+O9Lvo/PJJ7jEkJKNucKiGmzOC7fQ== X-Received: by 2002:a05:600c:444e:b0:3c6:fbb0:bf3c with SMTP id v14-20020a05600c444e00b003c6fbb0bf3cmr1530600wmn.189.1666034815834; Mon, 17 Oct 2022 12:26:55 -0700 (PDT) Received: from ?IPv6:2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653? ([2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653]) by smtp.gmail.com with ESMTPSA id c1-20020adfed81000000b00226dba960b4sm9268523wro.3.2022.10.17.12.26.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Oct 2022 12:26:54 -0700 (PDT) Subject: Re: [PATCH] internal_error: remove need to pass __FILE__/__LINE__ To: Simon Marchi , gdb-patches@sourceware.org References: <20221017185019.3233941-1-pedro@palves.net> From: Pedro Alves Message-ID: Date: Mon, 17 Oct 2022 20:26:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 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=-3.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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: Mon, 17 Oct 2022 19:27:00 -0000 On 2022-10-17 7:59 p.m., Simon Marchi wrote: > > > On 2022-10-17 14:50, Pedro Alves wrote: >> Currently, every internal_error call must be passed __FILE__/__LINE__ >> explicitly, like: >> >> internal_error (__FILE__, __LINE__, "foo %d", var); >> >> The need to pass in explicit __FILE__/__LINE__ is there probably >> because the function predates widespread and portable variadic macros >> availability. We can use variadic macros nowadays, and in fact, we >> already use them in several places, including the related >> gdb_assert_not_reached. >> >> So this patch renames the internal_error function to something else, >> and then reimplements internal_error as a variadic macro that expands >> __FILE__/__LINE__ itself. >> >> The result is that we now should call internal_error like so: >> >> internal_error ("foo %d", var); >> >> Likewise for internal_warning. >> >> The patch adjusts all calls sites. 99% of the adjustments were done >> with a perl/sed script. >> >> The non-mechanical changes are in gdbsupport/errors.h, >> gdbsupport/gdb_assert.h, and gdb/gdbarch.py. > > I think it's a good change, but as a result gdb_assert_not_reached and > internal_error become essentially the same thing. Can we just keep one? Most probably. I prefer keeping internal_error for it being more pervasive and older. gdb_assert_not_reached is a more recent addition. > The only difference is that gdb_assert_not_reached includes the > function name, but I don't think it's an important difference. I think > we could switch to a single one that does include the function name. I don't think it needs to be in this patch, though? This one is just making internal_error more convenient to call. We can always look at doing something to its internals separately.