Commit 1752c929 authored by Cedric Roux's avatar Cedric Roux

T: update 'to_vcd' tracer to trace all VCD variables and functions

Pass the command line arguemnt -vcd to trace all VCD variables
and functions.
parent 07d16106
...@@ -174,7 +174,8 @@ void usage(void) ...@@ -174,7 +174,8 @@ void usage(void)
" -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"
" -b <event> <arg> <vcd name> trace as binary (0 off, anything else on)\n" " -b <event> <arg> <vcd name> trace as binary (0 off, anything else on)\n"
" -l <event> <arg> <vcd name> trace as uint64_t\n", " -l <event> <arg> <vcd name> trace as uint64_t\n"
" -vcd trace all VCD variables and functions\n",
DEFAULT_REMOTE_IP, DEFAULT_REMOTE_IP,
DEFAULT_REMOTE_PORT DEFAULT_REMOTE_PORT
); );
...@@ -192,6 +193,20 @@ void force_stop(int x) ...@@ -192,6 +193,20 @@ void force_stop(int x)
run = 0; run = 0;
} }
vcd_vars *add_var(vcd_vars *vars, int nvars,
char *event, char *arg, char *vcd_name, int is_boolean)
{
if (nvars % 64 == 0) {
vars = realloc(vars, (nvars+64) * sizeof(vcd_vars));
if (vars == NULL) abort();
}
vars[nvars].event = event;
vars[nvars].arg = arg;
vars[nvars].vcd_name = vcd_name;
vars[nvars].boolean = is_boolean;
return vars;
}
int main(int n, char **v) int main(int n, char **v)
{ {
char *output_filename = NULL; char *output_filename = NULL;
...@@ -202,11 +217,12 @@ int main(int n, char **v) ...@@ -202,11 +217,12 @@ int main(int n, char **v)
int *is_on; int *is_on;
int number_of_events; int number_of_events;
int i; int i;
vcd_vars vars[n]; vcd_vars *vars = NULL;
int nvars = 0; int nvars = 0;
view *vcd_view; view *vcd_view;
event_handler *h; event_handler *h;
logger *textlog; logger *textlog;
int all_vcd = 0;
/* write on a socket fails if the other end is closed and we get SIGPIPE */ /* write on a socket fails if the other end is closed and we get SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort(); if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
...@@ -221,19 +237,22 @@ int main(int n, char **v) ...@@ -221,19 +237,22 @@ int main(int n, char **v)
if (!strcmp(v[i], "-p")) if (!strcmp(v[i], "-p"))
{ if (i > n-2) usage(); port = atoi(v[++i]); continue; } { if (i > n-2) usage(); port = atoi(v[++i]); continue; }
if (!strcmp(v[i], "-b")) { if(i>n-4)usage(); if (!strcmp(v[i], "-b")) { if(i>n-4)usage();
vars[nvars].event = v[++i]; char *event = v[++i];
vars[nvars].arg = v[++i]; char *arg = v[++i];
vars[nvars].vcd_name = v[++i]; char *vcd_name = v[++i];
vars[nvars++].boolean = 1; vars = add_var(vars, nvars, event, arg, vcd_name, 1);
nvars++;
continue; continue;
} }
if (!strcmp(v[i], "-l")) { if(i>n-4)usage(); if (!strcmp(v[i], "-l")) { if(i>n-4)usage();
vars[nvars].event = v[++i]; char *event = v[++i];
vars[nvars].arg = v[++i]; char *arg = v[++i];
vars[nvars].vcd_name = v[++i]; char *vcd_name = v[++i];
vars[nvars++].boolean = 0; vars = add_var(vars, nvars, event, arg, vcd_name, 0);
nvars++;
continue; continue;
} }
if (!strcmp(v[i], "-vcd")) { all_vcd = 1; continue; }
usage(); usage();
} }
...@@ -260,6 +279,28 @@ int main(int n, char **v) ...@@ -260,6 +279,28 @@ int main(int n, char **v)
/* create the view */ /* create the view */
vcd_view = new_view_vcd(); vcd_view = new_view_vcd();
if (all_vcd) {
/* activate all VCD traces */
for (i = 0; i < number_of_events; i++) {
int is_boolean;
int prefix_length;
char *name = event_name_from_id(database, i);
char *var_prefix = "VCD_VARIABLE_";
char *fun_prefix = "VCD_FUNCTION_";
if (!strncmp(name, var_prefix, strlen(var_prefix))) {
prefix_length = strlen(var_prefix);
is_boolean = 0;
} else if (!strncmp(name, fun_prefix, strlen(fun_prefix))) {
prefix_length = strlen(fun_prefix);
is_boolean = 1;
} else
continue;
vars = add_var(vars, nvars,
name, "value", name+prefix_length, is_boolean);
nvars++;
}
}
/* setup traces */ /* setup traces */
for (i = 0; i < nvars; i++) { for (i = 0; i < nvars; i++) {
char format[256]; char format[256];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment