From: Gary Funck <gary@intrepid.com>
To: GDB List <gdb@sources.redhat.com>
Cc: Daniel Jacobowitz <drow@false.org>
Subject: Re: how to search for a global type?
Date: Wed, 02 Jan 2008 17:46:00 -0000 [thread overview]
Message-ID: <20080102174158.GH30197@intrepid.com> (raw)
In-Reply-To: <20080102130630.GA31874@caradoc.them.org>
On 01/02/08 08:06:30, Daniel Jacobowitz wrote:
> On Tue, Jan 01, 2008 at 09:16:26PM -0800, Gary Funck wrote:
> > The typedef appears to be in inner block. Does that make it static?
>
> Block 0 is the global symbols; block 1 is the file static symbols.
> Later blocks are the bodies of functions, et cetera.
>
> It makes sense for types to be static if you think about it from the
> right perspective, since types do not (generally) have linker
> visibility; the linker can't patch up your code to reference a type
> declared in another file.
>
> In short, try just lookup_symbol?
I did try lookup_symbol() as well, no go.
I'm currently using this approach:
static
int
lookup_type_by_name (const char *type_name)
{
const struct symbol *sym;
const struct type *type;
int type_id;
struct symbol_search *matches;
/* FIXME: add ^$ anchors to front/back of type_name, so
that the regex matches only the desired type name. */
search_symbols ((char *)type_name, TYPES_DOMAIN,
0 /* nfiles */, NULL /* files */, &matches);
if (!matches)
return 0;
/* Arbitrarily use the first match. */
sym = matches->symbol;
free_search_symbols (matches);
type_id = get_type_id (SYMBOL_TYPE (sym));
return type_id;
}
Search_symbols() finds the type definition that we're interested in.
I think one difficulty is that the current file doesn't
define the type. It is defined in the runtime files.
I haven't tried following the logic, but could you briefly
explain the raltionship between block vectors and symbol
tables?
thanks,
- Gary
next prev parent reply other threads:[~2008-01-02 17:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-31 4:28 Gary Funck
2008-01-02 3:18 ` Daniel Jacobowitz
2008-01-02 5:16 ` Gary Funck
2008-01-02 13:12 ` Daniel Jacobowitz
2008-01-02 17:46 ` Gary Funck [this message]
2008-01-02 18:02 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080102174158.GH30197@intrepid.com \
--to=gary@intrepid.com \
--cc=drow@false.org \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox