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.133.124]) by sourceware.org (Postfix) with ESMTPS id 644CA3834874 for ; Thu, 15 Dec 2022 16:28:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 644CA3834874 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=1671121704; 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=hR/0oUZXPuaIF4QP7Wde/whbopjdN4qkTrQvnIzvNblhWV1tyDaJj0jIFCsn91e1DQPSR6 ykr7uH9doWwLMYDiFtspVxOADGkKRIBwrgvMKSrm+GWgpaWT04wK1/Li9b53FjWV+rCH4g f1KCo/ZLgT9FOx4l3kPUM04QGYJm+5o= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-632-0b_7oftwMR-H9EX87IPVmw-1; Thu, 15 Dec 2022 11:28:22 -0500 X-MC-Unique: 0b_7oftwMR-H9EX87IPVmw-1 Received: by mail-qk1-f197.google.com with SMTP id bi42-20020a05620a31aa00b006faaa1664b9so6206313qkb.8 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=cUSn8fbQnrhAuPROMfu52xfne0EpWBKAj5vm5mVfTm1mNeniVxDqCAU4FLh2R6p5si FBc/BRb4cGj3XdV2H6bsYJnPJ4dUfF7+X2x8yalw78w3FYNu6ehi6GproJpSzRLTQRcN 0nVp68naAWBudXB1eyXhTZnFgQxV4YttklIiLRm8URYLVjWtsXE5osXUPnlakbFomMYu 9vwNCnpPBJ0E9pqbjnBkoMlrsy+q16Yp92DjLZ8w/its8CT3gAntWRfBgZX5Fh92z1bG hrllsxJa5Sx14769Oreyaw4dibEI1gXVtXXnASfnOSbh1uqK3Yl4qsTpDq3LPiYfNiAV oadw== X-Gm-Message-State: ANoB5pm0/w/bVa3nHO6hlB51Fwe5pyG1bMI0qhBZsLIOXtLOR5G/gV4w RTmB3fo4vZ8BXJI4Wj6qE3FDfSOnmpKQzoB67EQSiKg1VZu78JB7nGKVE3Pi7srNC9yoSJrGAD7 IoMLDfqDIdCNYhCDrDA== X-Received: by 2002:ac8:528a:0:b0:3a3:e79:e4cb with SMTP id s10-20020ac8528a000000b003a30e79e4cbmr17114348qtn.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=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 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 > }