This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: teaching gdb about new types?
- From: Doug Evans <dje at google dot com>
- To: Richard Silverman <res at qoxp dot net>
- Cc: Paul Koning <paul_koning at dell dot com>, GDB Mailing List <gdb at sourceware dot org>
- Date: Tue, 10 May 2011 16:42:16 -0700
- Subject: Re: teaching gdb about new types?
- References: <alpine.DEB.1.10.1104291428590.11634@seraph.oankali.net> <C3277526-BD9A-4710-9717-5857BD6C3262@dell.com> <alpine.DEB.1.10.1104291638510.11634@seraph.oankali.net> <0CC3B1C2-DD9F-4A4A-AA07-9E2FC72D6C9D@dell.com> <alpine.OSX.2.01.1104292254280.1166@darwin.oankali.net>
On Fri, Apr 29, 2011 at 8:02 PM, Richard Silverman <res@qoxp.net> wrote:
> On Fri, 29 Apr 2011, Paul Koning wrote:
>
>> If you're worried about types rather than line numbers, I would think that
>> all you'd need is a symbol table that has the right type definitions in it.
>> ?If you know what they are supposed to be, you can supply such a symbol
>> table easily enough.
>>
>> ? ? ? ?paul
>
> I tried that -- I created a little file:
>
> ----------------------------------------
> #include <pthreads.h>
>
> pthread_cond_t p;
> pthread_mutex_t m;
> ----------------------------------------
>
> ... and built an object from it. ?However, I can't find a way to get gdb to
> use it while debugging an existing program, that is, to add the type
> definitions in that object to its existing set. ?The commands "symbol-file"
> 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.h>
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 = 0x0
(y or n) y
(gdb) pty pthread_cond_t
type = 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)