From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32515 invoked by alias); 18 Jun 2007 08:53:18 -0000 Received: (qmail 32504 invoked by uid 22791); 18 Jun 2007 08:53:17 -0000 X-Spam-Check-By: sourceware.org Received: from konig.cs.elte.hu (HELO konig.cs.elte.hu) (157.181.226.9) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 18 Jun 2007 08:53:14 +0000 Received: from lime.cs.elte.hu ([157.181.227.196] helo=[127.0.0.1]) by konig.cs.elte.hu with esmtp (Exim 4.54) id 1I0Cyy-0007xL-2l; Mon, 18 Jun 2007 10:53:10 +0200 Subject: Re: how to view content in stl vector From: =?ISO-8859-1?Q?Alp=E1r_J=FCttner?= To: Mark Kettenis Cc: kdsfinger@gmail.com, gdb@sourceware.org In-Reply-To: <200706151952.l5FJq2B7009679@brahms.sibelius.xs4all.nl> References: <200706151952.l5FJq2B7009679@brahms.sibelius.xs4all.nl> Content-Type: text/plain Date: Mon, 18 Jun 2007 08:53:00 -0000 Message-Id: <1182156720.4609.31.camel@mikro.mikro> Mime-Version: 1.0 X-Mailer: Evolution 2.8.2 Content-Transfer-Encoding: 7bit X-CS-Spam-Score: -4.6 (----) X-CS-Spam-Report: score=-4.6 required=5.0 tests=ALL_TRUSTED,BAYES_00,CS_MAT2 pts rule name description ---- ---------------------- ------------------------------------ -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP -0.2 CS_MAT2 BODY: mat. kifejezesek -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 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: 2007-06/txt/msg00135.txt.bz2 In a running On Fri, 2007-06-15 at 21:52 +0200, Mark Kettenis wrote: > > Date: Tue, 12 Jun 2007 11:05:21 -0400 > > From: kdsfinger@gmail.com > > > > hi, all > > How may I view the content in a stl vector in ddd? (or the command to > > print it in gdb?). It seems I can only view the first element. I > > searched google but did not find answer. Thanks for help. You can simply use the member functions and operators of std::vector<> in the p[rint] gdb command. For example: (gdb) p v.size() $1 = 8 (gdb) p v[2] $2 = (double &) @0x804c048: 12 This works perfectly provided that * optimization is turned off and debugging (-ggdb) is turned on, * operator[] (or any other query function you would like to use) is used at least once in the code, thus its code is put in the executable, * you debug a running process, not a core dump. > I generally consider C++ code to be undebuggable. I wouldn't say that. It is at least as well debuggable as a C code. (Debugging any non-trivial data structure in C is also very cumbersome). The only major difficulty I frequently encounter is that debugging of the STL header files cannot be turned off. Regards, Alpar