T tracer: textlog: remove GUI code
textlog is, well, text log. The GUI part is totally useless. Let's remove it.
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
add_library(tracer_utils OBJECT configuration.c database.c event.c handler.c utils.c)
|
add_library(tracer_utils OBJECT configuration.c database.c event.c handler.c utils.c)
|
||||||
target_link_libraries(tracer_utils PUBLIC m pthread)
|
target_link_libraries(tracer_utils PUBLIC m pthread)
|
||||||
|
|
||||||
add_library(tracer_events OBJECT event_selector.c)
|
|
||||||
|
|
||||||
add_executable(record record.c)
|
add_executable(record record.c)
|
||||||
target_link_libraries(record PRIVATE tracer_utils)
|
target_link_libraries(record PRIVATE tracer_utils)
|
||||||
|
|
||||||
@@ -28,10 +26,19 @@ add_executable(multi multi.c)
|
|||||||
target_link_libraries(multi PRIVATE tracer_utils T)
|
target_link_libraries(multi PRIVATE tracer_utils T)
|
||||||
target_include_directories(multi PRIVATE ..)
|
target_include_directories(multi PRIVATE ..)
|
||||||
|
|
||||||
|
add_executable(textlog textlog.c)
|
||||||
|
target_link_libraries(textlog PRIVATE tracer_utils tracer_filter
|
||||||
|
tracer_logger tracer_view)
|
||||||
|
|
||||||
|
add_subdirectory(filter)
|
||||||
|
add_subdirectory(logger)
|
||||||
|
add_subdirectory(view)
|
||||||
|
|
||||||
add_custom_target(T_tools)
|
add_custom_target(T_tools)
|
||||||
add_dependencies(T_tools
|
add_dependencies(T_tools
|
||||||
record replay extract_config extract_input_subframe
|
record replay extract_config extract_input_subframe
|
||||||
extract_output_subframe extract macpdu2wireshark multi)
|
extract_output_subframe extract macpdu2wireshark multi
|
||||||
|
textlog)
|
||||||
add_dependencies(nr-softmodem T_tools)
|
add_dependencies(nr-softmodem T_tools)
|
||||||
add_dependencies(nr-uesoftmodem T_tools)
|
add_dependencies(nr-uesoftmodem T_tools)
|
||||||
add_dependencies(lte-softmodem T_tools)
|
add_dependencies(lte-softmodem T_tools)
|
||||||
@@ -42,9 +49,7 @@ add_dependencies(lte-uesoftmodem T_tools)
|
|||||||
# GUI-related tools so they can be added on demand, if necessary.
|
# GUI-related tools so they can be added on demand, if necessary.
|
||||||
add_boolean_option(T_TRACER_GUI OFF "Compile T tracer GUI tools" OFF)
|
add_boolean_option(T_TRACER_GUI OFF "Compile T tracer GUI tools" OFF)
|
||||||
if(T_TRACER_GUI)
|
if(T_TRACER_GUI)
|
||||||
add_executable(textlog textlog.c)
|
add_library(tracer_events OBJECT event_selector.c)
|
||||||
target_link_libraries(textlog PRIVATE tracer_utils tracer_filter tracer_gui
|
|
||||||
tracer_logger tracer_view tracer_events)
|
|
||||||
|
|
||||||
find_library(png png REQUIRED)
|
find_library(png png REQUIRED)
|
||||||
add_executable(enb enb.c)
|
add_executable(enb enb.c)
|
||||||
@@ -71,9 +76,6 @@ if(T_TRACER_GUI)
|
|||||||
tracer_logger tracer_view tracer_events)
|
tracer_logger tracer_view tracer_events)
|
||||||
|
|
||||||
add_subdirectory(gui)
|
add_subdirectory(gui)
|
||||||
add_subdirectory(filter)
|
|
||||||
add_subdirectory(logger)
|
|
||||||
add_subdirectory(view)
|
|
||||||
|
|
||||||
add_dependencies(T_tools textlog enb gnb ue vcd to_vcd)
|
add_dependencies(T_tools enb gnb ue vcd to_vcd)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -31,9 +31,8 @@ extract: extract.o database.o event.o utils.o configuration.o
|
|||||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||||
|
|
||||||
textlog: utils.o textlog.o database.o event.o handler.o configuration.o \
|
textlog: utils.o textlog.o database.o event.o handler.o configuration.o \
|
||||||
event_selector.o view/view.a gui/gui.a logger/logger.a \
|
view/view.a logger/logger.a filter/filter.a
|
||||||
filter/filter.a
|
$(CC) $(CFLAGS) -o textlog $^ $(LIBS)
|
||||||
$(CC) $(CFLAGS) -o textlog $^ $(LIBS) $(XLIBS)
|
|
||||||
|
|
||||||
enb: utils.o enb.o database.o event.o handler.o configuration.o \
|
enb: utils.o enb.o database.o event.o handler.o configuration.o \
|
||||||
event_selector.o view/view.a gui/gui.a logger/logger.a \
|
event_selector.o view/view.a gui/gui.a logger/logger.a \
|
||||||
|
|||||||
@@ -1,42 +1,24 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "handler.h"
|
#include "handler.h"
|
||||||
#include "logger/logger.h"
|
#include "logger/logger.h"
|
||||||
#include "view/view.h"
|
#include "view/view.h"
|
||||||
#include "gui/gui.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "event_selector.h"
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
typedef struct {
|
void activate_traces(int socket, int *is_on, int nevents)
|
||||||
int socket;
|
|
||||||
int *is_on;
|
|
||||||
int nevents;
|
|
||||||
pthread_mutex_t lock;
|
|
||||||
} textlog_data;
|
|
||||||
|
|
||||||
void is_on_changed(void *_d)
|
|
||||||
{
|
{
|
||||||
textlog_data *d = _d;
|
|
||||||
char t;
|
char t;
|
||||||
|
|
||||||
if (pthread_mutex_lock(&d->lock)) abort();
|
|
||||||
|
|
||||||
if (d->socket == -1) goto no_connection;
|
|
||||||
|
|
||||||
t = 1;
|
t = 1;
|
||||||
if (socket_send(d->socket, &t, 1) == -1 ||
|
if (socket_send(socket, &t, 1) == -1 ||
|
||||||
socket_send(d->socket, &d->nevents, sizeof(int)) == -1 ||
|
socket_send(socket, &nevents, sizeof(int)) == -1 ||
|
||||||
socket_send(d->socket, d->is_on, d->nevents * sizeof(int)) == -1)
|
socket_send(socket, is_on, nevents * sizeof(int)) == -1)
|
||||||
abort();
|
abort();
|
||||||
|
|
||||||
no_connection:
|
|
||||||
if (pthread_mutex_unlock(&d->lock)) abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void usage(void)
|
void usage(void)
|
||||||
@@ -54,28 +36,18 @@ void usage(void)
|
|||||||
" -full also dump buffers' content\n"
|
" -full also dump buffers' content\n"
|
||||||
" -raw-time also prints 'raw time'\n"
|
" -raw-time also prints 'raw time'\n"
|
||||||
" -ip <host> connect to given IP address (default %s)\n"
|
" -ip <host> connect to given IP address (default %s)\n"
|
||||||
" -p <port> connect to given port (default %d)\n"
|
" -p <port> connect to given port (default %d)\n",
|
||||||
" -x GUI output\n"
|
|
||||||
" -debug-gui activate GUI debug logs\n"
|
|
||||||
" -no-gui disable GUI entirely\n",
|
|
||||||
DEFAULT_REMOTE_IP,
|
DEFAULT_REMOTE_IP,
|
||||||
DEFAULT_REMOTE_PORT
|
DEFAULT_REMOTE_PORT
|
||||||
);
|
);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *gui_thread(void *_g)
|
|
||||||
{
|
|
||||||
gui *g = _g;
|
|
||||||
gui_loop(g);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int n, char **v)
|
int main(int n, char **v)
|
||||||
{
|
{
|
||||||
extern int volatile gui_logd;
|
|
||||||
char *database_filename = NULL;
|
char *database_filename = NULL;
|
||||||
void *database;
|
void *database;
|
||||||
|
int socket;
|
||||||
char *ip = DEFAULT_REMOTE_IP;
|
char *ip = DEFAULT_REMOTE_IP;
|
||||||
int port = DEFAULT_REMOTE_PORT;
|
int port = DEFAULT_REMOTE_PORT;
|
||||||
char **on_off_name;
|
char **on_off_name;
|
||||||
@@ -86,11 +58,7 @@ int main(int n, char **v)
|
|||||||
int i;
|
int i;
|
||||||
event_handler *h;
|
event_handler *h;
|
||||||
logger *textlog;
|
logger *textlog;
|
||||||
gui *g = NULL; /* initialization not necessary but gcc is not happy */
|
|
||||||
int gui_mode = 0;
|
|
||||||
view *out;
|
view *out;
|
||||||
int gui_active = 1;
|
|
||||||
textlog_data textlog_data;
|
|
||||||
int full = 0;
|
int full = 0;
|
||||||
int raw_time = 0;
|
int raw_time = 0;
|
||||||
|
|
||||||
@@ -115,16 +83,11 @@ int main(int n, char **v)
|
|||||||
{ on_off_name[on_off_n]=NULL; on_off_action[on_off_n++]=1; continue; }
|
{ on_off_name[on_off_n]=NULL; on_off_action[on_off_n++]=1; continue; }
|
||||||
if (!strcmp(v[i], "-OFF"))
|
if (!strcmp(v[i], "-OFF"))
|
||||||
{ on_off_name[on_off_n]=NULL; on_off_action[on_off_n++]=0; continue; }
|
{ on_off_name[on_off_n]=NULL; on_off_action[on_off_n++]=0; continue; }
|
||||||
if (!strcmp(v[i], "-x")) { gui_mode = 1; continue; }
|
|
||||||
if (!strcmp(v[i], "-debug-gui")) { gui_logd = 1; continue; }
|
|
||||||
if (!strcmp(v[i], "-no-gui")) { gui_active = 0; continue; }
|
|
||||||
if (!strcmp(v[i], "-full")) { full = 1; continue; }
|
if (!strcmp(v[i], "-full")) { full = 1; continue; }
|
||||||
if (!strcmp(v[i], "-raw-time")) { raw_time = 1; continue; }
|
if (!strcmp(v[i], "-raw-time")) { raw_time = 1; continue; }
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gui_active == 0) gui_mode = 0;
|
|
||||||
|
|
||||||
if (database_filename == NULL) {
|
if (database_filename == NULL) {
|
||||||
printf("ERROR: provide a database file (-d)\n");
|
printf("ERROR: provide a database file (-d)\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -140,29 +103,12 @@ int main(int n, char **v)
|
|||||||
|
|
||||||
h = new_handler(database);
|
h = new_handler(database);
|
||||||
|
|
||||||
if (gui_active) {
|
out = new_view_stdout();
|
||||||
g = gui_init();
|
|
||||||
new_thread(gui_thread, g);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gui_mode) {
|
|
||||||
widget *w, *win;
|
|
||||||
// w = new_textlist(g, 600, 20, 0);
|
|
||||||
w = new_textlist(g, 800, 50, BACKGROUND_COLOR);
|
|
||||||
win = new_toplevel_window(g, 800, 50*12, "textlog");
|
|
||||||
widget_add_child(g, win, w, -1);
|
|
||||||
out = new_view_textlist(1000, 10, g, w);
|
|
||||||
//tout = new_view_textlist(7, 4, g, w);
|
|
||||||
} else {
|
|
||||||
out = new_view_stdout();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < number_of_events; i++) {
|
for (i = 0; i < number_of_events; i++) {
|
||||||
char *name, *desc;
|
char *name, *desc;
|
||||||
database_get_generic_description(database, i, &name, &desc);
|
database_get_generic_description(database, i, &name, &desc);
|
||||||
textlog = new_textlog(h, database, name, desc);
|
textlog = new_textlog(h, database, name, desc);
|
||||||
// "ENB_PHY_UL_CHANNEL_ESTIMATE",
|
|
||||||
// "ev: {} eNB_id [eNB_ID] frame [frame] subframe [subframe]");
|
|
||||||
logger_add_view(textlog, out);
|
logger_add_view(textlog, out);
|
||||||
if (full) textlog_dump_buffer(textlog, 1);
|
if (full) textlog_dump_buffer(textlog, 1);
|
||||||
if (raw_time) textlog_raw_time(textlog, 1);
|
if (raw_time) textlog_raw_time(textlog, 1);
|
||||||
@@ -173,24 +119,21 @@ int main(int n, char **v)
|
|||||||
for (i = 0; i < on_off_n; i++)
|
for (i = 0; i < on_off_n; i++)
|
||||||
on_off(database, on_off_name[i], is_on, on_off_action[i]);
|
on_off(database, on_off_name[i], is_on, on_off_action[i]);
|
||||||
|
|
||||||
textlog_data.socket = -1;
|
socket = connect_to(ip, port);
|
||||||
textlog_data.is_on = is_on;
|
if (socket == -1) {
|
||||||
textlog_data.nevents = number_of_events;
|
printf("fatal: connection failed\n");
|
||||||
if (pthread_mutex_init(&textlog_data.lock, NULL)) abort();
|
return 1;
|
||||||
if (gui_active)
|
}
|
||||||
setup_event_selector(g, database, is_on, is_on_changed, &textlog_data);
|
|
||||||
|
|
||||||
textlog_data.socket = connect_to(ip, port);
|
|
||||||
|
|
||||||
/* send the first message - activate selected traces */
|
/* send the first message - activate selected traces */
|
||||||
is_on_changed(&textlog_data);
|
activate_traces(socket, is_on, number_of_events);
|
||||||
|
|
||||||
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
|
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
|
||||||
|
|
||||||
/* read messages */
|
/* read messages */
|
||||||
while (1) {
|
while (1) {
|
||||||
event e;
|
event e;
|
||||||
e = get_event(textlog_data.socket, &ebuf, database);
|
e = get_event(socket, &ebuf, database);
|
||||||
if (e.type == -1) break;
|
if (e.type == -1) break;
|
||||||
handle_event(h, e);
|
handle_event(h, e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user