Commit 0fb583a2 authored by Cedric Roux's avatar Cedric Roux
Browse files

import the T tracer into openair

parents f9d740ee 2bb04f01
CC=gcc
CFLAGS=-Wall -g -pthread -DT_TRACER
#comment those two lines to NOT use shared memory
CFLAGS += -DT_USE_SHARED_MEMORY
LIBS += -lrt
PROG=t
OBJS=main.o T.o
GENIDS=genids
GENIDS_OBJS=genids.o
ALL=$(PROG) $(GENIDS)
all : $(ALL)
$(GENIDS): $(GENIDS_OBJS)
$(CC) $(CFLAGS) -o $(GENIDS) $(GENIDS_OBJS)
$(PROG): $(OBJS)
$(CC) $(CFLAGS) -o $(PROG) $(OBJS) $(LIBS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
T_IDs.h: $(GENIDS) T_messages.txt
./$(GENIDS) T_messages.txt T_IDs.h
main.o: T.h T_IDs.h T_defs.h
clean:
rm -f *.o $(PROG) $(GENIDS) core T_IDs.h
cd tracer && make clean
#PHY logs
ID = ENB_INPUT_SIGNAL
DESC = eNodeB received signal in the time domain for a duration of 1ms
GROUP = PHY:GRAPHIC:HEAVY
FORMAT = int,eNB_ID : int,frame : int,subframe : int,antenna : buffer,rxdata
ID = ENB_UL_CHANNEL_ESTIMATE
DESC = eNodeB channel estimation in the time domain
GROUP = PHY:GRAPHIC:HEAVY
FORMAT = int,eNB_ID : int,UE_ID : int,frame : int,subframe : int,antenna : buffer,chest_t
ID = PUSCH_IQ
DESC = eNodeB PUSCH received IQ data
GROUP = PHY:GRAPHIC:HEAVY
FORMAT = int,eNB_ID : int,UE_ID : int,frame : int,subframe : int,nb_rb : buffer,pusch_comp
ID = PUCCH_1AB_IQ
DESC = eNodeB PUCCH received IQ data
GROUP = PHY:GRAPHIC:HEAVY
FORMAT = int,eNB_ID : int,UE_ID : int,frame : int,subframe : int,I : int,Q
ID = PUCCH_1_ENERGY
DESC = eNodeB PUCCH 1 energy and threshold
GROUP = PHY:GRAPHIC:HEAVY
FORMAT = int,eNB_ID : int,UE_ID : int,frame : int,subframe : int,energy : int,threshold
#legacy logs
ID = LEGACY_MAC_INFO
DESC = MAC legacy logs - info level
GROUP = MAC:INFO:LEGACY
ID = LEGACY_MAC_ERROR
DESC = MAC legacy logs - error level
GROUP = MAC:ERROR:LEGACY
ID = LEGACY_MAC_WARNING
DESC = MAC legacy logs - warning level
GROUP = MAC:WARNING:LEGACY
ID = LEGACY_MAC_DEBUG
DESC = MAC legacy logs - debug level
GROUP = MAC:DEBUG:LEGACY
ID = LEGACY_MAC_TRACE
DESC = MAC legacy logs - trace level
GROUP = MAC:TRACE:LEGACY
ID = LEGACY_PHY_INFO
DESC = PHY legacy logs - info level
GROUP = PHY:INFO:LEGACY
ID = LEGACY_PHY_ERROR
DESC = PHY legacy logs - error level
GROUP = PHY:ERROR:LEGACY
ID = LEGACY_PHY_WARNING
DESC = PHY legacy logs - warning level
GROUP = PHY:WARNING:LEGACY
ID = LEGACY_PHY_DEBUG
DESC = PHY legacy logs - debug level
GROUP = PHY:DEBUG:LEGACY
ID = LEGACY_PHY_TRACE
DESC = PHY legacy logs - trace level
GROUP = PHY:TRACE:LEGACY
ID = LEGACY_S1AP_INFO
DESC = S1AP legacy logs - info level
GROUP = S1AP:INFO:LEGACY
ID = LEGACY_S1AP_ERROR
DESC = S1AP legacy logs - error level
GROUP = S1AP:ERROR:LEGACY
ID = LEGACY_S1AP_WARNING
DESC = S1AP legacy logs - warning level
GROUP = S1AP:WARNING:LEGACY
ID = LEGACY_S1AP_DEBUG
DESC = S1AP legacy logs - debug level
GROUP = S1AP:DEBUG:LEGACY
ID = LEGACY_S1AP_TRACE
DESC = S1AP legacy logs - trace level
GROUP = S1AP:TRACE:LEGACY
ID = LEGACY_X2AP_INFO
DESC = X2AP legacy logs - info level
GROUP = X2AP:INFO:LEGACY
ID = LEGACY_X2AP_ERROR
DESC = X2AP legacy logs - error level
GROUP = X2AP:ERROR:LEGACY
ID = LEGACY_X2AP_WARNING
DESC = X2AP legacy logs - warning level
GROUP = X2AP:WARNING:LEGACY
ID = LEGACY_X2AP_DEBUG
DESC = X2AP legacy logs - debug level
GROUP = X2AP:DEBUG:LEGACY
ID = LEGACY_X2AP_TRACE
DESC = X2AP legacy logs - trace level
GROUP = X2AP:TRACE:LEGACY
ID = LEGACY_RRC_INFO
DESC = RRC legacy logs - info level
GROUP = RRC:INFO:LEGACY
ID = LEGACY_RRC_ERROR
DESC = RRC legacy logs - error level
GROUP = RRC:ERROR:LEGACY
ID = LEGACY_RRC_WARNING
DESC = RRC legacy logs - warning level
GROUP = RRC:WARNING:LEGACY
ID = LEGACY_RRC_DEBUG
DESC = RRC legacy logs - debug level
GROUP = RRC:DEBUG:LEGACY
ID = LEGACY_RRC_TRACE
DESC = RRC legacy logs - trace level
GROUP = RRC:TRACE:LEGACY
ID = LEGACY_RLC_INFO
DESC = RLC legacy logs - info level
GROUP = RLC:INFO:LEGACY
ID = LEGACY_RLC_ERROR
DESC = RLC legacy logs - error level
GROUP = RLC:ERROR:LEGACY
ID = LEGACY_RLC_WARNING
DESC = RLC legacy logs - warning level
GROUP = RLC:WARNING:LEGACY
ID = LEGACY_RLC_DEBUG
DESC = RLC legacy logs - debug level
GROUP = RLC:DEBUG:LEGACY
ID = LEGACY_RLC_TRACE
DESC = RLC legacy logs - trace level
GROUP = RLC:TRACE:LEGACY
ID = LEGACY_PDCP_INFO
DESC = PDCP legacy logs - info level
GROUP = PDCP:INFO:LEGACY
ID = LEGACY_PDCP_ERROR
DESC = PDCP legacy logs - error level
GROUP = PDCP:ERROR:LEGACY
ID = LEGACY_PDCP_WARNING
DESC = PDCP legacy logs - warning level
GROUP = PDCP:WARNING:LEGACY
ID = LEGACY_PDCP_DEBUG
DESC = PDCP legacy logs - debug level
GROUP = PDCP:DEBUG:LEGACY
ID = LEGACY_PDCP_TRACE
DESC = PDCP legacy logs - trace level
GROUP = PDCP:TRACE:LEGACY
ID = LEGACY_ENB_APP_INFO
DESC = ENB_APP legacy logs - info level
GROUP = ENB_APP:INFO:LEGACY
ID = LEGACY_ENB_APP_ERROR
DESC = ENB_APP legacy logs - error level
GROUP = ENB_APP:ERROR:LEGACY
ID = LEGACY_ENB_APP_WARNING
DESC = ENB_APP legacy logs - warning level
GROUP = ENB_APP:WARNING:LEGACY
ID = LEGACY_ENB_APP_DEBUG
DESC = ENB_APP legacy logs - debug level
GROUP = ENB_APP:DEBUG:LEGACY
ID = LEGACY_ENB_APP_TRACE
DESC = ENB_APP legacy logs - trace level
GROUP = ENB_APP:TRACE:LEGACY
ID = LEGACY_SCTP_INFO
DESC = SCTP legacy logs - info level
GROUP = SCTP:INFO:LEGACY
ID = LEGACY_SCTP_ERROR
DESC = SCTP legacy logs - error level
GROUP = SCTP:ERROR:LEGACY
ID = LEGACY_SCTP_WARNING
DESC = SCTP legacy logs - warning level
GROUP = SCTP:WARNING:LEGACY
ID = LEGACY_SCTP_DEBUG
DESC = SCTP legacy logs - debug level
GROUP = SCTP:DEBUG:LEGACY
ID = LEGACY_SCTP_TRACE
DESC = SCTP legacy logs - trace level
GROUP = SCTP:TRACE:LEGACY
ID = LEGACY_UDP__INFO
DESC = UDP_ legacy logs - info level
GROUP = UDP_:INFO:LEGACY
ID = LEGACY_UDP__ERROR
DESC = UDP_ legacy logs - error level
GROUP = UDP_:ERROR:LEGACY
ID = LEGACY_UDP__WARNING
DESC = UDP_ legacy logs - warning level
GROUP = UDP_:WARNING:LEGACY
ID = LEGACY_UDP__DEBUG
DESC = UDP_ legacy logs - debug level
GROUP = UDP_:DEBUG:LEGACY
ID = LEGACY_UDP__TRACE
DESC = UDP_ legacy logs - trace level
GROUP = UDP_:TRACE:LEGACY
ID = LEGACY_NAS_INFO
DESC = NAS legacy logs - info level
GROUP = NAS:INFO:LEGACY
ID = LEGACY_NAS_ERROR
DESC = NAS legacy logs - error level
GROUP = NAS:ERROR:LEGACY
ID = LEGACY_NAS_WARNING
DESC = NAS legacy logs - warning level
GROUP = NAS:WARNING:LEGACY
ID = LEGACY_NAS_DEBUG
DESC = NAS legacy logs - debug level
GROUP = NAS:DEBUG:LEGACY
ID = LEGACY_NAS_TRACE
DESC = NAS legacy logs - trace level
GROUP = NAS:TRACE:LEGACY
ID = LEGACY_HW_INFO
DESC = HW legacy logs - info level
GROUP = HW:INFO:LEGACY
ID = LEGACY_HW_ERROR
DESC = HW legacy logs - error level
GROUP = HW:ERROR:LEGACY
ID = LEGACY_HW_WARNING
DESC = HW legacy logs - warning level
GROUP = HW:WARNING:LEGACY
ID = LEGACY_HW_DEBUG
DESC = HW legacy logs - debug level
GROUP = HW:DEBUG:LEGACY
ID = LEGACY_HW_TRACE
DESC = HW legacy logs - trace level
GROUP = HW:TRACE:LEGACY
ID = LEGACY_EMU_INFO
DESC = EMU legacy logs - info level
GROUP = EMU:INFO:LEGACY
ID = LEGACY_EMU_ERROR
DESC = EMU legacy logs - error level
GROUP = EMU:ERROR:LEGACY
ID = LEGACY_EMU_WARNING
DESC = EMU legacy logs - warning level
GROUP = EMU:WARNING:LEGACY
ID = LEGACY_EMU_DEBUG
DESC = EMU legacy logs - debug level
GROUP = EMU:DEBUG:LEGACY
ID = LEGACY_EMU_TRACE
DESC = EMU legacy logs - trace level
GROUP = EMU:TRACE:LEGACY
ID = LEGACY_OTG_INFO
DESC = OTG legacy logs - info level
GROUP = OTG:INFO:LEGACY
ID = LEGACY_OTG_ERROR
DESC = OTG legacy logs - error level
GROUP = OTG:ERROR:LEGACY
ID = LEGACY_OTG_WARNING
DESC = OTG legacy logs - warning level
GROUP = OTG:WARNING:LEGACY
ID = LEGACY_OTG_DEBUG
DESC = OTG legacy logs - debug level
GROUP = OTG:DEBUG:LEGACY
ID = LEGACY_OTG_TRACE
DESC = OTG legacy logs - trace level
GROUP = OTG:TRACE:LEGACY
ID = LEGACY_OCG_INFO
DESC = OCG legacy logs - info level
GROUP = OCG:INFO:LEGACY
ID = LEGACY_OCG_ERROR
DESC = OCG legacy logs - error level
GROUP = OCG:ERROR:LEGACY
ID = LEGACY_OCG_WARNING
DESC = OCG legacy logs - warning level
GROUP = OCG:WARNING:LEGACY
ID = LEGACY_OCG_DEBUG
DESC = OCG legacy logs - debug level
GROUP = OCG:DEBUG:LEGACY
ID = LEGACY_OCG_TRACE
DESC = OCG legacy logs - trace level
GROUP = OCG:TRACE:LEGACY
ID = LEGACY_OCM_INFO
DESC = OCM legacy logs - info level
GROUP = OCM:INFO:LEGACY
ID = LEGACY_OCM_ERROR
DESC = OCM legacy logs - error level
GROUP = OCM:ERROR:LEGACY
ID = LEGACY_OCM_WARNING
DESC = OCM legacy logs - warning level
GROUP = OCM:WARNING:LEGACY
ID = LEGACY_OCM_DEBUG
DESC = OCM legacy logs - debug level
GROUP = OCM:DEBUG:LEGACY
ID = LEGACY_OCM_TRACE
DESC = OCM legacy logs - trace level
GROUP = OCM:TRACE:LEGACY
ID = LEGACY_OIP_INFO
DESC = OIP legacy logs - info level
GROUP = OIP:INFO:LEGACY
ID = LEGACY_OIP_ERROR
DESC = OIP legacy logs - error level
GROUP = OIP:ERROR:LEGACY
ID = LEGACY_OIP_WARNING
DESC = OIP legacy logs - warning level
GROUP = OIP:WARNING:LEGACY
ID = LEGACY_OIP_DEBUG
DESC = OIP legacy logs - debug level
GROUP = OIP:DEBUG:LEGACY
ID = LEGACY_OIP_TRACE
DESC = OIP legacy logs - trace level
GROUP = OIP:TRACE:LEGACY
ID = LEGACY_OMG_INFO
DESC = OMG legacy logs - info level
GROUP = OMG:INFO:LEGACY
ID = LEGACY_OMG_ERROR
DESC = OMG legacy logs - error level
GROUP = OMG:ERROR:LEGACY
ID = LEGACY_OMG_WARNING
DESC = OMG legacy logs - warning level
GROUP = OMG:WARNING:LEGACY
ID = LEGACY_OMG_DEBUG
DESC = OMG legacy logs - debug level
GROUP = OMG:DEBUG:LEGACY
ID = LEGACY_OMG_TRACE
DESC = OMG legacy logs - trace level
GROUP = OMG:TRACE:LEGACY
ID = LEGACY_OPT_INFO
DESC = OPT legacy logs - info level
GROUP = OPT:INFO:LEGACY
ID = LEGACY_OPT_ERROR
DESC = OPT legacy logs - error level
GROUP = OPT:ERROR:LEGACY
ID = LEGACY_OPT_WARNING
DESC = OPT legacy logs - warning level
GROUP = OPT:WARNING:LEGACY
ID = LEGACY_OPT_DEBUG
DESC = OPT legacy logs - debug level
GROUP = OPT:DEBUG:LEGACY
ID = LEGACY_OPT_TRACE
DESC = OPT legacy logs - trace level
GROUP = OPT:TRACE:LEGACY
ID = LEGACY_GTPU_INFO
DESC = GTPU legacy logs - info level
GROUP = GTPU:INFO:LEGACY
ID = LEGACY_GTPU_ERROR
DESC = GTPU legacy logs - error level
GROUP = GTPU:ERROR:LEGACY
ID = LEGACY_GTPU_WARNING
DESC = GTPU legacy logs - warning level
GROUP = GTPU:WARNING:LEGACY
ID = LEGACY_GTPU_DEBUG
DESC = GTPU legacy logs - debug level
GROUP = GTPU:DEBUG:LEGACY
ID = LEGACY_GTPU_TRACE
DESC = GTPU legacy logs - trace level
GROUP = GTPU:TRACE:LEGACY
ID = LEGACY_TMR_INFO
DESC = TMR legacy logs - info level
GROUP = TMR:INFO:LEGACY
ID = LEGACY_TMR_ERROR
DESC = TMR legacy logs - error level
GROUP = TMR:ERROR:LEGACY
ID = LEGACY_TMR_WARNING
DESC = TMR legacy logs - warning level
GROUP = TMR:WARNING:LEGACY
ID = LEGACY_TMR_DEBUG
DESC = TMR legacy logs - debug level
GROUP = TMR:DEBUG:LEGACY
ID = LEGACY_TMR_TRACE
DESC = TMR legacy logs - trace level
GROUP = TMR:TRACE:LEGACY
ID = LEGACY_OSA_INFO
DESC = OSA legacy logs - info level
GROUP = OSA:INFO:LEGACY
ID = LEGACY_OSA_ERROR
DESC = OSA legacy logs - error level
GROUP = OSA:ERROR:LEGACY
ID = LEGACY_OSA_WARNING
DESC = OSA legacy logs - warning level
GROUP = OSA:WARNING:LEGACY
ID = LEGACY_OSA_DEBUG
DESC = OSA legacy logs - debug level
GROUP = OSA:DEBUG:LEGACY
ID = LEGACY_OSA_TRACE
DESC = OSA legacy logs - trace level
GROUP = OSA:TRACE:LEGACY
# this is a bad hack but I won't fix (function util_print_hex_octets
# in openairinterface5g/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c
# does funky things with the LOG_x macros but we work on the C pre-processor
# level and this funkyness is not easily dealable with, so be it...)
ID = LEGACY_component_INFO
DESC = component legacy logs - info level
GROUP = component:INFO:LEGACY
ID = LEGACY_component_ERROR
DESC = component legacy logs - error level
GROUP = component:ERROR:LEGACY
ID = LEGACY_component_WARNING
DESC = component legacy logs - warning level
GROUP = component:WARNING:LEGACY
ID = LEGACY_component_DEBUG
DESC = component legacy logs - debug level
GROUP = component:DEBUG:LEGACY
ID = LEGACY_component_TRACE
DESC = component legacy logs - trace level
GROUP = component:TRACE:LEGACY
ID = LEGACY_componentP_INFO
DESC = componentP legacy logs - info level
GROUP = componentP:INFO:LEGACY
ID = LEGACY_componentP_ERROR
DESC = componentP legacy logs - error level
GROUP = componentP:ERROR:LEGACY
ID = LEGACY_componentP_WARNING
DESC = componentP legacy logs - warning level
GROUP = componentP:WARNING:LEGACY
ID = LEGACY_componentP_DEBUG
DESC = componentP legacy logs - debug level
GROUP = componentP:DEBUG:LEGACY
ID = LEGACY_componentP_TRACE
DESC = componentP legacy logs - trace level
GROUP = componentP:TRACE:LEGACY
#needed?
ID = LEGACY_CLI_INFO
DESC = CLI legacy logs - info level
GROUP = CLI:INFO:LEGACY
ID = LEGACY_CLI_ERROR
DESC = CLI legacy logs - error level
GROUP = CLI:ERROR:LEGACY
ID = LEGACY_CLI_WARNING
DESC = CLI legacy logs - warning level
GROUP = CLI:WARNING:LEGACY
ID = LEGACY_CLI_DEBUG
DESC = CLI legacy logs - debug level
GROUP = CLI:DEBUG:LEGACY
ID = LEGACY_CLI_TRACE
DESC = CLI legacy logs - trace level
GROUP = CLI:TRACE:LEGACY
#for debug/test - not used
ID = first
ID = buf_test
CC=gcc
CFLAGS=-Wall -g -pthread -DT_TRACER
#CFLAGS += -O3 -ffast-math -fomit-frame-pointer
LIBS=-lX11 -lm
#comment those two lines to NOT use shared memory
CFLAGS += -DT_USE_SHARED_MEMORY
LIBS += -lrt
PROG=tracer
OBJS=main.o plot.o database.o forward.o gui/gui.a
$(PROG): $(OBJS)
$(CC) $(CFLAGS) -o $(PROG) $(OBJS) $(LIBS)
gui/gui.a:
cd gui && make
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
main.o: ../T_IDs.h ../T_defs.h
clean:
rm -f *.o $(PROG) core
cd gui && make clean
#include "defs.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
typedef struct {
char *name;
char *desc;
char **groups;
int size;
int id;
} id;
typedef struct {
char *name;
char **ids;
int size;
} group;
typedef struct {
char *name;
id *i;
int isize;
group *g;
int gsize;
} database;
typedef struct {
char *data;
int size;
int maxsize;
} buffer;
typedef struct {
buffer name;
buffer value;
} parser;
void put(buffer *b, int c)
{
if (b->size == b->maxsize) {
b->maxsize += 256;
b->data = realloc(b->data, b->maxsize);
if (b->data == NULL) { printf("memory allocation error\n"); exit(1); }
}
b->data[b->size] = c;
b->size++;
}
void smash_spaces(FILE *f)
{
int c;
while (1) {
c = fgetc(f);
if (isspace(c)) continue;
if (c == ' ') continue;
if (c == '\t') continue;
if (c == '\n') continue;
if (c == 10 || c == 13) continue;
if (c == '#') {
while (1) {
c = fgetc(f);
if (c == '\n' || c == EOF) break;
}
continue;
}
break;
}
if (c != EOF) ungetc(c, f);
}
void get_line(parser *p, FILE *f, char **name, char **value)
{
int c;
p->name.size = 0;
p->value.size = 0;
*name = NULL;
*value = NULL;
smash_spaces(f);
c = fgetc(f);
while (!(c == '=' || isspace(c) || c == EOF))
{ put(&p->name, c); c = fgetc(f); }
if (c == EOF) return;
put(&p->name, 0);
while (!(c == EOF || c == '=')) c = fgetc(f);
if (c == EOF) return;
smash_spaces(f);
c = fgetc(f);
while (!(c == 10 || c == 13 || c == EOF))
{ put(&p->value, c); c = fgetc(f); }
put(&p->value, 0);
if (p->name.size <= 1) return;
if (p->value.size <= 1) return;
*name = p->name.data;
*value = p->value.data;
}
int group_cmp(const void *_p1, const void *_p2)
{
const group *p1 = _p1;
const group *p2 = _p2;
return strcmp(p1->name, p2->name);
}
int id_cmp(const void *_p1, const void *_p2)
{
const id *p1 = _p1;
const id *p2 = _p2;
return strcmp(p1->name, p2->name);
}
int string_cmp(const void *_p1, const void *_p2)
{
char * const *p1 = _p1;
char * const *p2 = _p2;
return strcmp(*p1, *p2);
}
id *add_id(database *r, char *idname, int i)
{
if (bsearch(&(id){name:idname}, r->i, r->isize, sizeof(id), id_cmp) != NULL)
{ printf("ERROR: ID '%s' declared more than once\n", idname); exit(1); }
if ((r->isize & 1023) == 0) {
r->i = realloc(r->i, (r->isize + 1024) * sizeof(id));
if (r->i == NULL) { printf("out of memory\n"); exit(1); }
}
r->i[r->isize].name = strdup(idname);
if (r->i[r->isize].name == NULL) { printf("out of memory\n"); exit(1); }
r->i[r->isize].desc = NULL;
r->i[r->isize].groups = NULL;
r->i[r->isize].size = 0;
r->i[r->isize].id = i;
r->isize++;
qsort(r->i, r->isize, sizeof(id), id_cmp);
return (id*)bsearch(&(id){name:idname}, r->i, r->isize, sizeof(id), id_cmp);
}
group *get_group(database *r, char *group_name)