From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 46473382E476 for ; Thu, 15 Dec 2022 16:28:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46473382E476 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671121708; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lx1LFdA+nCdVs8XKZAYhi4vKKNws7QYm538Q4h3kWtg=; b=i7dAKE/7gMF2FnkYLqCPTdL56+AARghOrhEUGbuxBakwVcral3FKRk9e0kCk36mtyEbj5H 767cdawfzl6WlYPOTByytVc+zrvdvMD3bVDOGcI7cYzHgqgJakj5/cTy41hao83jtfX1My p0tfjJ4tW2n6W+7HTa413lzCJZYlL0A= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-637-kvEQytl1NoasUAMzT5zJDA-1; Thu, 15 Dec 2022 11:28:22 -0500 X-MC-Unique: kvEQytl1NoasUAMzT5zJDA-1 Received: by mail-qt1-f198.google.com with SMTP id z16-20020ac84550000000b003a807d816b2so4781292qtn.4 for ; Thu, 15 Dec 2022 08:28:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lx1LFdA+nCdVs8XKZAYhi4vKKNws7QYm538Q4h3kWtg=; b=BJQe7Nrk9KWBTnP54bLAVbAu2Ftqa3tqBWO9UCIrDW8kpWV+sxP7JWLnAaTnPgVjUU GYPzljVh1co4T0Y3KwD0kg11JYk4EfWLyilAlJ8IRa2idCIwpzWuxzY+vzsiy0XioRy7 j9firxpnzaLNBj6dmB9qM3+iGpmg2sRIhDmnQHTDnV8iPnYcaNcfqbbPMPfUvOWIBkPc GNAZytPxlKDtK+oW+WvGZSvnmX9wMFTFZJZAEz3W0lHX/Eac9COP73FtjdOiH0a6eQAF m/wqegrYa6aVfYifU3QoTRhglhhkXOrmRLkMzHrYR4eKwwzZZLF7WeXl2dAXL+64+arX 39SA== X-Gm-Message-State: ANoB5pkzl1/kegNli+WQ8/6bsoWhToYEUAW5GLvRdbcu9fWzwwqs/cU8 OQRX1hd/KgPC4pfNHtzrXpgZ1Vy7EqPYsVDJ1ixeBa6ezfHPm5yPo2P7tRRHxEqUkG4g2hNV0xB k/QOEQUKl77DlUXc= X-Received: by 2002:ac8:528a:0:b0:3a3:e79:e4cb with SMTP id s10-20020ac8528a000000b003a30e79e4cbmr17114349qtn.49.1671121701623; Thu, 15 Dec 2022 08:28:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf5bJY7jxP/Ju7RgIqjzfw6SW6tIh8EAPAj3Fbp1w11lAaB0rzf5hHbx/blgM9r7vwUffTVhPQ== X-Received: by 2002:ac8:528a:0:b0:3a3:e79:e4cb with SMTP id s10-20020ac8528a000000b003a30e79e4cbmr17114322qtn.49.1671121701330; Thu, 15 Dec 2022 08:28:21 -0800 (PST) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id fe4-20020a05622a4d4400b003a69225c2cdsm3739554qtb.56.2022.12.15.08.28.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Dec 2022 08:28:20 -0800 (PST) Message-ID: <7b129144-65a9-7f1a-c093-f85722979d38@redhat.com> Date: Thu, 15 Dec 2022 11:28:19 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH 2/4] libstdc++: Improve output of default contract violation handler [PR107792] To: =?UTF-8?Q?Arsen_Arsenovi=c4=87?= , gcc-patches@gcc.gnu.org Cc: jwakely@redhat.com, libstdc++@gcc.gnu.org References: <20221210094303.2180127-1-arsen@aarsen.me> <20221210094303.2180127-3-arsen@aarsen.me> From: Jason Merrill In-Reply-To: <20221210094303.2180127-3-arsen@aarsen.me> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable 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 12/10/22 04:43, Arsen Arsenović wrote: > From: Jonathan Wakely > > Make the output more readable. Don't output anything unless verbose > termination is enabled at configure-time. > > libstdc++-v3/ChangeLog: > > PR libstdc++/107792 > PR libstdc++/107778 > * src/experimental/contract.cc (handle_contract_violation): Make > output more readable. > --- > libstdc++-v3/src/experimental/contract.cc | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > > diff --git a/libstdc++-v3/src/experimental/contract.cc b/libstdc++-v3/src/experimental/contract.cc > index c8d2697eddc..6a7f064d35e 100644 > --- a/libstdc++-v3/src/experimental/contract.cc > +++ b/libstdc++-v3/src/experimental/contract.cc > @@ -1,4 +1,5 @@ > // -*- C++ -*- std::experimental::contract_violation and friends > + > // Copyright (C) 2019-2022 Free Software Foundation, Inc. > // > // This file is part of GCC. > @@ -23,19 +24,21 @@ > // . > > #include > -#include > +#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE > +# include > +#endif > > __attribute__ ((weak)) void > handle_contract_violation (const std::experimental::contract_violation &violation) > { > - std::cerr << "default std::handle_contract_violation called: \n" > - << " " << violation.file_name() > - << " " << violation.line_number() > - << " " << violation.function_name() > - << " " << violation.comment() > - << " " << violation.assertion_level() > - << " " << violation.assertion_role() > - << " " << (int)violation.continuation_mode() > +#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE > + const char* modes[]{ "never", "maybe" }; // Must match enumerators in header. I'd actually suggest "off" and "on" since it's really a boolean since "always_continue" was dropped. > + std::cerr << "contract violation in function " << violation.function_name() > + << " at " << violation.file_name() << ':' << violation.line_number() > + << ": " << violation.comment() > + << "\n[level:" << violation.assertion_level() Maybe omit level/role if "default"? > + << ", role:" << violation.assertion_role() << ", continuation mode:" > + << modes[(int)violation.continuation_mode()] << ']' > << std::endl; > +#endif > }