[antlr-interest] Re: code instrumentation with Monty's C grammar

lgcraymer lgc at mail1.jpl.nasa.gov
Thu Dec 4 11:58:35 PST 2003


Daniel--

Take a look at ANTLR's semantic and syntactic predicates.  The semantic predicates will be useful to identify the functions to be 
ignored, while syntactic predicates can be used to identify the automatically generated if statements.  Mostly, you will need to 
duplicate existing rules or alternatives, insert actions in one of the duplicates, and add predicates to determine which version to 
invoke.  You may want to add an intermediate tree transformation step to insert the instrumentation function calls before invoking the 
emitter, or you may modify the emitter to identify the special cases.

--Loring

--- In antlr-interest at yahoogroups.com, "daniel_raichle" <daniel.raichle at e...> wrote:
> Hi All,
> 
> I have to do C-code instrumentation to measure the decision coverage
> of a software. I think Monty's C-grammar is the right thing for me. I
> think I could do the instrumentation with some changes in the
> GnuCEmitter.g file, eg. I could change the rule in the grammar where
> the if-clause is printed. 
> 
> Example:
> // Selection statements:
>         |       #( i:"if"    { print( i ); print( "(" ); }
>                  expr        { print( ")" ); print("{ counter++; "); }
>                 statement    { print("}");}
>                 (  e:"else"  { print( e ); print( "(" ); }
>                    statement { print("}");}
>                 )?
>                 )
> 
> But I have one big problem: I must not instrument all the functions
> and all the if-statements in the software. There are some functions
> with a special function name (eg. _L1_...) that should not be
> instrumented. And there are some special if-statements with
> automatically generated code that prevents from divisions by 0. 
> Is it possible to check for the functionname or the content of the
> if-expression before instrumenting the if-statement? What do I have to
> change? Can you please give me an example?!
> 
> Thank you very much!
> 
> P.S.: Sorry for my bad English!


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list