...
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 |
---|
void MyFunc(){
BAS_FUNCTION(MyFunc);
// blah
} |
For inspecting variables you can use BAS_VAR for one variable, BAS_VAR2 for two, BAS_VAR3 for three and so on:
| ||
void APPfunctionAPPmyFunction(int Number, const char* pString, int StringLength, bool Flag){ BAS_VARFUNCTION(NumberAPPmyFunction); BARBAS_VAR(pStringNumber); // print one number BAS_VAR2(Number, pStringFlag); } |
For hexdumps you will need to use BAS_HEX with a label, a pointer to the data and it’s length:
Code Block | ||
---|---|---|
| ||
void APPfunction(const char* pData, int Size, const BASstring& String){ // print two variables BAS_TRC("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.