Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-RAN
Commits
5dec2748
Commit
5dec2748
authored
May 20, 2016
by
Cedric Roux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a basic VCD plotter
parent
f38476ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
248 additions
and
9 deletions
+248
-9
common/utils/T/tracer/Makefile
common/utils/T/tracer/Makefile
+1
-3
common/utils/T/tracer/Makefile.remote
common/utils/T/tracer/Makefile.remote
+7
-6
common/utils/T/tracer/vcd.c
common/utils/T/tracer/vcd.c
+240
-0
No files found.
common/utils/T/tracer/Makefile
View file @
5dec2748
...
...
@@ -4,9 +4,7 @@ local:
make
-f
Makefile.local
remote
:
make
-f
Makefile.remote
make
-f
Makefile.remote textlog
make
-f
Makefile.remote enb
make
-f
Makefile.remote tracer_remote textlog enb vcd
clean
:
make
-f
Makefile.local clean
...
...
common/utils/T/tracer/Makefile.remote
View file @
5dec2748
...
...
@@ -5,11 +5,8 @@ CFLAGS=-Wall -g -pthread -DT_TRACER -I.
LIBS
=
-lX11
-lm
PROG
=
tracer_remote
OBJS
=
remote_old.o plot.o database.o gui.o utils.o
$(PROG)
:
gui/gui.a $(OBJS)
$(CC)
$(CFLAGS)
-o
$(PROG)
$(OBJS)
gui/gui.a
$(LIBS)
tracer_remote
:
remote_old.o plot.o database.o gui.o utils.o gui/gui.a
$(CC)
$(CFLAGS)
-o
tracer_remote
$^
$(LIBS)
textlog
:
utils.o textlog.o database.o event.o handler.o
\
event_selector.o view/view.a gui/gui.a logger/logger.a
...
...
@@ -19,6 +16,10 @@ enb: utils.o enb.o database.o event.o handler.o \
event_selector.o view/view.a gui/gui.a logger/logger.a
$(CC)
$(CFLAGS)
-o
enb
$^
$(LIBS)
vcd
:
utils.o vcd.o database.o event.o handler.o
\
event_selector.o view/view.a gui/gui.a logger/logger.a
$(CC)
$(CFLAGS)
-o
vcd
$^
$(LIBS)
.PHONY
:
gui/gui.a view/view.a logger/logger.a
gui/gui.a
:
...
...
@@ -34,7 +35,7 @@ logger/logger.a:
$(CC)
$(CFLAGS)
-c
-o
$@
$<
clean
:
rm
-f
*
.o
$(PROG)
core textlog
rm
-f
*
.o
core tracer_remote textlog enb vcd
cd
gui
&&
make clean
cd
view
&&
make clean
cd
logger
&&
make clean
common/utils/T/tracer/vcd.c
0 → 100644
View file @
5dec2748
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include "database.h"
#include "event.h"
#include "handler.h"
#include "logger/logger.h"
#include "view/view.h"
#include "gui/gui.h"
#include "utils.h"
#include "../T_defs.h"
#include "event_selector.h"
#define DEFAULT_REMOTE_PORT 2021
int
get_connection
(
char
*
addr
,
int
port
)
{
struct
sockaddr_in
a
;
socklen_t
alen
;
int
s
,
t
;
printf
(
"waiting for connection on %s:%d
\n
"
,
addr
,
port
);
s
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
s
==
-
1
)
{
perror
(
"socket"
);
exit
(
1
);
}
t
=
1
;
if
(
setsockopt
(
s
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
t
,
sizeof
(
int
)))
{
perror
(
"setsockopt"
);
exit
(
1
);
}
a
.
sin_family
=
AF_INET
;
a
.
sin_port
=
htons
(
port
);
a
.
sin_addr
.
s_addr
=
inet_addr
(
addr
);
if
(
bind
(
s
,
(
struct
sockaddr
*
)
&
a
,
sizeof
(
a
)))
{
perror
(
"bind"
);
exit
(
1
);
}
if
(
listen
(
s
,
5
))
{
perror
(
"bind"
);
exit
(
1
);
}
alen
=
sizeof
(
a
);
t
=
accept
(
s
,
(
struct
sockaddr
*
)
&
a
,
&
alen
);
if
(
t
==
-
1
)
{
perror
(
"accept"
);
exit
(
1
);
}
close
(
s
);
printf
(
"connected
\n
"
);
return
t
;
}
void
usage
(
void
)
{
printf
(
"options:
\n
"
" -d <database file> this option is mandatory
\n
"
" -on <GROUP or ID> turn log ON for given GROUP or ID
\n
"
" -off <GROUP or ID> turn log OFF for given GROUP or ID
\n
"
" -ON turn all logs ON
\n
"
" -OFF turn all logs OFF
\n
"
" note: you may pass several -on/-off/-ON/-OFF,
\n
"
" they will be processed in order
\n
"
" by default, all is off
\n
"
" -p <port> use given port (default %d)
\n
"
" -debug-gui activate GUI debug logs
\n
"
,
DEFAULT_REMOTE_PORT
);
exit
(
1
);
}
int
fullread
(
int
fd
,
void
*
_buf
,
int
count
)
{
char
*
buf
=
_buf
;
int
ret
=
0
;
int
l
;
while
(
count
)
{
l
=
read
(
fd
,
buf
,
count
);
if
(
l
<=
0
)
{
printf
(
"read socket problem
\n
"
);
abort
();
}
count
-=
l
;
buf
+=
l
;
ret
+=
l
;
}
return
ret
;
}
event
get_event
(
int
s
,
char
*
v
,
void
*
d
)
{
#ifdef T_SEND_TIME
struct
timespec
t
;
#endif
int
type
;
int32_t
length
;
fullread
(
s
,
&
length
,
4
);
#ifdef T_SEND_TIME
fullread
(
s
,
&
t
,
sizeof
(
struct
timespec
));
length
-=
sizeof
(
struct
timespec
);
#endif
fullread
(
s
,
&
type
,
sizeof
(
int
));
length
-=
sizeof
(
int
);
fullread
(
s
,
v
,
length
);
#ifdef T_SEND_TIME
return
new_event
(
t
,
type
,
length
,
v
,
d
);
#else
return
new_event
(
type
,
length
,
v
,
d
);
#endif
}
static
void
*
gui_thread
(
void
*
_g
)
{
gui
*
g
=
_g
;
gui_loop
(
g
);
return
NULL
;
}
static
void
vcd_main_gui
(
gui
*
g
,
event_handler
*
h
,
void
*
database
,
int
*
is_on
)
{
int
i
,
j
;
int
n
;
int
nb_functions
=
0
;
char
**
ids
;
widget
*
win
;
widget
*
container
;
widget
*
w
;
view
*
timeview
;
view
*
subview
;
logger
*
timelog
;
/* get number of vcd functions - look for all events VCD_FUNCTION_xxx */
n
=
database_get_ids
(
database
,
&
ids
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
if
(
strncmp
(
ids
[
i
],
"VCD_FUNCTION_"
,
13
)
!=
0
)
continue
;
nb_functions
++
;
}
win
=
new_toplevel_window
(
g
,
1000
,
5
*
nb_functions
,
"VCD tracer"
);
container
=
new_container
(
g
,
VERTICAL
);
widget_add_child
(
g
,
win
,
container
,
-
1
);
w
=
new_timeline
(
g
,
1000
,
nb_functions
,
5
);
widget_add_child
(
g
,
container
,
w
,
-
1
);
for
(
i
=
0
;
i
<
nb_functions
;
i
++
)
timeline_set_subline_background_color
(
g
,
w
,
i
,
new_color
(
g
,
i
&
1
?
"#ddd"
:
"#eee"
));
timeview
=
new_view_time
(
3600
,
10
,
g
,
w
);
i
=
0
;
for
(
j
=
0
;
j
<
n
;
j
++
)
{
if
(
strncmp
(
ids
[
j
],
"VCD_FUNCTION_"
,
13
)
!=
0
)
continue
;
on_off
(
database
,
ids
[
j
],
is_on
,
1
);
timelog
=
new_timelog
(
h
,
database
,
ids
[
j
]);
subview
=
new_subview_time
(
timeview
,
i
,
FOREGROUND_COLOR
,
3600
*
1000
);
logger_add_view
(
timelog
,
subview
);
i
++
;
}
free
(
ids
);
}
int
main
(
int
n
,
char
**
v
)
{
extern
int
volatile
gui_logd
;
char
*
database_filename
=
NULL
;
void
*
database
;
int
port
=
DEFAULT_REMOTE_PORT
;
char
**
on_off_name
;
int
*
on_off_action
;
int
on_off_n
=
0
;
int
*
is_on
;
int
number_of_events
;
int
s
;
int
i
;
char
t
;
int
l
;
event_handler
*
h
;
gui
*
g
;
on_off_name
=
malloc
(
n
*
sizeof
(
char
*
));
if
(
on_off_name
==
NULL
)
abort
();
on_off_action
=
malloc
(
n
*
sizeof
(
int
));
if
(
on_off_action
==
NULL
)
abort
();
for
(
i
=
1
;
i
<
n
;
i
++
)
{
if
(
!
strcmp
(
v
[
i
],
"-h"
)
||
!
strcmp
(
v
[
i
],
"--help"
))
usage
();
if
(
!
strcmp
(
v
[
i
],
"-d"
))
{
if
(
i
>
n
-
2
)
usage
();
database_filename
=
v
[
++
i
];
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-p"
))
{
if
(
i
>
n
-
2
)
usage
();
port
=
atoi
(
v
[
++
i
]);
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-on"
))
{
if
(
i
>
n
-
2
)
usage
();
on_off_name
[
on_off_n
]
=
v
[
++
i
];
on_off_action
[
on_off_n
++
]
=
1
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-off"
))
{
if
(
i
>
n
-
2
)
usage
();
on_off_name
[
on_off_n
]
=
v
[
++
i
];
on_off_action
[
on_off_n
++
]
=
0
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-ON"
))
{
on_off_name
[
on_off_n
]
=
NULL
;
on_off_action
[
on_off_n
++
]
=
1
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-OFF"
))
{
on_off_name
[
on_off_n
]
=
NULL
;
on_off_action
[
on_off_n
++
]
=
0
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-debug-gui"
))
{
gui_logd
=
1
;
continue
;
}
usage
();
}
if
(
database_filename
==
NULL
)
{
printf
(
"ERROR: provide a database file (-d)
\n
"
);
exit
(
1
);
}
database
=
parse_database
(
database_filename
);
number_of_events
=
number_of_ids
(
database
);
is_on
=
calloc
(
number_of_events
,
sizeof
(
int
));
if
(
is_on
==
NULL
)
abort
();
h
=
new_handler
(
database
);
g
=
gui_init
();
new_thread
(
gui_thread
,
g
);
vcd_main_gui
(
g
,
h
,
database
,
is_on
);
for
(
i
=
0
;
i
<
on_off_n
;
i
++
)
on_off
(
database
,
on_off_name
[
i
],
is_on
,
on_off_action
[
i
]);
s
=
get_connection
(
"0.0.0.0"
,
port
);
/* send the first message - activate selected traces */
t
=
0
;
if
(
write
(
s
,
&
t
,
1
)
!=
1
)
abort
();
l
=
0
;
for
(
i
=
0
;
i
<
number_of_events
;
i
++
)
if
(
is_on
[
i
])
l
++
;
if
(
write
(
s
,
&
l
,
sizeof
(
int
))
!=
sizeof
(
int
))
abort
();
for
(
l
=
0
;
l
<
number_of_events
;
l
++
)
if
(
is_on
[
l
])
if
(
write
(
s
,
&
l
,
sizeof
(
int
))
!=
sizeof
(
int
))
abort
();
setup_event_selector
(
g
,
database
,
s
,
is_on
);
/* read messages */
while
(
1
)
{
char
v
[
T_BUFFER_MAX
];
event
e
;
e
=
get_event
(
s
,
v
,
database
);
handle_event
(
h
,
e
);
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment