linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yoann Padioleau <padator@wanadoo.fr>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: mosfet <forumer@smartmobili.com>,
	linux-sparse@vger.kernel.org, Julia Lawall <julia@diku.dk>
Subject: Re: source code transform
Date: Thu, 08 Jan 2009 17:45:01 -0600	[thread overview]
Message-ID: <87skntqs5e.fsf@aryx.cs.uiuc.edu> (raw)
In-Reply-To: <1231354996.3545.80.camel@johannes> (Johannes Berg's message of "Wed\, 07 Jan 2009 20\:03\:16 +0100")

Johannes Berg <johannes@sipsolutions.net> writes:

> On Wed, 2009-01-07 at 19:48 +0100, mosfet wrote:
>
>> I would like to know if sparse would be able to parse GCC source file to
>> add a comment in each function it encounters ?
>> For instance let's say I want to trace every function in c-parser.c :
>> 
>> 
>> static struct c_typespec
>> c_parser_enum_specifier (c_parser *parser)
>> {
>> ...
>> 
>> }
>> 
>> in a first step I would like to modify source code like this :
>> 
>> static struct c_typespec
>> c_parser_enum_specifier (c_parser *parser)
>> {
>>  fprintf(stderr, "c-parser.c: c_parser_enum_specifier()\n");
>> ...
>> 
>> }
>> 
>> is it possible with sparse ?
>
> Not sure, but spatch might be able to:
>
> http://www.emn.fr/x-info/coccinelle/

Yes it can. Just write this semantic patch: 

@@
identifier f;
@@

 f(...)
 { 
+ fprintf(stderr, "%s: %s()\n", __FILE__, __FUNCTION__);
 ...
 }


into a file such as instrument_tracing.cocci and then run spatch with 


 $ ./spatch -c instrument_tracing.cocci c-parser.c -o c-parser-instrumented.c



>
> johannes

  parent reply	other threads:[~2009-01-09  0:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-07 18:48 source code transform mosfet
2009-01-07 19:03 ` Johannes Berg
2009-01-08  7:52   ` Nicholas Mc Guire
2009-01-08 23:45   ` Yoann Padioleau [this message]
2009-01-09  0:38     ` Harvey Harrison
2009-01-09 17:06       ` Yoann Padioleau
2009-01-31 23:37         ` H. Peter Anvin

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=87skntqs5e.fsf@aryx.cs.uiuc.edu \
    --to=padator@wanadoo.fr \
    --cc=forumer@smartmobili.com \
    --cc=johannes@sipsolutions.net \
    --cc=julia@diku.dk \
    --cc=linux-sparse@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 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).