Permalink
Browse files

Add basic command line parameters to full-trace.sh and trace-process.sh.

This patch adds the following command line parameters to full-trace.sh:
-b|--bufsize: specify tracing buffer size;
-d|--debug  : enable debugging (this adds debug arguments to the bash
              executing the tracing scripts).
The buffer size option is also enabled in the trace-process.sh script
which actually sets up tracing.
  • Loading branch information...
1 parent 9292953 commit 1ff34ca425695ad520a80000a2e0cec5784085e6 @ariava ariava committed Dec 4, 2012
Showing with 59 additions and 6 deletions.
  1. +40 −4 full-trace.sh
  2. +19 −2 trace-process.sh
View
@@ -1,7 +1,43 @@
#!/bin/bash
+SHELL=bash
+BASHARG=
-./finegrain-uprobes.sh $1
-./trace-process.sh $1
-./rewrite-addresses.sh $1
-#./clean.sh
+usage()
+{
+cat << EOF
+usage: $0 [-b bufsize] [-d] <command>
+Full process tracer (userspace, libraries, kernel)
+ OPTIONS:
+-b Buffer size
+-d Debug
+EOF
+}
+
+options=$(getopt -o db: -l "debug,bufsize:" -n "full-trace.sh" -- "$@")
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
+eval set -- "$options"
+
+while true; do
+ case "$1" in
+ -d|--debug) BASHARG=-xv ;;
+ -b|--bufsize) BUFSIZE=$2; shift ;;
+ (--) shift; break;;
+ esac
+ shift
+done
+
+CMD=$@
+
+if [ "$BUFSIZE" != "" ]; then
+ TRACEARGS="-b $BUFSIZE"
+else
+ TRACEARGS=
+fi
+
+$SHELL $BASHARG ./finegrain-uprobes.sh $CMD
+sudo $SHELL $BASHARG ./trace-process.sh $TRACEARGS $CMD
+$SHELL $BASHARG ./rewrite-addresses.sh $CMD
View
@@ -1,4 +1,21 @@
-#!/bin/bash -xv
+#!/bin/bash
+
+BUFSIZE=2000000
+
+options=$(getopt -o b: -l "bufsize:" -n "trace-process.sh" -- "$@")
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
+eval set -- "$options"
+
+while true; do
+ case "$1" in
+ -b|--bufsize) BUFSIZE=$2; shift ;;
+ (--) shift; break;;
+ esac
+ shift
+done
CMD="$@"
UPROBES="/tmp/uprobes"
@@ -15,7 +32,7 @@ make wrapper
echo "tracing $CMD"
echo function_graph | sudo tee /sys/kernel/debug/tracing/current_tracer
-echo 2000000 | sudo tee /sys/kernel/debug/tracing/buffer_size_kb
+echo $BUFSIZE | sudo tee /sys/kernel/debug/tracing/buffer_size_kb
echo 1 | sudo tee /sys/kernel/debug/tracing/tracing_on
echo | sudo tee /sys/kernel/debug/tracing/uprobe_events
cat $UPROBES | sudo tee -a /sys/kernel/debug/tracing/uprobe_events

0 comments on commit 1ff34ca

Please sign in to comment.