Skip to content

Commit

Permalink
Add basic command line parameters to full-trace.sh and trace-process.sh.
Browse files Browse the repository at this point in the history
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
ariava committed Dec 4, 2012
1 parent 9292953 commit 1ff34ca
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
44 changes: 40 additions & 4 deletions full-trace.sh
@@ -1,7 +1,43 @@
#!/bin/bash #!/bin/bash


SHELL=bash
BASHARG=


./finegrain-uprobes.sh $1 usage()
./trace-process.sh $1 {
./rewrite-addresses.sh $1 cat << EOF
#./clean.sh 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
21 changes: 19 additions & 2 deletions trace-process.sh
@@ -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="$@" CMD="$@"
UPROBES="/tmp/uprobes" UPROBES="/tmp/uprobes"
Expand All @@ -15,7 +32,7 @@ make wrapper


echo "tracing $CMD" echo "tracing $CMD"
echo function_graph | sudo tee /sys/kernel/debug/tracing/current_tracer 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 1 | sudo tee /sys/kernel/debug/tracing/tracing_on
echo | sudo tee /sys/kernel/debug/tracing/uprobe_events echo | sudo tee /sys/kernel/debug/tracing/uprobe_events
cat $UPROBES | sudo tee -a /sys/kernel/debug/tracing/uprobe_events cat $UPROBES | sudo tee -a /sys/kernel/debug/tracing/uprobe_events
Expand Down

0 comments on commit 1ff34ca

Please sign in to comment.