Re: source code transform

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Berg <johannes@xxxxxxxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux