All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Reshetova, Elena" <elena.reshetova@intel.com>
Cc: "smatch@vger.kernel.org" <smatch@vger.kernel.org>
Subject: Re: BKM on generating a call graph for smatch warnings
Date: Mon, 13 Sep 2021 18:09:33 +0300	[thread overview]
Message-ID: <20210913150933.GL7203@kadam> (raw)
In-Reply-To: <DM8PR11MB5701267BE5A0824EFAEC54B2E7FE9@DM8PR11MB5701.namprd11.prod.outlook.com>

Hi,

I'm really sorry, I missed your email.  I was on vacation that week and
didn't see your email until now.

On Tue, Aug 17, 2021 at 07:32:21AM +0000, Reshetova, Elena wrote:
> Hi, 
> 
> Quick question: are there some suggested methods for obtaining a call graph
> for a warning that a smatch pattern reports when I run it for the whole kernel? 
> 
> I can see that there are a couple of existing patterns (check_capable, check_locking)
> that use sql methods for saving the caller_info, but I don't fully understand how it
> works, maybe there is some description somewhere on this that I missed? 

How the Smatch cross function database works is that you run:

	/path/to/smatch/smatch_scripts/build_kernel_data.sh

This takes a long time to run.  It does a complete Smatch run and it
outputs a ton of SQL insert commands.  Then it does:

	cat sql.txt | sqlite3 smatch_db.sqlite

It doesn't literally cat that because that would be very slow.  It's
uses a perl script to handle transactions, caching and syncing etc.
There is also a little bit of tweaking for some of the tables.  The
final database on my system is 30GB.

What I do is I rebuild my database every night.  Each time you rebuild
the database then the knowledge about the call tree gets pushed out one
call further.

In my experience if you rebuild the DB 5-7 times, that's basically
the limit.  The call tree is complete, of course, right away.  foo()
calls bar() calls baz().  But it takes two rebuilds before the user
data from foo() gets to baz().

The /path/to/smatch/smatch_data/db/smdb.py script is a way to see what's
stored in the database.  `smdb.py foo` will print all the callers of
foo() and `smdb.py return_states foo` will show what it returns.

Again, very sorry for the long delay.  Please let me know if you have
any questions.

regards,
dan carpenter

  reply	other threads:[~2021-09-13 15:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17  7:32 BKM on generating a call graph for smatch warnings Reshetova, Elena
2021-09-13 15:09 ` Dan Carpenter [this message]
2021-09-14  6:06   ` Reshetova, Elena

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=20210913150933.GL7203@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=elena.reshetova@intel.com \
    --cc=smatch@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.