Instrumentation pragmas

The Runtime Tracing feature allows the user to add special directives to the source code under test, known as instrumentation pragma directives. When the source code is instrumented, the Instrumentor replaces instrumentation pragma directives with dedicated code.

Usage

#pragma attol <pragma name> <directive>

Example

int f ( int a )

{

#pragma attol att_insert if ( a == 0 ) _ATT_DUMP_STACK

return a;

}

This code will be replaced, after instrumentation, with the following line:

/*#pragma attol att_insert*/ if ( a == 0 ) _ATT_DUMP_STACK

Note Pragma directives are implemented only if the routine in which it is used is instrumented.

Instrumentation Pragma Names

#pragma attol insert <directive> 

This code must be replaced with the following instrumentation if any of Code Coverage, Runtime Tracing, Memory Profiling or Performance Profiling is/are selected:

/*#pragma attol insert*/ <directive>

#pragma attol atc_insert <directive> 

This code must be replaced with the following instrumentation if Code Coverage is selected:

/*#pragma attol atc_insert*/ <directive>

#pragma attol att_insert <directive>
This code must be replaced with the following instrumentation if Runtime Tracing is selected:

/*#pragma attol att_insert*/ <directive>

#pragma attol atp_insert <directive>

This code must be replaced with the following instrumentation if Memory Profiling is selected.

/*#pragma attol atp_insert*/ <directive>

#pragma attol atq_insert <directive>
This code must be replaced with the following instrumentation if Performance Profiling is selected.

/*#pragma attol atq_insert*/ <directive>

#pragma attol type_boolean= <myType>
For Code Coverage, this code declares the variable type <myType> as a Boolean for MC/DC coverage of bit-wise operations.

#pragma attol type_modifier= <keyword
This pragma indicates a specific type modifier to the parser. For example:

#pragma attol type_modifier = __far

#pragma attol type_modifier = __pascal

will analyze silently :

int __pascal func ( int ) { /* ... */ }

char __far *pointer;

#pragma attol stop_analyze #pragma attol start_analyze
#pragma attol stop_instr #pragma attol start_instr
These pragmas can be used to start and stop analysis or instrumentation.

Stopping analysis also stops instrumentation. Starting instrumentation also starts analysis.

#pragma attol rename_local_var = <FuncName>:<localVarName> 

This pragma allows the user to change the declaration name of the local variable named <localVarName> into the method <FuncName> in the source code. This instrumentation pragma directive can be used in a test to get access to the <localVarName> variable.

In the following example, the prama is used to change the name of the local declaration var 'tata' into the translate method. The following code that uses this variable will search for an external variable method instead of the local one.

#pragma attol rename_local_var = translate:tata

int Point::translate(void)

{

static int tata=4;

return tata++; //

tata is a local variable that cannot be modified or read outside the method

becomes

int Point::translate(void)

{

static int _atu_stub_tata=4;

return tata++; //

This 'tata' variable is now a global variable that can be created from the test driver script.

#pragma attol cov_justify <directive>

This pragma allows the user to add a justification statement for non-coverage of a branch of code.

For more details on the directives, see Justification of non-covered lines of code.

As this branch of code is covered, the code coverage percentage is computed. The coverage report highlights the branch in blue. The justification is displayed in the coverage viewer when you hover over this branch with your mouse.

If this branch is covered, an error is reported in the coverage report.

Code Review Directives

In some cases, it can be useful to temporarily ignore a rule non-conformance on a short portion of source code, while providing a justification of why you are allowing the non-conformance.

#pragma attol crc_justify (<rule>[,<lines>],"<text>")

This macro justifies a deviation on the first non-conformance to a rule that follows the pragma, where:

<rule> is the name of the code review rule (for example: "Rule M8.5").

<lines> is the optional number of lines (including blank lines), after the current pragma line, that are covered by the deviation. The default value is 1 meaning that the deviation only applies to the next line. Specify the 'all' value to apply the deviation to all lines until the end of the file.

<text> is the justification of why the deviation applies here.

#pragma attol crc_justify_all (<rule>,<lines>,"<text>")

This macro justifies all non-conformance instances to a rule that follows the pragma statement, where:

<rule> is the name of the code review rule (for example: "Rule M8.5").

<lines> is the number of lines (mandatory)

<text> is the justification of why the rule is ignored here.

#pragma attol crc_justify_everywhere (<rule>[,<lines>],"<text>")

This macro justifies all non-conformance instances to a rule for all source files in the current project, including if they are located before the pragma statement, where:

<rule> is the name of the code review rule (for example: "Rule M8.5").

<lines> is an ignored parameter.

<text> is the justification of why the rule is ignored here.

The recommended usage for crc_justify_everywhere is to create a specific source file containing only the list of pragma statements and to add this file to the project.

Code Coverage, Memory Profiling and Performance Profiling Directives

The following macros must be used only with Memory Profiling and Performance Profiling.

_ATCPQ_DUMP(<reset>)

where <reset> can be one or more of the following values:

  • _ATCPQ_COV to dump coverage results.
  • _ATCPQ_RESET_COV to reset the coverage status after the dump.
  • _ATCPQ_QTF to dump performance results.
  • _ATCPQ_RESET_QTF to reset the performance status after the dump.
  • _ATCPQ_FREE_FRQ to free all old memory blocks after the dump.
  • _ATCPQ_PRF to dump memory profiling results.
  • _ATCPQ_CHK_WL to dump ABWL and FMWL results.
  • _ATCPQ_ALL to dump everything.

By default, _ATCPQ_RESET is set to _ATCPQ_ALL but can be redefined with a compilation command. Values of 0 or 1 are equivalent to _ATCPQ_ALL.

_ATCPQ_CLOSE closes the result file at the end of the requested dump so that an open action can be done on the next result dump using the runtime priv_open method.

_ATCPQ_DUMP can be automatically inserted by clicking the Insert Dump button in the Text Editor toolbar.

_ATP_CHECK(@REFLINE)

This macro indicates a manual dump point in the source code for checking for ADWL or FMWL errors when using Memory Profiling. The corresponding setting must be selected.

The @REFLINE parameter is mandatory.

_ATP_TRACK(<pointer>)

This macro adds <pointer> to a list of selected memory blocks to check for ABWL or FMWL errors. A manual dump point in the source code is used for checking for ADWL or FMWL errors when using Memory Profiling.

Runtime Tracing Directives

When using this mode, the Target Deployment Package only sends messages related to an instance creation and destruction, or user notes. All other events are ignored. See Partial message dump for more information about this feature.

_ATT_START_DUMP

_ATT_STOP_DUMP

These directives enable and disable the partial message dump mode.

_ATT_TOGGLE_DUMP

This directive toggles the dump mode on and off. _ATT_TOGGLE_DUMP can be used instead of _ATT_START_DUMP and _ATT_STOP_DUMP.

_ATT_DUMP_STACK

When invoked, this directive dumps the contents of the call stack at that moment.

_ATT_FLUSH_ITEMS

When entered in Target Deployment Package buffer mode, this directive flushes the buffer. All buffered trace information is dumped. Flushing the buffer is useful before entering a time-critical phase of the trace.

_ATT_USER_NOTE( <text> )

This directive associates a text note to the function or method instance. <text> is a user-specified alphanumeric string containing the note text of type char*. The length of <text> must be within the maximum note length specified in the Runtime Tracing Settings dialog box. This pragma statement can be automatically inserted by clicking the Add Note button in the Text Editor toolbar.