Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mbe-tools
TTool
Commits
7b278bc0
Commit
7b278bc0
authored
13 years ago
by
Ludovic Apvrille
Browse files
Options
Downloads
Patches
Plain Diff
AVATAR:new tracing facilities
parent
27e32f30
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
executablecode/src/tracemanager.c
+152
-0
152 additions, 0 deletions
executablecode/src/tracemanager.c
executablecode/src/tracemanager.h
+14
-0
14 additions, 0 deletions
executablecode/src/tracemanager.h
with
166 additions
and
0 deletions
executablecode/src/tracemanager.c
0 → 100644
+
152
−
0
View file @
7b278bc0
#include
<stdlib.h>
#include
<stdio.h>
#include
<time.h>
#include
"tracemanager.h"
#include
"debug.h"
#include
"mytimelib.h"
#define TRACE_OFF 0
#define TRACE_IN_FILE 1
#define TRACE_FILE_NAME "Trace.txt"
//pthread_mutex_t traceMutex;
//pthread_cond_t wakeupTraceManager;
int
trace
=
TRACE_OFF
;
int
id
=
0
;
FILE
*
file
;
struct
timespec
begints
;
void
addInfo
(
char
*
dest
,
char
*
info
)
{
char
s1
[
10
];
long
tmp
;
long
tmp1
;
int
i
;
struct
timespec
ts
,
ts1
;
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
debugMsg
(
"DIFF TIME"
);
diffTime
(
&
begints
,
&
ts
,
&
ts1
);
tmp
=
ts1
.
tv_nsec
;
if
(
tmp
<
0
)
{
tmp
=
-
tmp
;
}
tmp1
=
100000000
;
for
(
i
=
0
;
i
<
9
;
i
++
)
{
s1
[
i
]
=
48
+
(
tmp
/
tmp1
);
tmp
=
tmp
%
tmp1
;
tmp1
=
tmp1
/
10
;
}
s1
[
9
]
=
'\0'
;
sprintf
(
dest
,
"#%d @%ld.%s %s"
,
id
,
ts1
.
tv_sec
,
s1
,
info
);
id
++
;
}
void
writeInTrace
(
char
*
info
)
{
char
s
[
1024
];
addInfo
(
s
,
info
);
//printf("Write in file\n");
if
(
file
!=
NULL
)
{
debug2Msg
(
"Saving in file"
,
s
);
fprintf
(
file
,
s
);
fflush
(
file
);
}
}
void
activeTracingInFile
(
char
*
fileName
)
{
char
*
name
;
trace
=
TRACE_IN_FILE
;
clock_gettime
(
CLOCK_REALTIME
,
&
begints
);
if
(
fileName
==
NULL
)
{
name
=
TRACE_FILE_NAME
;
}
else
{
name
=
fileName
;
}
file
=
fopen
(
name
,
"w"
);
}
void
unactiveTracing
()
{
trace
=
TRACE_OFF
;
}
void
traceStateEntering
(
char
*
myname
,
char
*
statename
)
{
char
s
[
1024
];
debugMsg
(
"Trace function"
);
if
(
trace
==
TRACE_OFF
)
{
return
;
}
sprintf
(
s
,
"#block=%s type=state_entering state=%s
\n
"
,
myname
,
statename
);
// Saving trace
writeInTrace
(
s
);
}
void
traceFunctionCall
(
char
*
block
,
char
*
func
)
{
char
s
[
1024
];
debugMsg
(
"Trace function"
);
if
(
trace
==
TRACE_OFF
)
{
return
;
}
sprintf
(
s
,
"block=%s type=function_call func=%s
\n
"
,
block
,
func
);
// Saving trace
writeInTrace
(
s
);
}
void
traceRequest
(
char
*
myname
,
request
*
req
)
{
char
s
[
1024
];
debugMsg
(
"Trace request"
);
if
(
trace
==
TRACE_OFF
)
{
return
;
}
// Build corresponding char*;
switch
(
req
->
type
)
{
case
SEND_SYNC_REQUEST
:
debug2Msg
(
"Sync channel"
,
req
->
syncChannel
->
outname
);
sprintf
(
s
,
"block=%s type=send_synchro channel=%s
\n
"
,
myname
,
req
->
syncChannel
->
outname
);
break
;
case
RECEIVE_SYNC_REQUEST
:
sprintf
(
s
,
"block=%s type=receive_synchro channel=%s
\n
"
,
myname
,
req
->
syncChannel
->
inname
);
break
;
case
IMMEDIATE
:
sprintf
(
s
,
"block=%s type=action
\n
"
,
myname
);
break
;
default:
sprintf
(
s
,
"block=%s type=unknown
\n
"
,
myname
);
}
debugMsg
(
"Trace request 2"
);
// Saving trace
writeInTrace
(
s
);
}
This diff is collapsed.
Click to expand it.
executablecode/src/tracemanager.h
0 → 100644
+
14
−
0
View file @
7b278bc0
#ifndef TRACEMANAGER_H
#define TRACEMANANER_H
#include
"request.h"
void
activeTracingInFile
();
void
unactiveTracing
();
void
traceRequest
(
char
*
myname
,
request
*
req
);
void
traceFunctionCall
(
char
*
block
,
char
*
func
);
void
traceStateEntering
(
char
*
myname
,
char
*
statename
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment