release-request-a2143a0f-bf92-4fa8-ad68-7346e7505126-for-git_oc-dr1-release-4067638 snap-temp-L84900000070511178

Change-Id: I172fbc67fbb67d3df3fe2708c2eb61d16a48a039
diff --git a/libs/utils/trace.py b/libs/utils/trace.py
index ada8db4..d3cabed 100644
--- a/libs/utils/trace.py
+++ b/libs/utils/trace.py
@@ -78,7 +78,9 @@
                  normalize_time=True,
                  trace_format='FTrace',
                  plots_dir=None,
-                 plots_prefix=''):
+                 plots_prefix='',
+                 event_callbacks={},
+                 build_df=True):
 
         # The platform used to run the experiments
         self.platform = platform
@@ -108,6 +110,10 @@
         # List of events required by user
         self.events = []
 
+        # Stuff for event callback support
+        self.event_callbacks = event_callbacks
+        self.build_df = build_df
+
         # List of events available in the parsed trace
         self.available_events = []
 
@@ -135,6 +141,11 @@
         self.__registerTraceEvents(events)
         self.__parseTrace(data_dir, tasks, window, normalize_time,
                           trace_format)
+
+        if not self.build_df:
+            self._log.info('Data frames not built for the trace')
+            return
+
         self.__computeTimeSpan()
 
         # Minimum and Maximum x_time to use for all plots
@@ -242,7 +253,9 @@
             raise ValueError("Unknown trace format {}".format(trace_format))
 
         self.ftrace = trace_class(path, scope="custom", events=self.events,
-                                  window=window, normalize_time=normalize_time)
+                                  window=window, normalize_time=normalize_time,
+                                  event_callbacks=self.event_callbacks,
+                                  build_df=self.build_df)
 
         # Load Functions profiling data
         has_function_stats = self._loadFunctionsStats(path)
@@ -253,6 +266,8 @@
             if has_function_stats:
                 self._log.info('Trace contains only functions stats')
                 return
+            elif not self.build_df:
+                return
             raise ValueError('The trace does not contain useful events '
                              'nor function stats')
 
diff --git a/libs/utils/trace_callback.py b/libs/utils/trace_callback.py
new file mode 100644
index 0000000..6115adf
--- /dev/null
+++ b/libs/utils/trace_callback.py
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: Apache-2.0
+#
+# Copyright (C) 2017, Google and contributors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from trace import Trace
+
+class TraceCallback(object):
+    """
+    The TraceCallbacks object which is used for event-driven trace analysis
+    """
+    def __init__(self, trace_path, callbacks):
+        self.trace_obj = Trace(None, trace_path, callbacks.keys(), event_callbacks=callbacks, build_df=False);
diff --git a/src/shell/android-post.sh b/src/shell/android-post.sh
index cd3292f..57bf4a5 100644
--- a/src/shell/android-post.sh
+++ b/src/shell/android-post.sh
@@ -11,15 +11,20 @@
 		export PYTHONPATH=$lisadir:$PYTHONPATH
 		echo "Welcome to LISA $TARGET_PRODUCT environment"
 		echo "Target-specific scripts are located in $lisadir"
-
-		monsoon_path="$ANDROID_BUILD_TOP/cts/tools/utils/"
-		export PATH="$monsoon_path:$PATH"
-		echo "Monsoon will run from: $monsoon_path"
 	else
 		echo "LISA scripts don't exist for $TARGET_PRODUCT, skipping"
 	fi
 fi
 
+if [ -z  "$CATAPULT_HOME" ]; then
+        export CATAPULT_HOME=$LISA_HOME/../chromium-trace/catapult/
+        echo "Systrace will run from: $(readlink -f $CATAPULT_HOME)"
+fi
+
+monsoon_path="$LISA_HOME/../../cts/tools/utils/"
+export PATH="$monsoon_path:$PATH"
+echo "Monsoon will run from: $(readlink -f $monsoon_path/monsoon.py)"
+
 export PYTHONPATH=$LISA_HOME/../devlib:$PYTHONPATH
 export PYTHONPATH=$LISA_HOME/../trappy:$PYTHONPATH
 export PYTHONPATH=$LISA_HOME/../bart:$PYTHONPATH