File itrace-scripts.patch of Package itrace
---
Makefile.am | 1
configure.in | 1
scripts/Makefile.am | 3 +
scripts/it_setup | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/it_teardown | 81 +++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 171 insertions(+)
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,4 +2,5 @@
# driver
SUBDIRS = \
+ scripts \
src
--- a/configure.in
+++ b/configure.in
@@ -290,6 +290,7 @@ AM_CONDITIONAL(pi_counters_supported, te
LIBS=
AC_CONFIG_FILES([Makefile
+ scripts/Makefile
src/Makefile
src/perfutil/Makefile
src/a2n/Makefile
--- /dev/null
+++ b/scripts/Makefile.am
@@ -0,0 +1,3 @@
+## Process this file with automake to produce Makefile.in
+
+bin_SCRIPTS = it_setup it_teardown pi_load.sh pi_unload.sh
--- /dev/null
+++ b/scripts/it_setup
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+do_help()
+{
+ echo "`basename $0` usage:
+ -?/--help print this message
+ -V/--verbose write verbose output to stdout
+ --step-trace run trace in single step mode (default)
+ --branch-trace run trace in branch mode
+ --buffer-size=num per-cpu buffer size in MB (default: 50MB)
+" >&2
+}
+
+getOptions()
+{
+ BUF_SIZE=50
+ BRANCH_TRACE=0
+ VERBOSE=0
+
+ while [ "$#" -ne 0 ]; do
+ arg=`printf %s $1 | awk -F= '{print $1}'`
+ val=`printf %s $1 | awk -F= '{print $2}'`
+ shift
+ case "$arg" in
+ -"?"|--help)
+ do_help
+ exit 0
+ ;;
+ --buffer-size)
+ if test -z "$val"; then
+ echo "No value given for option $arg. "\
+ "See `basename $0` --help" >&2
+ exit 1
+ fi
+ BUF_SIZE=$val
+ ;;
+ --step-trace)
+ BRANCH_TRACE=0
+ ;;
+ --branch-trace)
+ BRANCH_TRACE=1
+ ;;
+ -V|--verbose)
+ VERBOSE=1
+ ;;
+ *)
+ echo "Unknown option \"$arg\". "\
+ "See `basename $0` --help" >&2
+ exit 1
+ ;;
+ esac
+ done
+}
+
+runCommand()
+{
+ if test $VERBOSE = 1; then
+ echo
+ echo ---Output of command \"$@\" -------------------------
+ $@
+ else
+ $@ &> /dev/null
+ fi
+ if test "$?" -ne 0; then
+ echo "Error running command \"$@\". Aborting." >&2
+ exit 1
+ fi
+}
+
+getOptions $@
+
+if test $BRANCH_TRACE = 0; then
+ runCommand swtrace it_install -ss
+else
+ runCommand swtrace it_install
+fi
+
+runCommand swtrace init -s $BUF_SIZE
+runCommand swtrace disable
+
+if test $BRANCH_TRACE = 0; then
+ runCommand swtrace enable 49 50
+fi
+
+runCommand swtrace on
--- /dev/null
+++ b/scripts/it_teardown
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+do_help()
+{
+ echo "`basename $0` usage:
+ -?/--help print this message
+ -V/--verbose write verbose output to stdout
+ --trace-outupt=file trace output filename (default: trace.nrm2)
+" >&2
+}
+
+getOptions()
+{
+ TRACE_OUTPUT="trace.nrm2"
+ VERBOSE=0
+
+ while [ "$#" -ne 0 ]; do
+ arg=`printf %s $1 | awk -F= '{print $1}'`
+ val=`printf %s $1 | awk -F= '{print $2}'`
+ shift
+ case "$arg" in
+ -"?"|--help)
+ do_help
+ exit 0
+ ;;
+ --trace-output)
+ if test -z "$val"; then
+ echo "No value given for option $arg. "\
+ "See `basename $0` --help" >&2
+ exit 1
+ fi
+ TRACE_OUTPUT=$val
+ ;;
+ -V|--verbose)
+ VERBOSE=1
+ ;;
+ *)
+ echo "Unknown option \"$arg\". "\
+ "See `basename $0` --help" >&2
+ exit 1
+ ;;
+ esac
+ done
+}
+
+runCommand()
+{
+ if test $VERBOSE = 1; then
+ echo
+ echo ---Output of command \"$@\" -------------------------
+ $@
+ else
+ $@ &> /dev/null
+ fi
+ if test "$?" -ne 0; then
+ echo "Error running command \"$@\". Aborting." >&2
+ exit 1
+ fi
+}
+
+runSwtraceOff()
+{
+ if test $VERBOSE = 1; then
+ echo
+ echo ---Output of command \"$@\" -------------------------
+ swtrace off
+ else
+ swtrace off &> /dev/null
+ fi
+ if test "$?" -ne 0; then
+ echo "Warning: swtrace off reports possible buffer overflow." >&2
+ fi
+}
+
+
+getOptions $@
+
+runSwtraceOff
+runCommand swtrace get $TRACE_OUTPUT
+runCommand swtrace free
+runCommand swtrace it_remove