From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2090 invoked by alias); 9 Mar 2010 10:29:47 -0000 Received: (qmail 2079 invoked by uid 22791); 9 Mar 2010 10:29:46 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp.nokia.com (HELO mgw-mx06.nokia.com) (192.100.122.233) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Mar 2010 10:29:38 +0000 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o29ATWC4003310 for ; Tue, 9 Mar 2010 12:29:34 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 9 Mar 2010 12:29:28 +0200 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 9 Mar 2010 12:29:26 +0200 Received: from gar.localnet (berwst16747.europe.nokia.com [172.25.167.47]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o29ATOLj000672 for ; Tue, 9 Mar 2010 12:29:24 +0200 From: =?iso-8859-1?q?Andr=E9_P=F6nitz?= To: gdb@sourceware.org Subject: Re: Printing of strings with special characters Date: Tue, 09 Mar 2010 10:29:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-19-generic; KDE/4.3.2; i686; ; ) References: <4B8F9FE9.2040401@technosis.de> <4B94BC31.3020109@technosis.de> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201003091129.56867.andre.poenitz@nokia.com> X-Nokia-AV: Clean Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00056.txt.bz2 On Monday 08 March 2010 20:41:00 Tom Tromey wrote: > >>>>> "Anton" == Anton Kunze writes: > > Anton> http://websvn.kde.org/trunk/extragear/sdk/kdevelop/debuggers/gdb/printers/ > > Also, the QStringPrinter code seems suspect to me: > > class QStringPrinter: > > def __init__(self, val): > self.val = val > > def to_string(self): > ret = "" > i = 0 > while i < self.val['d']['size']: > if self.val['d']['data'][i] > 256: > #TODO: fix this properly > ret += '?' > else: > ret += chr(self.val['d']['data'][i]) > i = i + 1 > return ret > > This is constructing a string by hand, and using '?' to replace some > characters. > > It is better to use Value.string or Value.lazy_string. From the > qstring.h in code search, I gather that this is UTF-16-encoded, so this > should probably read: > > return self.val['d']['data'].string(encoding = 'UTF-16', length = self.val['d']['size']) I think I tried something like that when I started to use gdb/python and it did not really work for corrupted data (like uninitialized objects or "real" corruption). At least I ended up transferring the raw data to the frontend and let that decide on how to present it. Andre'