How do you use tracing?

Tracing can only be done inside the body of a cpp file. It requires C++, so it won’t work on pure C files.

You need to include BAS/BAStrace.h and invoke the BAS_TRACE_INIT macro:

#include <BAS/BAStrace.h> BAS_TRACE_INIT;

Here’s an example of tracing one function:

void APPmyFunction(int Number, const char* pString, int StringLength, bool Flag){ BAS_FUNCTION(APPmyFunction); BAS_VAR(Number); // print one number BAS_VAR2(Number, Flag); // print two variables BAS_TRC("This function is just for demonstration: " << Flag); BAS_HEX("String Data", pString, StringLength); // do some stuff }

This is what we are using:

  • BAS_FUNCTION to show entry and exit from the function - the argument is the just the name supplied, see flow of calls and values of variables

  • BAS_VAR, BAS_VAR2, BAS_VAR3 etc display variables in Name=Value pairs

  • BAS_TRC is like a general print statement to print whatever you want.

  • BAS_HEX will output a hex dump of the data given, pass in a label, pointer to the data and the length. See hexdumps.

That’s it.

I have found it extremely easy to train development teams to use tracing. It’s very straightforward.

Â