Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Simple script to create node names for debugging



details:   https://anonhg.NetBSD.org/src/rev/91a2b8ae87cf
branches:  trunk
changeset: 813884:91a2b8ae87cf
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Feb 24 14:51:20 2016 +0000

description:
Simple script to create node names for debugging

diffstat:

 bin/sh/mknodenames.sh |  40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diffs (44 lines):

diff -r 1023da410a62 -r 91a2b8ae87cf bin/sh/mknodenames.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/sh/mknodenames.sh     Wed Feb 24 14:51:20 2016 +0000
@@ -0,0 +1,40 @@
+#! /bin/sh
+
+test -t 1 && test "$#" -eq 0 && exec > nodenames.h
+
+echo "#ifdef DEBUG"
+echo '
+/*
+ * Automatically generated by '"$0"'
+ * DO NOT EDIT. Do Not "cvs add".
+ */
+'
+
+MAX=$(awk < nodes.h '
+       /#define/ {
+               if ($3 > MAX) MAX = $3
+       }
+       END { print MAX }
+')
+
+echo
+echo "STATIC const char * const NodeNames[${MAX} + 1] = {"
+
+grep '^#define' nodes.h | sort -k2n | while read define name number opt_comment
+do
+       : ${next:=0}
+       while [ "$number" -gt "$next" ]
+       do
+               echo '  "???",'
+               next=$(( next + 1))
+       done
+       echo '  "'"$name"'",'
+       next=$(( number + 1 ))
+done
+
+echo "};"
+echo
+echo '#define NODETYPENAME(type) \'
+echo ' ((unsigned)(type) <= '"${MAX}"' ? NodeNames[(type)] : "??OOR??")'
+echo
+echo '#endif'



Home | Main Index | Thread Index | Old Index