From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19481 invoked by alias); 5 Feb 2008 06:01:52 -0000 Received: (qmail 19472 invoked by uid 22791); 5 Feb 2008 06:01:52 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 05 Feb 2008 06:01:16 +0000 Received: from kahikatea.snap.net.nz (136.62.255.123.dynamic.snap.net.nz [123.255.62.136]) by viper.snap.net.nz (Postfix) with ESMTP id 978C83DA0C1 for ; Tue, 5 Feb 2008 19:01:13 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id A3EC18FC6D; Tue, 5 Feb 2008 19:01:02 +1300 (NZDT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18343.64413.689019.489727@kahikatea.snap.net.nz> Date: Tue, 05 Feb 2008 06:01:00 -0000 To: gdb@sourceware.org Subject: Variable objects and STL containers X-Mailer: VM 7.19 under Emacs 22.1.50.23 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: 2008-02/txt/msg00015.txt.bz2 Using variable objects, if I display a watch expression for an STL container, e.g. vector v (3); v[0] = 1; v[1] = 11; v[2] = 22; in Emacs, I get something like this: v std::vector > std::_Vector_base > std::_Vector_base > public _M_impl std::_Vector_base >::_Vector_impl std::allocator std::allocator __gnu_cxx::new_allocator {...} public _M_start int * 0x804c008 *_M_start 0 _M_finish int * 0x804c014 *_M_finish 135153 _M_end_of_storage int * 0x804c014 *_M_end_of_storage 135153 which is a bit meaningless to the end user. This is for gcc, and I guess other compilers store STL containers differently. In this case, I know where the values are really stored: v._M_impl._M_start int * 0x804c008 *v._M_impl._M_start 1 *(v._M_impl._M_start+1) 11 *(v._M_impl._M_start+2) 22 (gdb) p v._M_impl._M_finish - v._M_impl._M_start $1 = 3 and it would be better to display these. I have two questions: 1) Does GDB know what compiler was used to create an object file/executable? 2) _M_impl, _M_start are gcc internals and I guess they could change (like CLI!) Is it meaningful to ask on the gcc list for a formal interface to these details? -- Nick http://www.inet.net.nz/~nickrob