From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway34.websitewelcome.com (gateway34.websitewelcome.com [192.185.149.105]) by sourceware.org (Postfix) with ESMTPS id AEBE63858015 for ; Thu, 29 Jul 2021 23:13:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AEBE63858015 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 49B433EFC3 for ; Thu, 29 Jul 2021 18:13:08 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 9FDAmmrwsrJtZ9FDAmTYI3; Thu, 29 Jul 2021 18:13:08 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=La/c+RYbxNAjZjxqzT/E3VknB5LLy9caaPo3yiUWeqE=; b=qlm94Z6P5CQxjtQwjDfvitUwy/ aqRtvc1MPyas8llVbT8JO+ftlE5HKlr+VemCGfgwfnqckb9giflNN4flAeIXFXzl9HtwrKx+0a5VD GrtSx9YjigwYgrs2gDPI8EPMC; Received: from 97-122-74-117.hlrn.qwest.net ([97.122.74.117]:45948 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1m9FDA-00100a-3n; Thu, 29 Jul 2021 17:13:08 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Replace exception_print_same with operator!= Date: Thu, 29 Jul 2021 17:13:06 -0600 Message-Id: <20210729231306.1965099-1-tom@tromey.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.74.117 X-Source-L: No X-Exim-ID: 1m9FDA-00100a-3n X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-74-117.hlrn.qwest.net (localhost.localdomain) [97.122.74.117]:45948 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3029.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS_A autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 29 Jul 2021 23:13:11 -0000 I noticed that exception_print_same is only used in a single spot, and it seemed to be better as an operator!= method attached to gdb_exception. Regression tested on x86-64 Fedora 34. --- gdb/exceptions.c | 14 -------------- gdb/exec.c | 2 +- gdbsupport/common-exceptions.h | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gdb/exceptions.c b/gdb/exceptions.c index 32db6fe8235..5245b7ca28d 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -133,17 +133,3 @@ exception_fprintf (struct ui_file *file, const struct gdb_exception &e, print_exception (file, e); } } - -/* See exceptions.h. */ - -int -exception_print_same (const struct gdb_exception &e1, - const struct gdb_exception &e2) -{ - const char *msg1 = e1.message == nullptr ? "" : e1.what (); - const char *msg2 = e2.message == nullptr ? "" : e2.what (); - - return (e1.reason == e2.reason - && e1.error == e2.error - && strcmp (msg1, msg2) == 0); -} diff --git a/gdb/exec.c b/gdb/exec.c index 35bf7bd4506..a28336be8ef 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -201,7 +201,7 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf, } catch (const gdb_exception_error &err) { - if (!exception_print_same (prev_err, err)) + if (prev_err != err) warning ("%s", err.what ()); } } diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h index 92f43d267ad..5933c7356fe 100644 --- a/gdbsupport/common-exceptions.h +++ b/gdbsupport/common-exceptions.h @@ -165,6 +165,23 @@ struct gdb_exception return message->c_str (); } + /* Compare two exceptions. */ + bool operator== (const gdb_exception &other) const + { + const char *msg1 = message == nullptr ? "" : what (); + const char *msg2 = other.message == nullptr ? "" : other.what (); + + return (reason == other.reason + && error == other.error + && strcmp (msg1, msg2) == 0); + } + + /* Compare two exceptions. */ + bool operator!= (const gdb_exception &other) const + { + return !(*this == other); + } + enum return_reason reason; enum errors error; std::shared_ptr message; -- 2.31.1