Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
#include <BAS/BAStrace.h>
BAS_TRACE_INIT;

The for functions you want to trace useHere’s an example of tracing one function:

Code Block
languagecpp
void MyFuncAPPmyFunction(){int Number, const  BAS_FUNCTION(MyFunc);
   // blah
}

For methods, so that you get the this pointer. You need to use BAS_METHOD macro:

Code Block
APPfoo::~APPfoo(char* pString, int StringLength, bool Flag){
   BAS_METHOD(APPfoo::~APPfooFUNCTION(APPmyFunction);
}
 void APPfoo::run(const BASstring& Value, int Count){
   BAS_METHOD(APPfoo::runVAR(Number);    // ....
}

For inspecting variables you can use BAS_VAR for one variable, BAS_VAR2 for two, BAS_VAR3 for three and so on:

Code Block
void APPfunction(int Number, const char* pString){
   BAS_VAR(Numberprint one number
   BAS_VAR2(Number, Flag);  //  BAR_VAR(pString);print two variables
   BAS_VAR2TRC(Number, pString);
}

For hexdumps you will need to use BAS_HEX with a label, a pointer to the data and it’s length:

Code Block
languagecpp
void APPfunction(const char* pData, int Size, const BASstring& String){"This function is just for demonstration: " << Flag); 
   BAS_HEX("String Data", pDatapString, SizeStringLength);
   // do Forsome stringsstuff
we can use the data and size methods.
   BAS_HEX("String Data", String.data(), String.size()); 
}

...

}

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.