From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11628 invoked by alias); 9 Apr 2009 15:19:39 -0000 Received: (qmail 11364 invoked by uid 22791); 9 Apr 2009 15:19:37 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Apr 2009 15:19:29 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n39FJOfD012262; Thu, 9 Apr 2009 11:19:25 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n39FJNUA031530; Thu, 9 Apr 2009 11:19:23 -0400 Received: from localhost.localdomain (vpn-6-49.fab.redhat.com [10.33.6.49]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n39FJKtl025059; Thu, 9 Apr 2009 11:19:21 -0400 Message-ID: <49DE11F7.9000501@redhat.com> Date: Thu, 09 Apr 2009 15:19:00 -0000 From: Phil Muldoon User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: Thiago Jung Bauermann CC: Tom Tromey , gdb-patches ml Subject: Re: Python pretty-printing [5/6] References: <1238863179.3236.134.camel@localhost.localdomain> <1239289186.30578.18.camel@localhost.localdomain> In-Reply-To: <1239289186.30578.18.camel@localhost.localdomain> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes 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 X-SW-Source: 2009-04/txt/msg00174.txt.bz2 Thiago Jung Bauermann wrote: > El mié, 08-04-2009 a las 18:52 -0600, Tom Tromey escribió: > >> I looked again and I don't see how it can return NULL without setting >> the exception. Can you point it out to me? >> > > I found one potential problem, which could cause the function to return > NULL without an exception being set (it's not the case I thought of > before, I think): suppose there's no objfile Python object when this > function is called, to the ALL_OBJFILES loop will skip all objs, then > the gdb module has no pretty_printers attribute, or the pretty_printers > value is not a list object. In that case, the function will return NULL > without a Python exception being set. Can it happen? > > This would require the gdb.pretty_printers attribute in the code to be changed from a list to something else (or removed for the not existing scenario). Anyway it would require a conscious code change on behalf of another author, and not an environmental change. It could happen if somebody changed the code, but I suspect (in this scenario) it would fail long before it reached here. > Also, I noticed that the function may return Py_None if no > pretty-printer is found, and the callers even expect that. The function > comment needs to be fixed then: > > /* Find the pretty-printing constructor function for TYPE. If no > pretty-printer exists, return NULL. If one exists, return a new > reference. */ > > Yes, my fault. Missed this :( >> Thiago> Because of this, pretty_print_one_value can now probably just call >> Thiago> convert_value_from_python and return a struct value in all cases and be >> Thiago> done with it. Either this function should be changed to work that way, >> Thiago> or the comment above removed. >> >> I made the minimal change here. I don't want to refactor this right >> now; Phil is in the middle of doing that for the embedded \0 problem. >> We can apply his fix separately; the current code is not ideal, due to >> this problem, but it is still usable for a variety of printers. >> > > Fine with me. > > I'm in the middle of this right now. I'm putting the finishing touches on the optional string fetch parameter from the comments posted to the archer list, and will start work on fixing string output. Regards Phil