From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71339 invoked by alias); 30 Sep 2019 14:06:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 71289 invoked by uid 89); 30 Sep 2019 14:06:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 spammy=mine X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Sep 2019 14:06:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1569852378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fDmSGqq1wMN4MgTGHO16ZmKW4tu0x+tT2EJ/cXtEBrs=; b=NHdj9lvoFMugoa+U3YeVFAD82rQSCRbn4Noe/WGQYVN3e6jxGZ5+98Bh0G1uu76eSQ0ilN XuFpQ9+71yvqCYrH72QPc7hYN/teLkgi/cUK0sE6N2T7QFDBtVxmOFZ56oeu8tdrrQQlNy DIiQp6gtNLd0TyOcL0IXHdGIvkVXpeE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-uYjD0gVdOImPerf73mdCjg-1; Mon, 30 Sep 2019 10:05:40 -0400 Received: by mail-wr1-f69.google.com with SMTP id i10so4560991wrb.20 for ; Mon, 30 Sep 2019 07:05:40 -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 g4sm16654854wrw.9.2019.09.30.07.05.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Sep 2019 07:05:37 -0700 (PDT) Subject: Re: [PATCH 3/8] Introduce gdb-specific %p format suffixes To: Tom Tromey , gdb-patches@sourceware.org References: <20190927212520.20073-1-tom@tromey.com> <20190927212520.20073-4-tom@tromey.com> From: Pedro Alves Message-ID: Date: Mon, 30 Sep 2019 14:06:00 -0000 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: <20190927212520.20073-4-tom@tromey.com> X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2019-09/txt/msg00607.txt.bz2 Hi, I noticed a coupled typos while reading this, probably mine... On 9/27/19 10:25 PM, Tom Tromey wrote: > +/* The possible kinds of fields. */ > +enum class field_kind > + { > + SIGNED, > + STRING, > + }; > + > +/* An int field, to be passed to %pF in format strings. */ This should read something like: /* The base type of all fields. */ > + > +struct base_field_s > +{ > + const char *name; > + field_kind kind; > +}; > + > +/* An int field, to be passed to %pF in format strings. */ This used to be called int_field_s, before the 'uiout->field_int -> uiout->field_signed' rename. Should now read: /* A signed integer field, to be passed to %pF in format strings. */ > + > +struct signed_field_s : base_field_s > +{ > + LONGEST val; > +}; > + > +/* Construct a temporary signed_field_s on the caller's stack and > + return a pointer to the constructed object. We use this because > + it's not possible to pass a reference via va_args. */ > + > +static inline signed_field_s * > +signed_field (const char *name, LONGEST val, > + signed_field_s &&tmp =3D {}) > +{ > + tmp.name =3D name; > + tmp.kind =3D field_kind::SIGNED; > + tmp.val =3D val; > + return &tmp; > +} > + > +/* A string field, to be passed to %pF in format strings. */ > + > +struct string_field_s : base_field_s > +{ > + const char *str; > +}; > + > +/* Construct a temporary string_field_s on the caller's stack and > + return a pointer to the constructed object. We use this because > + it's not possible to pass a reference via va_args. */ > + > +static inline string_field_s * > +string_field (const char *name, const char *str, > + string_field_s &&tmp =3D {}) > +{ > + tmp.name =3D name; > + tmp.kind =3D field_kind::STRING; > + tmp.str =3D str; > + return &tmp; > +} > + > +/* A styled string. */ > + > +struct styled_string_s > +{ > + /* The style. */ > + ui_file_style style; > + > + /* The string. */ > + const char *str; > +}; > + > +/* Construct a temporary styled_string_s on the caller's stack and > + return a pointer to the constructed object. We use this because > + it's not possible to pass a reference via va_args. */ > + > +static inline styled_string_s * > +styled_string (const ui_file_style &style, const char *str, > + styled_string_s &&tmp =3D {}) > +{ > + tmp.style =3D style; > + tmp.str =3D str; > + return &tmp; > +} > + > class ui_out > { > public: > @@ -110,7 +197,55 @@ class ui_out >=20=20 > void spaces (int numspaces); > void text (const char *string); > + > + /* Output a printf-style formatted string. In addition to the usual > + printf format specs, this supports a few GDB-specific > + formatters: > + > + - '%pF' - output a field. > + > + The argument is a field, wrapped in any of the base_field_s > + subclasses. signed_field for integer fields, styled_field for styled_field -> string_field > + string fields. This is preferred over separate > + uiout->field_int(), uiout_>field_string() etc. calls when the field_int -> field_signed > + formatted message is translatable. E.g.: > + Thanks, Pedro Alves