From: "Dan Carpenter" <error27@gmail.com>
To: Michael Stefaniuc <mstefani@redhat.com>
Cc: smatch-discuss@lists.sourceforge.net, linux-sparse@vger.kernel.org
Subject: Re: Moving smatch to use sparse
Date: Fri, 6 Oct 2006 01:57:06 -0700 [thread overview]
Message-ID: <a63d67fe0610060157g117228fambc77363513a464d9@mail.gmail.com> (raw)
In-Reply-To: <45258B4B.6010907@redhat.com>
Sparse reads the source and creates a parse tree. At the base, are
function symbols, the function has a bunch statements and the
statements have a bunch of expressions which branch out into even more
expressions. If you have data that's a symbol.
struct expression is defined in expression.h
struct symbol is defined in symbol.h
struct statement is in parse.h
The important functions are:
set_state(name, my_id, sym, ISNULL);
get_state(deref, my_id, sym)
set_true_false_states(left, my_id, sym_left, ISNULL, NONNULL);
add_hook(&match_assign, ASSIGNMENT_HOOK);
void register_your_check(int id)
left = get_variable_from_expr(expr->left, &sym_left);
left = alloc_string(left);
my_id is a different int for every check script.
sym is a symbol * to the sparse symbol.
The condition hook feeds you one condition at a time.
add_hook() sets up a call back that will be called for every
assignment in this case.
add the register_your_check() to smatch.c.
get_variable_from_expr() is a bit buggy still but it's supposed to
give a string representation of an expression and it also gives you a
symbol pointer. If you want to keep the string instead of just
printing it out or using it for get_state() then you have to call
alloc_string().
I haven't added setting up custom merge_rules yet. Will do.
Internally smatch_states are a struct. I'm going to add some more
fields to that so it might be useful to have a get_state_struct()
function...
smatch_flow.c interprets that sparse tree. If you want to add another
hook that's the place to do it.
That's pretty much it.
regards,
dan carpenter
prev parent reply other threads:[~2006-10-06 8:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a63d67fe0607140925h3665cd98ibc2fab07f6f80360@mail.gmail.com>
2006-07-16 0:42 ` Moving smatch to use sparse Dan Carpenter
2006-10-05 8:41 ` Dan Carpenter
2006-10-05 9:26 ` Sam Ravnborg
2006-10-05 9:49 ` Dan Carpenter
2006-10-05 10:25 ` Jörn Engel
2006-10-06 6:31 ` Dan Carpenter
2006-10-05 15:52 ` Michael Stefaniuc
2006-10-05 20:58 ` Dan Carpenter
2006-10-05 22:46 ` Michael Stefaniuc
2006-10-06 8:57 ` Dan Carpenter [this message]
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=a63d67fe0610060157g117228fambc77363513a464d9@mail.gmail.com \
--to=error27@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=mstefani@redhat.com \
--cc=smatch-discuss@lists.sourceforge.net \
/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;
as well as URLs for NNTP newsgroup(s).