From patchwork Mon Jul 1 19:27:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 33506 Received: (qmail 65783 invoked by alias); 1 Jul 2019 19:27:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 65768 invoked by uid 89); 1 Jul 2019 19:27:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: mail-wm1-f52.google.com Received: from mail-wm1-f52.google.com (HELO mail-wm1-f52.google.com) (209.85.128.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 01 Jul 2019 19:27:55 +0000 Received: by mail-wm1-f52.google.com with SMTP id x15so632748wmj.3 for ; Mon, 01 Jul 2019 12:27:55 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:56ee:75ff:fe8d:232b? ([2001:8a0:f913:f700:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id b9sm5178491wrx.57.2019.07.01.12.27.53 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jul 2019 12:27:53 -0700 (PDT) Subject: [users/palves/format_strings] %pS/%pN -> %p[/%p] To: Tom Tromey References: <20190605020116.1550-1-tom@tromey.com> <1ee4bd6b-4cdf-f3a9-74af-0843bf123a8b@redhat.com> <87lfygi1x0.fsf@tromey.com> <32872d6a-15d6-9718-59ae-957694e114c9@redhat.com> <87imtjhj6b.fsf@tromey.com> <625cd0ba-058d-d4bf-8ba3-8676f335b0f3@redhat.com> <87blzbep47.fsf@tromey.com> <2180f72f-da10-5333-90a1-666ba3bd145e@redhat.com> <87imtjbrmx.fsf@tromey.com> <871s056yjw.fsf@tromey.com> <87ef3aq6ux.fsf@tromey.com> <5372d765-b75f-8d2c-bf0f-e3c0ddc3a802@redhat.com> <87muhxpt7q.fsf@tromey.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <8216adbc-9d34-a29a-02e3-42e0a1ef49fb@redhat.com> Date: Mon, 1 Jul 2019 20:27:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <87muhxpt7q.fsf@tromey.com> On 7/1/19 6:20 PM, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> The visual balance of brackets is appealing as well, so I can't say > Pedro> I have a strong preference either way. If you've been converting things > Pedro> already, you'll have a better judgment, so I'll defer to you. > > I haven't really converted much, just what you saw on the branch. > > I suspect using some kind of paired brackets will make it a little > harder to forget to close the style. But probably only a little. Also > I guess we could add asserts to check that the closing parameter is > always null. Let's try this. I pushed the patch below to the branch. From 5984c619b7ee91e6414b1a56d0a735240fb5afce Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 1 Jul 2019 19:07:44 +0100 Subject: [PATCH] %pS/%pN -> %p[/%p] --- gdb/common/format.c | 3 ++- gdb/ui-out.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gdb/common/format.c b/gdb/common/format.c index 177f79afee3..345bdfc4cca 100644 --- a/gdb/common/format.c +++ b/gdb/common/format.c @@ -259,7 +259,8 @@ format_pieces::format_pieces (const char **arg, bool gdb_extensions) case 's': case 'S': case 'F': - case 'N': + case '[': + case ']': f++; break; } diff --git a/gdb/ui-out.c b/gdb/ui-out.c index d50fb3a3e3f..065a9209656 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -617,12 +617,16 @@ ui_out::vmessage (const char *format, va_list args) call_do_message (ss->style (), "%s", ss->str ()); } break; - case 'S': + case '[': style = *va_arg (args, const ui_file_style *); break; - case 'N': - va_arg (args, void *); - style = {}; + case ']': + { + void *arg = va_arg (args, void *); + gdb_assert (arg == nullptr); + + style = {}; + } break; default: call_do_message (style, current_substring, va_arg (args, void *));