From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 475 invoked by alias); 10 May 2011 23:42:34 -0000 Received: (qmail 466 invoked by uid 22791); 10 May 2011 23:42:33 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 23:42:20 +0000 Received: from kpbe11.cbf.corp.google.com (kpbe11.cbf.corp.google.com [172.25.105.75]) by smtp-out.google.com with ESMTP id p4ANgHxC030062 for ; Tue, 10 May 2011 16:42:18 -0700 Received: from gwb11 (gwb11.prod.google.com [10.200.2.11]) by kpbe11.cbf.corp.google.com with ESMTP id p4ANfsK3003415 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Tue, 10 May 2011 16:42:16 -0700 Received: by gwb11 with SMTP id 11so3167756gwb.34 for ; Tue, 10 May 2011 16:42:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.91.23.15 with SMTP id a15mr7114930agj.72.1305070936206; Tue, 10 May 2011 16:42:16 -0700 (PDT) Received: by 10.90.72.6 with HTTP; Tue, 10 May 2011 16:42:16 -0700 (PDT) In-Reply-To: References: <0CC3B1C2-DD9F-4A4A-AA07-9E2FC72D6C9D@dell.com> Date: Tue, 10 May 2011 23:42:00 -0000 Message-ID: Subject: Re: teaching gdb about new types? From: Doug Evans To: Richard Silverman Cc: Paul Koning , GDB Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true 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: 2011-05/txt/msg00036.txt.bz2 On Fri, Apr 29, 2011 at 8:02 PM, Richard Silverman wrote: > On Fri, 29 Apr 2011, Paul Koning wrote: > >> If you're worried about types rather than line numbers, I would think th= at >> all you'd need is a symbol table that has the right type definitions in = it. >> =A0If you know what they are supposed to be, you can supply such a symbol >> table easily enough. >> >> =A0 =A0 =A0 =A0paul > > I tried that -- I created a little file: > > ---------------------------------------- > #include > > pthread_cond_t p; > pthread_mutex_t m; > ---------------------------------------- > > ... and built an object from it. =A0However, I can't find a way to get gd= b to > use it while debugging an existing program, that is, to add the type > definitions in that object to its existing set. =A0The commands "symbol-f= ile" > and "add-symbol-file" seem likely candidates, but they don't appear to do > it. I've used add-symbol-file to accomplish exactly this kind of thing. Can you elaborate on what didn't work? Here's a quick example to illustrate. bash$ cat foo.c #include pthread_cond_t p; pthread_mutex_t m; bash$ gcc -g -c foo.c bash$ gdb hello.x [...] (gdb) pty pthread_cond_t No symbol "pthread_cond_t" in current context. (gdb) add-symbol-file foo.o 0 add symbol table from file "foo.o" at .text_addr =3D 0x0 (y or n) y (gdb) pty pthread_cond_t type =3D union { struct { int __lock; unsigned int __futex; long long unsigned int __total_seq; long long unsigned int __wakeup_seq; long long unsigned int __woken_seq; void *__mutex; unsigned int __nwaiters; unsigned int __broadcast_seq; } __data; char __size[48]; long long int __align; } (gdb)