FireBirdLib - Topfield TMS PVR TAP Programming Library
CallTraceExit.c
Go to the documentation of this file.
1
#include "
FBLib_debug.h
"
2
3
void
CallTraceExit
(dword *Magic)
4
{
5
char
Spaces[101];
6
int
i, j;
7
dword t;
8
extern
dword
__tap_ud__
;
9
10
if
(
CallTraceDoNotReenter
)
return
;
11
CallTraceDoNotReenter
= TRUE;
12
13
t = TAP_GetTick();
14
15
if
(!
CallTraceInitialized
)
CallTraceInit
();
16
17
Spaces[0] =
'\0'
;
18
19
if
(
CallLevel
> 0)
20
{
21
CallLevel
--;
22
23
if
(
CallTraceStats
&&
CallLevel
<
CTSTACKSIZE
)
24
{
25
//Check if the proc name is already known by the stats array
26
j = -1;
27
for
(i = 0; i <
CallTraceStatsEntries
; i++)
28
if
(
CallTraceStats
[i].ProcName ==
CallTraceStack
[
CallLevel
].ProcName)
29
{
30
j = i;
31
break
;
32
}
33
34
//If not, use the next free entry
35
if
(j == -1) j =
CallTraceStatsEntries
;
36
37
//Add the stats
38
if
(j <
CTSTATENTRIES
)
39
{
40
i = t -
CallTraceStack
[
CallLevel
].
EntryTime
;
41
if
(
CallTraceStats
[j].ProcName)
42
{
43
//Already known
44
if
((dword)i <
CallTraceStats
[j].MinTime)
CallTraceStats
[j].
MinTime
= i;
45
if
((dword)i >
CallTraceStats
[j].MaxTime)
CallTraceStats
[j].
MaxTime
= i;
46
CallTraceStats
[j].
TotalTime
+= i;
47
if
(
CallTraceStats
[j].NrCalls < 0xffffffff)
48
{
49
CallTraceStats
[j].
TotalTime
+= i;
50
CallTraceStats
[j].
NrCalls
++;
51
}
52
}
53
else
54
{
55
//New procedure
56
CallTraceStats
[j].
ProcName
=
CallTraceStack
[
CallLevel
].
ProcName
;
57
CallTraceStats
[j].
MinTime
= i;
58
CallTraceStats
[j].
MaxTime
= i;
59
CallTraceStats
[j].
TotalTime
= i;
60
CallTraceStats
[j].
NrCalls
= 1;
61
CallTraceStatsEntries
++;
62
}
63
}
64
}
65
}
66
else
67
LogEntryFBLibPrintf
(TRUE,
"CallLevel Underflow! (TAPID 0x%8.8lx)"
,
__tap_ud__
);
68
69
if
(
CallTraceEnabled
|| Magic)
70
{
71
memset(Spaces,
' '
,
CallLevel
<
CTSTACKSIZE
?
CallLevel
<< 1 : 100);
72
Spaces[
CallLevel
<
CTSTACKSIZE
?
CallLevel
<< 1 : 100] =
'\0'
;
73
}
74
75
if
(Magic && *Magic !=
DEFAULTMAGIC
)
76
{
77
TAP_Print
(
"%sINVALID MAGIC!\n"
, Spaces);
78
*Magic =
DEFAULTMAGIC
;
79
}
80
81
CallTraceDoNotReenter
= FALSE;
82
}
CallTraceExit
void CallTraceExit(dword *Magic)
Definition:
CallTraceExit.c:3
CallTraceStack
tCallTraceStack CallTraceStack[CTSTACKSIZE]
Definition:
CallTraceInit.c:4
CallTraceInitialized
bool CallTraceInitialized
Definition:
CallTraceInit.c:6
CallLevel
dword CallLevel
Definition:
CallTraceInit.c:3
CallTraceStatsEntries
int CallTraceStatsEntries
Definition:
CallTraceInit.c:8
CallTraceStats
tCallTraceStats * CallTraceStats
Definition:
CallTraceInit.c:7
CallTraceEnabled
bool CallTraceEnabled
Definition:
CallTraceInit.c:5
CallTraceDoNotReenter
bool CallTraceDoNotReenter
Definition:
CallTraceInit.c:9
CallTraceInit
void CallTraceInit(void)
Definition:
CallTraceInit.c:11
FBLib_debug.h
DEFAULTMAGIC
#define DEFAULTMAGIC
Definition:
FBLib_debug.h:6
CTSTATENTRIES
#define CTSTATENTRIES
Definition:
FBLib_debug.h:8
CTSTACKSIZE
#define CTSTACKSIZE
Definition:
FBLib_debug.h:7
__tap_ud__
const dword __tap_ud__
LogEntryFBLibPrintf
void LogEntryFBLibPrintf(bool Console, char *format,...)
Definition:
LogEntryFBLibPrintf.c:13
TAP_Print
#define TAP_Print
Definition:
libFireBird.h:181
tCallTraceStack::ProcName
char * ProcName
Definition:
FBLib_debug.h:22
tCallTraceStack::EntryTime
dword EntryTime
Definition:
FBLib_debug.h:23
tCallTraceStats::TotalTime
dword TotalTime
Definition:
FBLib_debug.h:17
tCallTraceStats::MaxTime
dword MaxTime
Definition:
FBLib_debug.h:15
tCallTraceStats::NrCalls
dword NrCalls
Definition:
FBLib_debug.h:16
tCallTraceStats::ProcName
char * ProcName
Definition:
FBLib_debug.h:13
tCallTraceStats::MinTime
dword MinTime
Definition:
FBLib_debug.h:14
debug
CallTraceExit.c
Generated on Fri Apr 29 2022 13:34:01 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3