2021-07-19 15:11:41 +02:00
|
|
|
#ifndef OVNI_DEF_H
|
|
|
|
#define OVNI_DEF_H
|
|
|
|
|
|
|
|
#define MAX_CPU 256
|
|
|
|
#define MAX_PROC 32
|
2021-07-19 19:05:26 +02:00
|
|
|
#define MAX_THR 32
|
2021-07-19 15:11:41 +02:00
|
|
|
#define MAX_LOOM 4
|
|
|
|
#define TRACEDIR "ovni"
|
|
|
|
|
2021-07-19 19:05:26 +02:00
|
|
|
/* ----------------------- common ------------------------ */
|
|
|
|
|
|
|
|
enum thread_state {
|
|
|
|
ST_THREAD_UNINIT = 0,
|
|
|
|
ST_THREAD_INIT = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
struct __attribute__((__packed__)) event {
|
|
|
|
uint64_t clock;
|
|
|
|
uint8_t fsm;
|
|
|
|
uint8_t event;
|
2021-07-21 18:27:58 +02:00
|
|
|
uint16_t a;
|
|
|
|
uint16_t b;
|
2021-07-19 19:05:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------------------- runtime ------------------------ */
|
|
|
|
|
|
|
|
/* State of each thread on runtime */
|
|
|
|
struct rthread {
|
|
|
|
/* Current cpu the thread is running on. Set to -1 if unbounded or
|
|
|
|
* unknown */
|
2021-07-19 15:11:41 +02:00
|
|
|
int cpu;
|
2021-07-19 19:05:26 +02:00
|
|
|
|
|
|
|
/* Current thread id */
|
|
|
|
pid_t tid;
|
|
|
|
|
|
|
|
/* Clock value of the events being emitted */
|
2021-07-19 15:11:41 +02:00
|
|
|
uint64_t clockvalue;
|
2021-07-19 19:05:26 +02:00
|
|
|
|
|
|
|
/* Stream trace file */
|
|
|
|
FILE *stream;
|
|
|
|
|
2021-07-21 18:27:58 +02:00
|
|
|
int ready;
|
2021-07-19 15:11:41 +02:00
|
|
|
};
|
|
|
|
|
2021-07-19 19:05:26 +02:00
|
|
|
/* State of each process on runtime */
|
|
|
|
struct rproc {
|
|
|
|
/* Path of the process tracedir */
|
|
|
|
char dir[PATH_MAX];
|
|
|
|
|
2021-07-19 15:11:41 +02:00
|
|
|
int proc;
|
|
|
|
int loom;
|
|
|
|
int ncpus;
|
|
|
|
clockid_t clockid;
|
2021-07-19 19:05:26 +02:00
|
|
|
char procdir[PATH_MAX];
|
2021-07-21 18:27:58 +02:00
|
|
|
|
|
|
|
int ready;
|
2021-07-19 15:11:41 +02:00
|
|
|
};
|
|
|
|
|
2021-07-19 19:05:26 +02:00
|
|
|
/* ----------------------- emulated ------------------------ */
|
|
|
|
|
|
|
|
/* State of each thread on post-process */
|
|
|
|
struct ethread {
|
|
|
|
/* Emulated thread tid */
|
|
|
|
pid_t tid;
|
|
|
|
|
|
|
|
/* Stream file */
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
/* Thread stream */
|
|
|
|
struct stream *stream;
|
2021-07-19 15:11:41 +02:00
|
|
|
};
|
|
|
|
|
2021-07-19 19:05:26 +02:00
|
|
|
/* State of each process on post-process */
|
|
|
|
struct eproc {
|
|
|
|
/* Monotonic counter for process index */
|
|
|
|
/* TODO: Use pid? */
|
|
|
|
int proc;
|
|
|
|
|
|
|
|
/* Path of the process tracedir */
|
|
|
|
char dir[PATH_MAX];
|
|
|
|
|
|
|
|
/* Threads */
|
|
|
|
size_t nthreads;
|
|
|
|
struct ethread thread[MAX_THR];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------------------- trace ------------------------ */
|
|
|
|
|
|
|
|
/* State of each loom on post-process */
|
|
|
|
struct loom {
|
|
|
|
size_t nprocs;
|
|
|
|
struct eproc proc[MAX_PROC];
|
2021-07-19 15:11:41 +02:00
|
|
|
};
|
|
|
|
|
2021-07-19 19:05:26 +02:00
|
|
|
struct stream {
|
2021-07-19 15:11:41 +02:00
|
|
|
FILE *f;
|
2021-07-21 18:27:58 +02:00
|
|
|
int tid;
|
|
|
|
int thread;
|
|
|
|
int proc;
|
|
|
|
int loom;
|
2021-07-19 15:11:41 +02:00
|
|
|
int loaded;
|
|
|
|
int active;
|
2021-07-19 19:05:26 +02:00
|
|
|
struct event last;
|
2021-07-21 18:27:58 +02:00
|
|
|
uint64_t lastclock;
|
2021-07-19 15:11:41 +02:00
|
|
|
};
|
|
|
|
|
2021-07-19 19:05:26 +02:00
|
|
|
struct trace {
|
2021-07-19 15:11:41 +02:00
|
|
|
int nlooms;
|
2021-07-19 19:05:26 +02:00
|
|
|
struct loom loom[MAX_LOOM];
|
2021-07-19 15:11:41 +02:00
|
|
|
int nstreams;
|
2021-07-19 19:05:26 +02:00
|
|
|
struct stream *stream;
|
2021-07-19 15:11:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* OVNI_DEF_H */
|