aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Mogenet <emogenet@gmail.com>2017-04-28 23:08:46 +0200
committerEmmanuel Mogenet <emogenet@gmail.com>2017-04-28 23:08:46 +0200
commit1bb2f354151d8d9c5497632656256e7543fdb782 (patch)
treeed3e6ac21bbab7506ab4fc0fac23888134db8092
parent3031cd34237dd168a942c259d0fe0c26a5f5c87c (diff)
downloadghdl-1bb2f354151d8d9c5497632656256e7543fdb782.tar.gz
ghdl-1bb2f354151d8d9c5497632656256e7543fdb782.tar.bz2
ghdl-1bb2f354151d8d9c5497632656256e7543fdb782.zip
Add -H to ghwdump to dump full pathnames of signals
-rw-r--r--src/grt/ghwdump.c14
-rw-r--r--src/grt/ghwlib.c49
-rw-r--r--src/grt/ghwlib.h1
3 files changed, 59 insertions, 5 deletions
diff --git a/src/grt/ghwdump.c b/src/grt/ghwdump.c
index 3b898d33d..d057b1004 100644
--- a/src/grt/ghwdump.c
+++ b/src/grt/ghwdump.c
@@ -34,6 +34,7 @@ usage (void)
printf ("Options are:\n"
" -t display types\n"
" -h display hierarchy\n"
+ " -H display hierarchy with full pathnames\n"
" -T display time\n"
" -s display signals (and time)\n"
" -f <lst> list of signals to display (default: all, example: -f 1,3,5-7,21-33)\n"
@@ -133,6 +134,7 @@ main (int argc, char **argv)
int flag_disp_hierarchy;
int flag_disp_time;
int flag_disp_signals;
+ int flag_full_names;
int flag_list;
int flag_verbose;
int nb_signals;
@@ -144,6 +146,7 @@ main (int argc, char **argv)
progname = argv[0];
flag_disp_types = 0;
flag_disp_hierarchy = 0;
+ flag_full_names = 0;
flag_disp_time = 0;
flag_disp_signals = 0;
flag_list = 0;
@@ -156,7 +159,7 @@ main (int argc, char **argv)
{
int c;
- c = getopt (argc, argv, "thTslvf:");
+ c = getopt (argc, argv, "thHTslvf:");
if (c == -1)
break;
switch (c)
@@ -167,6 +170,10 @@ main (int argc, char **argv)
case 'h':
flag_disp_hierarchy = 1;
break;
+ case 'H':
+ flag_disp_hierarchy = 1;
+ flag_full_names = 1;
+ break;
case 'T':
flag_disp_time = 1;
break;
@@ -252,7 +259,10 @@ main (int argc, char **argv)
if (flag_disp_types)
ghw_disp_types (hp);
if (flag_disp_hierarchy)
- ghw_disp_hie (hp, hp->hie);
+ {
+ hp->flag_full_names = flag_full_names;
+ ghw_disp_hie (hp, hp->hie);
+ }
#if 1
sm = ghw_sm_init;
diff --git a/src/grt/ghwlib.c b/src/grt/ghwlib.c
index bee84687c..1b3c4e683 100644
--- a/src/grt/ghwlib.c
+++ b/src/grt/ghwlib.c
@@ -840,6 +840,7 @@ ghw_read_hie (struct ghw_handler *h)
h->nbr_sigs++;
h->skip_sigs = NULL;
+ h->flag_full_names = 0;
h->sigs = (struct ghw_sig *) malloc (h->nbr_sigs * sizeof (struct ghw_sig));
memset (h->sigs, 0, h->nbr_sigs * sizeof (struct ghw_sig));
@@ -1004,6 +1005,48 @@ ghw_get_hie_name (struct ghw_hie *h)
void
ghw_disp_value (union ghw_val *val, union ghw_type *type);
+static void
+print_name (struct ghw_hie *hie, int full_names)
+{
+ int i;
+ int depth;
+ struct ghw_hie *p;
+ struct ghw_hie **buf;
+ struct ghw_hie **end;
+
+ if (0 == full_names)
+ {
+ printf (" %s: ", hie->name);
+ return;
+ }
+
+ p = hie;
+ depth = 0;
+ while (p && p->name)
+ {
+ p = p->parent;
+ ++depth;
+ }
+ buf = (struct ghw_hie **) malloc (depth * sizeof (struct ghw_hie *));
+
+ p = hie;
+ end = depth + buf;
+ while (p && p->name)
+ {
+ *(--end) = p;
+ p = p->parent;
+ }
+
+ putchar (' ');
+ for (i = 0; i < depth; ++i)
+ {
+ printf ("%s%s", i ? "." : "", buf[i]->name);
+ }
+ putchar (':');
+ putchar (' ');
+ free (buf);
+}
+
void
ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top)
{
@@ -1018,7 +1061,7 @@ ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top)
while (1)
{
for (i = 0; i < indent; i++)
- fputc (' ', stdout);
+ fputc (' ', stdout);
printf ("%s", ghw_get_hie_name (hie));
switch (hie->kind)
@@ -1031,7 +1074,7 @@ ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top)
case ghw_hie_process:
case ghw_hie_package:
if (hie->name)
- printf (" %s", hie->name);
+ print_name (hie, h->flag_full_names);
if (hie->kind == ghw_hie_generate_for)
{
printf ("(");
@@ -1057,7 +1100,7 @@ ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top)
unsigned int *sigs = hie->u.sig.sigs;
unsigned int k, num;
- printf (" %s: ", hie->name);
+ print_name (hie, h->flag_full_names);
ghw_disp_subtype_indication (h, hie->u.sig.type);
printf (":");
k = 0;
diff --git a/src/grt/ghwlib.h b/src/grt/ghwlib.h
index 11917542a..6f65d6ba8 100644
--- a/src/grt/ghwlib.h
+++ b/src/grt/ghwlib.h
@@ -333,6 +333,7 @@ struct ghw_handler
/* Non-composite (or basic) signals. */
int nbr_sigs;
char *skip_sigs;
+ int flag_full_names;
struct ghw_sig *sigs;
/* Hierarchy. */