Add the perf inject commands in the art script.

Test: art script
Change-Id: Icb3786a3fafcda6f93d1af1c16f4f1c1e439476e
diff --git a/compiler/jit/jit_logger.h b/compiler/jit/jit_logger.h
index 9d1f307..79f47f8 100644
--- a/compiler/jit/jit_logger.h
+++ b/compiler/jit/jit_logger.h
@@ -53,7 +53,7 @@
 //
 //     Command line Example:
 //       $ perf record -k mono dalvikvm -Xcompiler-option --generate-debug-info -cp <classpath> Test
-//       $ perf inject -i perf.data -o perf.data.jitted
+//       $ perf inject -j -i perf.data -o perf.data.jitted
 //       $ perf report -i perf.data.jitted
 //       $ perf annotate -i perf.data.jitted
 //     NOTE:
diff --git a/tools/art b/tools/art
index 9471c13..a811951 100755
--- a/tools/art
+++ b/tools/art
@@ -615,7 +615,8 @@
 fi
 
 if [ "$PERF" != "" ]; then
-  LAUNCH_WRAPPER="perf record -g --call-graph dwarf -F 10000 -o $ANDROID_DATA/perf.data -e cycles:u $LAUNCH_WRAPPER"
+  # -k is for supporting jitted code.
+  LAUNCH_WRAPPER="perf record -k 1 -g --call-graph dwarf -F 10000 -o $ANDROID_DATA/perf.data -e cycles:u $LAUNCH_WRAPPER"
   DEX2OAT_FLAGS+=(--generate-debug-info)
 fi
 
@@ -685,8 +686,12 @@
 if [ "$PERF" != "" ]; then
   if [ "$PERF" = report ]; then
     perf report -i $ANDROID_DATA/perf.data
+  else
+    # Inject jitted code in perf.data. Keep the old perf.data for debugging.
+    mv $ANDROID_DATA/perf.data $ANDROID_DATA/perf.data.old
+    perf inject -j -i $ANDROID_DATA/perf.data.old -o $ANDROID_DATA/perf.data
+    echo "Perf data saved in: $ANDROID_DATA/perf.data. Generated oat files not removed."
   fi
-  echo "Perf data saved in: $ANDROID_DATA/perf.data. Generated oat files not removed."
 else
   # Perf needs the odex files we generate for proper symbolization, so only remove them
   # when not running with perf.