how to search for a global type?
Gary Funck
gary@intrepid.com
Mon Dec 31 04:28:00 GMT 2007
To support UPC debugging, we need to be able to look up
runtime information. Case in point, we need to query
the structure of the target's shared pointer representation.
At preent, we're implmenting this query with the following
code (within gdb):
static
int
lookup_type_by_name (const char *type_name)
{
const struct symbol *sym;
const struct type *type;
int type_id;
sym = lookup_symbol_global (type_name, NULL, TYPES_DOMAIN, NULL);
if (!sym)
sym = lookup_symbol_global (type_name, NULL, STRUCT_DOMAIN, NULL);
if (!sym)
return 0;
type_id = get_type_id (SYMBOL_TYPE (sym));
return type_id;
}
This code doesn't find the type in question, in spite of the
fact that GDB has no problem finding the type from the
command line. For example,
(gdb) ptype upc_shared_ptr_t
type = struct shared_ptr_struct {
long unsigned int phase : 48;
short unsigned int thread : 16;
void *vaddr;
}
and
(gdb) info type upc_shared_ptr_t
All types matching regular expression "upc_shared_ptr_t":
File /upc/gcc-upc-4/src/libupc/smp/upc_access.c:
typedef shared_ptr_struct upc_shared_ptr_t;
File /upc/gcc-upc-4/src/libupc/smp/upc_barrier.c:
typedef shared_ptr_struct upc_shared_ptr_t;
[...]
I've added some simple debugging output to
lookup_symbol_global, to confirm that it is being
called with the expected parameters:
lookup_symbol_global(upc_shared_ptr_t, NULL, 6, NULL) called.
lookup_symbol_global(upc_shared_ptr_t, NULL, 2, NULL) called.
In both cases, the type can't be found.
What's the recommended way to perform this type lookup?
Thanks,
- Gary
configuration: x86_64, FC5, dwarf2 debugging info.
More information about the Gdb
mailing list