#!/bin/sh

INCLUDES=/usr/include

SYSLIST=`grep SYS_ $INCLUDES/bits/syscall.h | cut -d " " -f 2`
cat >pt_symbol.inc <<EOF
/*
 * pt_sh : pt_symbol.inc
 */

#include <syscall.h>
#include <signal.h>

char* syscall_symbols[] =
{
EOF

for i in `egrep "\_\_NR\_[\_a-z]+" $INCLUDES/asm/unistd.h | cut -f 1 | cut -d " " -f 2 | grep -v XXX | grep -v __NR__exit | cut -f 4,5 -d "_"`; do
  cat >>pt_symbol.inc <<EOF
#ifdef SYS_$i
  "$i",
#else
#ifdef SYS__$i
  "_$i",
#else
  NULL,
#endif
#endif
EOF
done

cat >>pt_symbol.inc <<EOF
  NULL
};

#ifdef SYS_$i
#define LAST_SYSCALL SYS_$i
#else
#define LAST_SYSCALL SYS__$i
#endif

char *signal_symbols[] =
{
EOF

for i in `egrep 'SIG[A-Z]' $INCLUDES/bits/signum.h | grep define | grep -v SIGRT | grep -v SIGUNUSED | egrep -v 'SIG[A-Z 	]*SIG' | grep -v SIGIOT | cut -f 1,2`; do
  if [ "$i" != "#define" ]; then
    cat >>pt_symbol.inc <<EOF
#ifdef $i
  "$i",
#else
  NULL,
#endif
EOF
  fi
done

cat >>pt_symbol.inc <<EOF
  NULL
};
EOF

exit 0
