ROVER - Modularization - relocated tracing scripts
Signed-off-by: Mustafa Ozcelikors <mozcelikors@gmail.com>
diff --git a/rover/scripts/tracing/ListThreads.sh b/rover/scripts/tracing/ListThreads.sh
new file mode 100644
index 0000000..436d16f
--- /dev/null
+++ b/rover/scripts/tracing/ListThreads.sh
@@ -0,0 +1,70 @@
+#!/bin/bash
+# Copyright (c) 2017 FH Dortmund and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Description:
+# This script is used for estimating the granularity of a thread by
+# making use of its name and period.
+# Example usage: sudo ./ListThreads.sh -n <process_name>
+#
+# Authors:
+# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
+#
+
+helpwindow ()
+{
+ echo "Arguments for ListThreads.sh are:"
+ echo "#################################################"
+ echo "-h or --help : Show these help instructions"
+ echo "-p or --pid : Progress using Process ID"
+ echo "-n or --name : Progress using Process Name (CMD)"
+ echo "#################################################"
+ echo "Example usage: sudo ./ListThreads.sh -n <process_name> "
+ echo "or sudo ./ListThreads.sh -p <pid>"
+}
+
+if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
+ helpwindow
+ exit 0
+fi
+
+while [[ $# -gt 1 ]]
+do
+ key="$1"
+ case $key in
+ -p|--pid)
+ pid="$2"
+ shift
+ ;;
+ -n|--name)
+ process_name="$2"
+ shift
+ ;;
+ *)
+ #Unknown
+ helpwindow
+ ;;
+ esac
+ shift
+done
+
+if ! [[ -z ${pid+x} ]]; then
+ ps H -p $pid -o 'pid tid cmd comm'
+elif ! [[ -z ${process_name+x} ]]; then
+ pid=$(pgrep -f $process_name -o)
+ ps H -p $pid -o 'pid tid cmd comm'
+fi
+
+exit $?
+
+
+
+
+
+
+
+
+
diff --git a/rover/scripts/tracing/MonitorThreads.sh b/rover/scripts/tracing/MonitorThreads.sh
new file mode 100644
index 0000000..501bc3f
--- /dev/null
+++ b/rover/scripts/tracing/MonitorThreads.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+# Copyright (c) 2017 FH Dortmund and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Description:
+# This script is used for monitoring core utilization of all threads of
+# a process by the process name.
+# Right usage: ./MonitorThreads.sh -n <process_name>
+# ./MonitorThreads.sh -p <pid>
+# You can access the help instructions by typing ./MonitorThreads.sh --help
+#
+# Authors:
+# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
+#
+
+helpwindow ()
+{
+ echo "Arguments for MonitorThreads.sh are:"
+ echo "#################################################"
+ echo "-h or --help : Show these help instructions"
+ echo "-p or --pid : Progress using Process ID"
+ echo "-n or --name : Progress using Process Name (CMD)"
+ echo "#################################################"
+ echo "Example usage: sudo ./MonitorThreads -n MyApplication"
+ echo " sudo ./MonitorThreads -p 1550"
+}
+
+if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
+ helpwindow
+ exit 0
+fi
+
+while [[ $# -gt 1 ]]
+do
+ key="$1"
+ case $key in
+ -p|--pid)
+ pid="$2"
+ shift
+ ;;
+ -n|--name)
+ process_name="$2"
+ shift
+ ;;
+ *)
+ #Unknown
+ helpwindow
+ ;;
+ esac
+ shift
+done
+
+
+if ! [[ -z ${pid+x} ]]; then
+ ps H -p $pid -o 'pid tid cmd comm'
+ top H -p $pid
+elif ! [[ -z ${process_name+x} ]]; then
+ pid=$(pgrep -f $process_name -o)
+ ps H -p $pid -o 'pid tid cmd comm'
+ top H -p $pid
+fi
+
+exit $?
diff --git a/rover/scripts/tracing/ProfileAThread.sh b/rover/scripts/tracing/ProfileAThread.sh
new file mode 100644
index 0000000..e8c31f6
--- /dev/null
+++ b/rover/scripts/tracing/ProfileAThread.sh
@@ -0,0 +1,86 @@
+#!/bin/bash
+# Copyright (c) 2017 FH Dortmund and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Description:
+# This script is used for estimating the granularity of a thread by
+# making use of its name and period.
+# Example usage: ./ProfileAThread.sh -n <process_name> -t <period> -c <path/to/perf/obj>
+# <period> is in seconds
+#
+# Authors:
+# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
+#
+
+helpwindow ()
+{
+ echo "Arguments for ProfileAThread.sh are:"
+ echo "#################################################"
+ echo "-h or --help : Show these help instructions"
+ echo "-p or --pid : Progress using Process ID"
+ echo "-n or --name : Progress using Process Name (CMD)"
+ echo "-t or --time : Specify period in seconds to analyze"
+ echo "-c or --command : Perf command or path to perf object to run"
+ echo "#################################################"
+ echo "Example usage: sudo ./ProfileAThread.sh -n <process_name> -t <period> -c <path/to/perf/obj>"
+ echo "or sudo ./ProfileAThread.sh -p <pid> -t <period> -c <path/to/perf/obj>"
+}
+
+if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
+ helpwindow
+ exit 0
+fi
+
+while [[ $# -gt 1 ]]
+do
+ key="$1"
+ case $key in
+ -p|--pid)
+ pid="$2"
+ shift
+ ;;
+ -n|--name)
+ process_name="$2"
+ shift
+ ;;
+ -t|--time)
+ period="$2"
+ shift
+ ;;
+ -c|--command)
+ perf_command="$2"
+ shift
+ ;;
+ *)
+ #Unknown
+ helpwindow
+ ;;
+ esac
+ shift
+done
+
+if ! [[ -z ${perf_command+x} ]]; then
+ if ! [[ -z ${period+x} ]]; then
+ if ! [[ -z ${pid+x} ]]; then
+ $perf_command stat -e instructions:u -p $pid -- sleep $period
+ elif ! [[ -z ${process_name+x} ]]; then
+ pid=$(pgrep -f $process_name -o)
+ $perf_command stat -e instructions:u -p $pid -- sleep $period
+ fi
+ else
+ helpwindow
+ fi
+else
+ helpwindow
+fi
+
+exit $?
+
+
+
+
+
+
diff --git a/rover/scripts/tracing/ProfileThreadsOfAProcess.sh b/rover/scripts/tracing/ProfileThreadsOfAProcess.sh
new file mode 100644
index 0000000..f2839b0
--- /dev/null
+++ b/rover/scripts/tracing/ProfileThreadsOfAProcess.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+# Copyright (c) 2017 FH Dortmund and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Description:
+# This script is used for estimating the granularity of a thread by
+# making use of its name and period.
+# Example usage: ./ProfileThreadsOfAProcess.sh -n <process_name> -t <period> -c <path/to/perf/obj>
+# <period> is in milliseconds
+#
+# Authors:
+# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
+#
+
+helpwindow ()
+{
+ echo "Arguments for ProfileThreadsOfAProcess.sh are:"
+ echo "#################################################"
+ echo "-h or --help : Show these help instructions"
+ echo "-p or --pid : Progress using Process ID"
+ echo "-n or --name : Progress using Process Name (CMD)"
+ echo "-t or --time : Specify period in milliseconds to analyze"
+ echo "-c or --command : Perf command or path to perf object to run"
+ echo "#################################################"
+ echo "Example usage: sudo ./ProfileThreadsOfAProcess.sh -n <process_name> -t <period> -c <path/to/perf/obj>"
+ echo "or sudo ./ProfileThreadsOfAProcess.sh -p <pid> -t <period> -c <path/to/perf/obj>"
+}
+
+if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
+ helpwindow
+ exit 0
+fi
+
+while [[ $# -gt 1 ]]
+do
+ key="$1"
+ case $key in
+ -p|--pid)
+ pid="$2"
+ shift
+ ;;
+ -n|--name)
+ process_name="$2"
+ shift
+ ;;
+ -t|--time)
+ period="$2"
+ shift
+ ;;
+ -c|--command)
+ perf_command="$2"
+ shift
+ ;;
+ *)
+ #Unknown
+ helpwindow
+ ;;
+ esac
+ shift
+done
+
+if ! [[ -z ${perf_command+x} ]]; then
+ if ! [[ -z ${period+x} ]]; then
+ if ! [[ -z ${pid+x} ]]; then
+ $perf_command stat --per-thread -e instructions:u -p $pid -I $period
+ elif ! [[ -z ${process_name+x} ]]; then
+ pid=$(pgrep -f $process_name -o)
+ $perf_command stat --per-thread -e instructions:u -p $pid -I $period
+ fi
+ else
+ helpwindow
+ fi
+else
+ helpwindow
+fi
+
+exit $?
+
+
diff --git a/rover/scripts/tracing/TraceLinuxProcesses.sh b/rover/scripts/tracing/TraceLinuxProcesses.sh
new file mode 100644
index 0000000..e072a87
--- /dev/null
+++ b/rover/scripts/tracing/TraceLinuxProcesses.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+# Copyright (c) 2017 FH Dortmund and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Description:
+# Linux shell (bash) script that traces linux processes and converts
+# the trace to common tracing format (CTF).
+# perf module should be compiles with libbabeltrace in order to run
+# the tracing utility correctly.
+# Created out directory will contain Processes_List.txt (process IDs
+# are listed), perf.data (trace in perf format), ctf_trace.tar.gz
+# (trace in ctf format)
+# The ctf_format.tar.gz can be extracted in order to visualize the
+# perf streams using Eclipse TraceCompass.
+#
+# Usage:
+# sudo ./TraceLinuxProcesses.sh -p <path/to/perf> -n <trace_name> -t <period_to_trace>
+#
+# Authors:
+# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
+#
+
+helpwindow ()
+{
+ echo "Arguments for TraceLinuxProcesses.sh are:"
+ echo "#################################################"
+ echo "-h or --help : Show these help instructions"
+ echo "-p or --path-to-perf : Path to Perf"
+ echo "-n or --name : Trace name to be created"
+ echo "-t or --time : Specify period in seconds to trace"
+ echo "#################################################"
+ echo "Example usage: sudo ./TraceLinuxProcesses.sh -p <path/to/perf> -n <trace_name> -t <period_to_trace>"
+}
+
+if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
+ helpwindow
+ exit 0
+fi
+
+while [[ $# -gt 1 ]]
+do
+ key="$1"
+ case $key in
+ -p|--path-to-perf)
+ perf_directory="$2"
+ shift
+ ;;
+ -n|--name)
+ trace_name="$2"
+ shift
+ ;;
+ -t|--time)
+ seconds="$2"
+ shift
+ ;;
+ *)
+ #Unknown
+ helpwindow
+ ;;
+ esac
+ shift
+done
+
+if ! [[ -z ${perf_directory+x} ]]; then
+ if ! [[ -z ${trace_name+x} ]]; then
+ if ! [[ -z ${seconds+x} ]]; then
+ echo "### Creating directory.."
+ sudo mkdir out_$trace_name/
+ echo "### Writing out process names.."
+ ps -aux >> out_$trace_name/Processes_List.txt
+ echo "### Tracing with perf for $seconds seconds.."
+ sudo $perf_directory/./perf sched record -o out_$trace_name/perf.data -- sleep $seconds
+ echo "### Converting to data to CTF (Common Tracing Format).."
+ sudo LD_LIBRARY_PATH=/opt/libbabeltrace/lib $perf_directory/./perf data convert -i out_$trace_name/perf.data --to-ctf=./ctf
+ sudo tar -czvf out_$trace_name/trace.tar.gz ctf/
+ sudo rm -rf ctf/
+
+ echo "### Process IDs are written to out_$trace_name/Processes_List.txt"
+ echo "### Trace in Perf format is written to out_$trace_name/perf.data"
+ echo "### Trace in CTF format is written to out_$trace_name/ctf_trace.tar.gz"
+ echo "### Exiting.."
+ else
+ helpwindow
+ fi
+ else
+ helpwindow
+ fi
+else
+ helpwindow
+fi
+
+exit $?
+
+
+
+
diff --git a/rover/src/tracing/ListThreads.sh b/rover/src/tracing/ListThreads.sh
deleted file mode 100644
index 30fc28b..0000000
--- a/rover/src/tracing/ListThreads.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2017 FH Dortmund and others
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Description:
-# This script is used for listing thread names (if registered by pthread_setname_np)
-# and thread IDs of all threads of a process by the process name.
-# Right usage: ListThreads.sh <process_name>
-# e.g. ListThreads.sh <process_name>
-#
-# Authors:
-# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
-#
-
-args=("$@")
-process_name=${args[0]}
-
-if [ "$#" -ne 1 ]; then
- echo "Entered arguments seem to be incorrect"
- echo "Right usage: ListThreads.sh <process_name>"
- echo "e.g. ListThreads.sh <process_name>"
-else
- pid=$(pgrep -f $process_name -o)
- ps H -p $pid -o 'pid tid cmd comm'
-fi
-
-
-
-
-
diff --git a/rover/src/tracing/MonitorThreads.sh b/rover/src/tracing/MonitorThreads.sh
deleted file mode 100644
index 89c2e71..0000000
--- a/rover/src/tracing/MonitorThreads.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2017 FH Dortmund and others
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Description:
-# This script is used for monitoring core utilization of all threads of
-# a process by the process name.
-# Right usage: MonitorThreads.sh <process_name>
-# e.g. MonitorThreads.sh <process_name>
-#
-# Authors:
-# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
-#
-
-args=("$@")
-process_name=${args[0]}
-
-if [ "$#" -ne 1 ]; then
- echo "Entered arguments seem to be incorrect"
- echo "Right usage: MonitorThreads.sh <process_name>"
- echo "e.g. MonitorThreads.sh <process_name>"
-else
- pid=$(pgrep -f $process_name -o)
- top H -p $pid
-fi
-
-
-
-
-
diff --git a/rover/src/tracing/ProfileAThread.sh b/rover/src/tracing/ProfileAThread.sh
deleted file mode 100644
index 0b1e1be..0000000
--- a/rover/src/tracing/ProfileAThread.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2017 FH Dortmund and others
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Description:
-# This script is used for estimating the granularity of a thread by
-# making use of its name and period.
-# Right usage: ProfileAThread.sh <process_name> <period> <perf_command>
-# e.g. ProfileAThread.sh <process_name> <period> <perf_command>
-#
-# Authors:
-# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
-#
-
-args=("$@")
-process_name=${args[0]}
-period=${args[1]}
-perf_command=${args[2]}
-
-if [ "$#" -ne 3 ]; then
- echo "Entered arguments seem to be incorrect"
- echo "Right usage: ProfileAThread.sh <process_name> <period> <perf_command>"
- echo "e.g. ProfileAThread.sh parking_task 0.45 perf"
-else
- pid=$(pgrep -f $process_name -o)
- $perf_command stat -e instructions:u -p $pid -- sleep $period
-fi
-
-
-
-
-
diff --git a/rover/src/tracing/ProfileThreadsOfAProcess.sh b/rover/src/tracing/ProfileThreadsOfAProcess.sh
deleted file mode 100644
index a0eae0c..0000000
--- a/rover/src/tracing/ProfileThreadsOfAProcess.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2017 FH Dortmund and others
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Description:
-# This script is used for estimating the granularity of a thread by
-# making use of its name and period.
-# Right usage: ProfileThreadsOfAProcess.sh <process_name> <period> <perf_command>
-# e.g. ProfileThreadsOfAProcess.sh <process_name> <period> <perf_command>
-# <period> is in milliseconds
-#
-# Authors:
-# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
-#
-
-args=("$@")
-process_name=${args[0]}
-period=${args[1]}
-perf_command=${args[2]}
-
-if [ "$#" -ne 3 ]; then
- echo "Entered arguments seem to be incorrect"
- echo "Right usage: ProfileThreadsOfAProcess.sh <process_name> <period> <perf_command>"
- echo "e.g. ProfileThreadsOfAProcess.sh parking_task 450 perf"
- echo "<period> is in milliseconds"
-else
- pid=$(pgrep -f $process_name -o)
- $perf_command stat --per-thread -e instructions:u -p $pid -I $period
-fi
-
-
-
-
-
diff --git a/rover/src/tracing/TraceLinuxProcesses.sh b/rover/src/tracing/TraceLinuxProcesses.sh
deleted file mode 100644
index 5a1275c..0000000
--- a/rover/src/tracing/TraceLinuxProcesses.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2017 FH Dortmund and others
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Description:
-# Linux shell (bash) script that traces linux processes and converts
-# the trace to common tracing format (CTF).
-# perf module should be compiles with libbabeltrace in order to run
-# the tracing utility correctly.
-# Created out directory will contain Processes_List.txt (process IDs
-# are listed), perf.data (trace in perf format), ctf_trace.tar.gz
-# (trace in ctf format)
-# The ctf_format.tar.gz can be extracted in order to visualize the
-# perf streams using Eclipse TraceCompass.
-#
-# Usage:
-# sudo TraceLinuxProcesses.sh <trace_name> <period> <path_to_perf>
-# e.g. sudo TraceLinuxProcesses.sh APP4MC_Trace 15 /home/pi/linux/tools/perf
-# <trace_name>: Trace name for the output
-# <period>: Amount of time in seconds to trace the system
-# <path_to_perf>: Installed perf directory that contains ./perf
-#
-# Authors:
-# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
-#
-
-args=("$@")
-trace_name=${args[0]}
-seconds=${args[1]}
-perf_directory=${args[2]}
-
-if [ "$#" -ne 3 ]; then
- echo "Entered arguments seem to be incorrect"
- echo "Right usage: sudo TraceLinuxProcesses.sh <trace_name> <period> <path_to_perf>"
- echo "e.g. sudo TraceLinuxProcesses.sh APP4MC_Trace 15 /home/pi/linux/tools/perf"
-else
- echo "### Creating directory.."
- sudo mkdir out_$trace_name/
- echo "### Writing out process names.."
- ps -aux >> out_$trace_name/Processes_List.txt
- echo "### Tracing with perf for $seconds seconds.."
- sudo $perf_directory/./perf sched record -o out_$trace_name/perf.data -- sleep $seconds
- echo "### Converting to data to CTF (Common Tracing Format).."
- sudo LD_LIBRARY_PATH=/opt/libbabeltrace/lib $perf_directory/./perf data convert -i out_$trace_name/perf.data --to-ctf=./ctf
- sudo tar -czvf out_$trace_name/trace.tar.gz ctf/
- sudo rm -rf ctf/
-
- echo "### Process IDs are written to out_$trace_name/Processes_List.txt"
- echo "### Trace in Perf format is written to out_$trace_name/perf.data"
- echo "### Trace in CTF format is written to out_$trace_name/ctf_trace.tar.gz"
- echo "### Exiting.."
-fi
-
-
-
-
-