From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17023 invoked by alias); 14 Oct 2010 18:30:03 -0000 Received: (qmail 16920 invoked by uid 22791); 14 Oct 2010 18:30:01 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_GD,TW_SM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.nokia.com (HELO mgw-mx03.nokia.com) (192.100.122.230) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Oct 2010 18:29:55 +0000 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o9EITO6T015735; Thu, 14 Oct 2010 21:29:37 +0300 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 14 Oct 2010 21:29:29 +0300 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 14 Oct 2010 21:29:28 +0300 Received: from gar.localnet (bettdhcp167127.europe.nokia.com [172.25.167.127]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o9EITQcM025210; Thu, 14 Oct 2010 21:29:26 +0300 From: =?utf-8?q?Andr=C3=A9_P=C3=B6nitz?= To: ext asmwarrior Subject: Re: gdb with python support still get crash on showing uninitialized local variables Date: Thu, 14 Oct 2010 18:30:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.32-21-generic; KDE/4.4.2; i686; ; ) Cc: "pmuldoon@redhat.com" , "tromey@redhat.com" , "gdb@sourceware.org" References: <4CB66700.3000907@gmail.com> In-Reply-To: <4CB66700.3000907@gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201010142029.24092.andre.poenitz@nokia.com> X-Nokia-AV: Clean X-IsSubscribed: yes 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-10/txt/msg00049.txt.bz2 Hi. I'll take that direct CC: to me as a hint that I should comment. Not sure=20 this is a good idea, but here we go: On Thursday 14 October 2010 04:12:16 ext asmwarrior wrote: > Hi, I still get gdb crashed when showing local variables. Here is the > test code: >=20 > OS: windows xp > GDB: clean gdb cvs snapshot weekly 2010 10 12 build with python support > GCC: TDM-MinGW GCC 4.5.1 > so, the program is build with -g (by default, it use the dwarf-2 format, > I have just tested by using -gdwarf-3, there's the same crash) >=20 > it seems gdb crashed when trying to show the vector : > std::vector v =3D {"a", "b", "c"}; , this is an uninitialized > variable. >=20 > Tested under codeblocks IDE Works fine for me using Qt Creator on Linux, gdb 7.1, 7.2 and recent CVS, including (our non-gdb) Python based pretty printing. Output in the Locals&Watchers view is something like Locals=09 l m s <19932 items> stdStr "" stdStrRef v wxStr=09 wxStrRef=09 Watchers=09 Not nice, but it's uninitialized data after all, and a stack could possibly= have=20 19932 items.=20 So I think the problem is neither the uninitialized data, nor Python, nor g= db's use of Python in general. > File "D:\code\mingw451tdm\bin\libstdcxx\v6\printers.py", line 297, in next > if node.dereference()['_M_right']: > RuntimeError: Attempt to dereference a generic pointer. > stdStrRef =3D > s =3D std::stack wrapping: std::deque with -521291805 elements =3D { reading variable s (Cannot access memory at address 0x80)> > wxStr =3D UnicodeEncodeError: 'gbk' codec can't encode character u'\uffff' > in position 0: illegal multibyte sequence > wxStrRef =3D @0x40b9c6 > l =3D std::list =3D { > [0] =3D 0x50000069)> > v =3D std::vector of length -37952, capacity -519864265 =3D {Traceback (m= ost > recent call last): > File "D:\code\mingw451tdm\bin\libstdcxx\v6\printers.py", line 549, in > to_string > return self.val['_M_dataplus']['_M_p'].lazy_string (length =3D len) > RuntimeError: Cannot access memory at address 0x90000cb6 > , Traceback (most recent call last): > File "D:\code\mingw451tdm\bin\libstdcxx\v6\printers.py", line 549, in > to_string > return self.val['_M_dataplus']['_M_p'].lazy_string (length =3D len) > RuntimeError: Cannot access memory at address 0x90909084 > , Traceback (most recent call last): This looks like gdb's own pretty printers could make more use of try/except and perhaps a few sanity checks on the contents. Printing "std::vector of length -37952" does not make much sense. Andre' PS: > andr's post in QT site > http://labs.qt.nokia.com/2009/06/22/peek-and-poke/#comment-4269 >=20 > It=E2=80=99s =E2=80=9Cnot ready=E2=80=9D yet. The gdb python =E2=80=9Cpre= tty-printers=E2=80=9D have serious > problems with uninitialized and/or damaged C++ objects. I understand > work to fix that is going on, but from my point of view it is not ready > for shipping yet. That's over a year old, and has significantly changed in so far as Qt Creat= or nowadays uses gdb's Python extensively to do pretty printing. Since 7.0.1 this is really good and usable. However, I do not use the gdb version of the pretty printers for the stability reason you just encountered, and because = they cannot (easily...) create several layers including possibly "virtual" ones = that do not correspond to actual objects on the inferior side. [And then there a= re non-gdb related reasons, like that I need a C++ version of the same code for Apple's gdb/Mac (no Python there) and CDB on Windows (completely different beast) and it's easier to keep that in sync if it's structurally similar]