From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway21.websitewelcome.com (gateway21.websitewelcome.com [192.185.45.140]) by sourceware.org (Postfix) with ESMTPS id A5B413857C6C for ; Thu, 4 Nov 2021 18:09:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A5B413857C6C 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 cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 481C7400CBF86 for ; Thu, 4 Nov 2021 13:09:12 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id ihAmmyQCZOnCIihAmmbHEs; Thu, 04 Nov 2021 13:09:12 -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:References:In-Reply-To: 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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=TkiG+lzcahSOsenv6mwWoc1wLG2qDs9h5Y7LKUIIPig=; b=ivKfyqKNvLOH8oq6Qx07LmIhwk sPh+6Q+OGk1n5s/p3EArhmflxpaddVbc8iNVsl1t+fP11Q2z5JYE9a/hZBa/UK6XcYJeC/QRLzN24 tqb1dfVeQuet2Pwnt/++Nea3o; Received: from 75-166-134-234.hlrn.qwest.net ([75.166.134.234]:51958 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 1mihAl-003Gzb-TH; Thu, 04 Nov 2021 12:09:11 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 12/32] Specialize std::hash for gdb_exception Date: Thu, 4 Nov 2021 12:08:47 -0600 Message-Id: <20211104180907.2360627-13-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211104180907.2360627-1-tom@tromey.com> References: <20211104180907.2360627-1-tom@tromey.com> 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: 75.166.134.234 X-Source-L: No X-Exim-ID: 1mihAl-003Gzb-TH X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-134-234.hlrn.qwest.net (localhost.localdomain) [75.166.134.234]:51958 X-Source-Auth: tom+tromey.com X-Email-Count: 17 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP 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, 04 Nov 2021 18:09:14 -0000 This adds a std::hash specialization for gdb_exception. This lets us store these objects in a hash table, which is used later in this series to de-duplicate the exception output from multiple threads. --- gdbsupport/common-exceptions.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h index 5933c7356fe..051379cdb56 100644 --- a/gdbsupport/common-exceptions.h +++ b/gdbsupport/common-exceptions.h @@ -24,6 +24,7 @@ #include #include #include +#include /* Reasons for calling throw_exceptions(). NOTE: all reason values must be different from zero. enum value 0 is reserved for internal @@ -187,6 +188,24 @@ struct gdb_exception std::shared_ptr message; }; +namespace std +{ + +/* Specialization of std::hash for gdb_exception. */ +template<> +struct hash +{ + size_t operator() (const gdb_exception &exc) const + { + size_t result = exc.reason + exc.error; + if (exc.message != nullptr) + result += std::hash {} (*exc.message); + return result; + } +}; + +} + /* Functions to drive the sjlj-based exceptions state machine. Though declared here by necessity, these functions should be considered internal to the exceptions subsystem and not used other than via -- 2.31.1