From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24561 invoked by alias); 11 Jan 2010 21:40:53 -0000 Received: (qmail 24537 invoked by uid 22791); 11 Jan 2010 21:40:53 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Jan 2010 21:40:49 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0BLelmC027904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 11 Jan 2010 16:40:47 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0BLek5k016524; Mon, 11 Jan 2010 16:40:46 -0500 Message-ID: <4B4B9ADD.9030200@redhat.com> Date: Mon, 11 Jan 2010 21:40:00 -0000 From: Phil Muldoon User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Lightning/1.0pre Thunderbird/3.0 MIME-Version: 1.0 To: tromey@redhat.com CC: gdb-patches ml Subject: Re: [patch][python] Implement Python lazy strings (PR 10705) References: <4B4746A7.90309@redhat.com> <4B4B9867.5080805@redhat.com> In-Reply-To: <4B4B9867.5080805@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 2010-01/txt/msg00281.txt.bz2 On 01/11/2010 09:30 PM, Phil Muldoon wrote: > On 01/11/2010 09:08 PM, Tom Tromey wrote: >>>>>>> "Phil" == Phil Muldoon writes: >> >> Phil> Index: gdb/varobj.c >> [...] >> Phil> + if (is_lazy_string (output)) >> Phil> + thevalue = extract_lazy_string (output, &type, >> Phil> + &len, &encoding); >> Phil> + else >> Phil> { >> Phil> - char *s = PyString_AsString (py_str); >> Phil> - len = PyString_Size (py_str); >> Phil> - thevalue = xmemdup (s, len + 1, len + 1); >> Phil> - Py_DECREF (py_str); >> Phil> + PyObject *py_str >> Phil> + = python_string_to_target_python_string (output); >> Phil> + if (py_str) >> Phil> + { >> Phil> + char *s = PyString_AsString (py_str); >> Phil> + len = PyString_Size (py_str); >> Phil> + thevalue = xmemdup (s, len + 1, len + 1); >> Phil> + type = builtin_type (gdbarch)->builtin_char; >> Phil> + Py_DECREF (py_str); >> Phil> + } >> Phil> } >> Phil> Py_DECREF (output); >> Phil> } >> Phil> if (thevalue && !string_print) >> Phil> { >> Phil> do_cleanups (back_to); >> Phil> + xfree (encoding); >> Phil> return thevalue; >> >> This is wrong in the lazy string case, because you are returning raw >> bytes, but the user expects them to be interpreted according to the >> encoding. >> >> We discussed this on irc and I thought the result was that we agreed >> that in this case we would pretend that a "string" hint was given. > > We did. This case is slightly different case from original case we > discussed in irc (the original was in the non-mi case). Anyway, if > thevalue is not NULL (and in these cases it won't) it is printed via > LA_PRINT_STRING (just a few lines further past this patch hunk) and > the encoding happens at that point. Oops I spotted the bug just after I sent this. Everything will work if only string_print is set properly for lazy strings ;) (which you mentioned ;). Ok, sorry for the noise, I'll set that hint.