linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* building of call tree
@ 2010-04-02 16:16 Sergey Lapin
  2010-04-02 17:55 ` Christopher Li
  0 siblings, 1 reply; 2+ messages in thread
From: Sergey Lapin @ 2010-04-02 16:16 UTC (permalink / raw)
  To: linux-sparse

Hi, all!

I'd like to make call-tree builder using libsparse.
I need to build symbol-hierarchy and feed dot with it.
I use test-dissect.c as an example.

I understand how to extract the symbols and find if it is definition
or reference,
but I fail with scoping. I need to detect which function that
particular reference belongs to,
and how to detect if that reference is really a function.
sym->type isn't what I need, sym->ctype.base_type is used to print base type,
but I'd like to print type as is, and detect if that is a function a proper way.
Or is there any better way to get this information?

Thanks a lot,
S.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: building of call tree
  2010-04-02 16:16 building of call tree Sergey Lapin
@ 2010-04-02 17:55 ` Christopher Li
  0 siblings, 0 replies; 2+ messages in thread
From: Christopher Li @ 2010-04-02 17:55 UTC (permalink / raw)
  To: Sergey Lapin; +Cc: linux-sparse

On Fri, Apr 2, 2010 at 9:16 AM, Sergey Lapin <slapinid@gmail.com> wrote:
> but I fail with scoping. I need to detect which function that
> particular reference belongs to,
> and how to detect if that reference is really a function.

What do you mean by "reference"? If you mean the struct symbol *
in the AST. It can point to the function prototype or declaration. It is easy to
find out the symbol is a function or not.

Some thing along the lines of :

if (sym->type == SYM_NODE)
    sym = sym->ctype.base_type
if (sym && sym->type = SYM_FN) {
    /* sym is a function */
}


> sym->type isn't what I need, sym->ctype.base_type is used to print base type,
> but I'd like to print type as is, and detect if that is a function a proper way.

You need understand that, each local variable or function start with a SYM_NODE.
SYM_NODE bind a type to a instance of the type. e.g. a variable.
A function is just a SYM_NODE with base type as SYM_FN.

You can also try debug_symbol(), see how it print out the function prototype.

I am about to post a AST inspection patch series. That tool should
help you understand
the AST as well. Stay tuned.

Chris

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-02 17:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-02 16:16 building of call tree Sergey Lapin
2010-04-02 17:55 ` Christopher Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).