We can see the sequence and depth of calls. From the sandbox for instance:
Code Block |
---|
./test --trace "APP*" --out "trace.log" |
Will give us this in the trace.log:
Code Block |
---|
|
T 1710:5824:0530.843859683662 0x1107d25c00x1087f75c0 mainAPPfactorial >main >APPfactorial Line:2310
T 1710:5824:0530.844466684335 0x1107d25c00x1087f75c0 main APPfactorial . GoingN to= call6
APPlocalFunction T 1710:5824:0530.844501684372 0x1107d25c0 main 0x1087f75c0 APPfactorial . >APPlocalFunction>APPfactorial Line:1210
T 1710:5824:0530.844549684423 0x1107d25c0 main 0x1087f75c0 APPfactorial . . AboutN to= print hello world...
T 17:58:05.844590 0x1107d25c0 main 5
10:24:30.684458 0x1087f75c0 APPfactorial . . Printed>APPfactorial helloLine:10
world! T 1710:5824:0530.844625684509 0x1107d25c00x1087f75c0 mainAPPfactorial . . . N = 4
. <APPlocalFunction
T 17:58:05.844666 0x1107d25c0 main 10:24:30.684545 0x1087f75c0 APPfactorial . Creating Foo object
T 17:58:05.844701 0x1107d25c0 APPfoo . >APPfoo::APPfoo>APPfactorial Line:10
this=0x7ffee9b9d7d0 T 1710:5824:0530.844756684595 0x1107d25c00x1087f75c0 APPfooAPPfactorial . . <APPfoo::APPfoo T 17:58:05.844798 0x1107d25c0 main . AboutN to= call3
run on Foo
T 17:58:05.844832 0x1107d25c0 APPfoo10:24:30.684631 0x1087f75c0 APPfactorial . . . . >APPfoo::run>APPfactorial Line:1710
this=0x7ffee9b9d7d0 T 1710:5824:0530.844889684682 0x1107d25c00x1087f75c0 APPfooAPPfactorial . . . . . ValueN = Rabbit,2
Count = 5
T 17:58:05.844924 0x1107d25c0 APPfoo10:24:30.684718 0x1087f75c0 APPfactorial . . . . . i>APPfactorial =Line:10
0 T 1710:5824:0530.844960684768 0x1107d25c00x1087f75c0 APPfooAPPfactorial . . . . . . iN = 1
T 1710:5824:0530.844995684806 0x1107d25c00x1087f75c0 APPfooAPPfactorial . . . . . . iEnding =recursion
2 T 1710:5824:0530.845029684843 0x1107d25c00x1087f75c0 APPfooAPPfactorial . . . . . i<APPfactorial
= 3 T 1710:5824:0530.845064684887 0x1107d25c00x1087f75c0 APPfooAPPfactorial . . . . . iResult = 42
T 1710:5824:0530.845104684923 0x1107d25c00x1087f75c0 APPfooAPPfactorial . . . . Dump= (size=35)
<APPfactorial
10:24:30.684966 0x1087f75c0 APPfactorial . . . . Result = 6
10:24:30.685002 0x1087f75c0 APPfactorial . . . <APPfactorial
10:24:30.685045 0x1087f75c0 APPfactorial . . 52. 61Result 62= 6224
69 74 0A 52 Rabb it.R
10:24:30.685081 0x1087f75c0 APPfactorial . . <APPfactorial
10:24:30.685124 0x1087f75c0 APPfactorial 61 62 62 69 74 0A 52 61 abbi t.Ra
62 62 69 74 0A 52 61 62 bbit .Rab
. . Result = 120
10:24:30.685173 0x1087f75c0 APPfactorial 62 69 74 0A 52 61 62 62 bit. Rabb<APPfactorial
69 74 0A it.
T 17:58:05.845140 0x1107d25c0 APPfoo10:24:30.685212 0x1087f75c0 APPfactorial . Result = 720
. <APPfoo10::run
T 17:58:05.845182 0x1107d25c0 main24:30.685244 0x1087f75c0 APPfactorial . All done!
T 17:58:05.845217 0x1107d25c0 APPfoo . >APPfoo::~APPfoo Line:13 this=0x7ffee9b9d7d0
T 17:58:05.845271 0x1107d25c0 APPfoo <APPfactorial |
We can see the entry into the APPfactorial which is calling itself recursively. Here’s the code:
Code Block |
---|
|
int APPfactorial(int N){
BAS_FUNCTION(APPfactorial);
BAS_VAR(N);
if (N == 1){
BAS_TRC("Ending recursion");
return 1;
. <APPfoo::~APPfoo T 17:58:05.845326 0x1107d25c0 main }
int Result = N * APPfactorial(N-1);
BAS_VAR(Result);
return <mai |
...
The BAS_FUNCTION macro allows us to see when we enter and exit the function. BAS_VAR shows the variable we want to see in Name=Value format in the trace. BAS_TRC is like a print statement in tracing.