Message ID | 20180712205208.32646-8-tom@tromey.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 57014 invoked by alias); 12 Jul 2018 20:52:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 56796 invoked by uid 89); 12 Jul 2018 20:52:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1104 X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.228) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jul 2018 20:52:34 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 24893400C95D1 for <gdb-patches@sourceware.org>; Thu, 12 Jul 2018 15:52:31 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id diZRfRGXzaSeydiZbf4E2B; Thu, 12 Jul 2018 15:52:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=A8tTL5fcg1aFKh7JYA1jeO8iH45oh2xeZoqR17wKaB4=; b=kf7p3vF2Y8Otmbq5pzgv5wtqjs lJkXVu3u9ot1MhAxSnb2HL9IvkeTapFGM6FrboGvWJSRiSFlju2015vHnlZ4b87C7c7Lf8+HtNrsC RXvQlmkLl2a056dpyjRF2yqSe; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:49432 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from <tom@tromey.com>) id 1fdiZQ-001ZuD-Mn; Thu, 12 Jul 2018 15:52:12 -0500 From: Tom Tromey <tom@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey <tom@tromey.com> Subject: [RFA 07/13] Remove unused declaration from py-prettyprint.c Date: Thu, 12 Jul 2018 14:52:02 -0600 Message-Id: <20180712205208.32646-8-tom@tromey.com> In-Reply-To: <20180712205208.32646-1-tom@tromey.com> References: <20180712205208.32646-1-tom@tromey.com> |
Commit Message
Tom Tromey
July 12, 2018, 8:52 p.m. UTC
This removes an unused declaration from py-prettyprint.c, but leaves the call to value_contents_for_printing, as it may throw. 2018-07-12 Tom Tromey <tom@tromey.com> * python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Call value_contents_for_printing for effect. --- gdb/ChangeLog | 5 +++++ gdb/python/py-prettyprint.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-)
Comments
On 2018-07-12 04:52 PM, Tom Tromey wrote: > This removes an unused declaration from py-prettyprint.c, but leaves > the call to value_contents_for_printing, as it may throw.> > 2018-07-12 Tom Tromey <tom@tromey.com> > > * python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Call > value_contents_for_printing for effect. > --- > gdb/ChangeLog | 5 +++++ > gdb/python/py-prettyprint.c | 4 +++- > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c > index 21b1ce94879..bfcbc95178e 100644 > --- a/gdb/python/py-prettyprint.c > +++ b/gdb/python/py-prettyprint.c > @@ -662,7 +662,9 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, > struct gdbarch *gdbarch = get_type_arch (type); > struct value *value; > enum string_repr_result print_result; > - const gdb_byte *valaddr = value_contents_for_printing (val); > + > + /* Call for side effects. */ > + value_contents_for_printing (val); > > /* No pretty-printer support for unavailable values. */ > if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type))) > Also LGTM. However, since both extension languages call value_contents_for_printing (from what I understand, to ensure the value has been fetched/is not lazy) and bail if some bytes are unavailable, perhaps apply_ext_lang_val_pretty_printer should do it instead. Also, doing if (value->lazy) value_fetch_lazy (value); would communicate better the intent than calling value_contents_for_printing for the same side-effect. Simon
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> Also LGTM. However, since both extension languages call value_contents_for_printing
Simon> (from what I understand, to ensure the value has been fetched/is not lazy) and bail
Simon> if some bytes are unavailable, perhaps apply_ext_lang_val_pretty_printer should
Simon> do it instead.
It seems possible that someday we'd want to expose unavailable bytes via
the Python Value API.
Simon> Also, doing
Simon> if (value->lazy)
Simon> value_fetch_lazy (value);
Simon> would communicate better the intent than calling value_contents_for_printing for the
Simon> same side-effect.
True, but then this is exposed to other possible changes in the value API.
Tom
On 07/14/2018 01:39 PM, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes: > > Simon> Also LGTM. However, since both extension languages call value_contents_for_printing > Simon> (from what I understand, to ensure the value has been fetched/is not lazy) and bail > Simon> if some bytes are unavailable, perhaps apply_ext_lang_val_pretty_printer should > Simon> do it instead. > > It seems possible that someday we'd want to expose unavailable bytes via > the Python Value API. Right, but that's not an issue if we morph the call to a direct value_fetch_lazy call instead, AFAICS. > > Simon> Also, doing > > Simon> if (value->lazy) > Simon> value_fetch_lazy (value); > > Simon> would communicate better the intent than calling value_contents_for_printing for the > Simon> same side-effect. Right, what I was saying too in the guile patch. > > True, but then this is exposed to other possible changes in the value API. I don't see how using value_contents_for_printing instead helps with that? Thanks, Pedro Alves
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 21b1ce94879..bfcbc95178e 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -662,7 +662,9 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, struct gdbarch *gdbarch = get_type_arch (type); struct value *value; enum string_repr_result print_result; - const gdb_byte *valaddr = value_contents_for_printing (val); + + /* Call for side effects. */ + value_contents_for_printing (val); /* No pretty-printer support for unavailable values. */ if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))