Permalink
Browse files

Select the proper version of OProfile tools based on host OS informat…

…ion.

android-bc_triage 2162989
  • Loading branch information...
1 parent 1434507 commit d6eeae3f5dd027a2d4e6b702cc07db4a605848c0 Ben Cheng committed Oct 7, 2009
Showing with 28 additions and 5 deletions.
  1. +28 −5 opimport_pull
View
@@ -5,26 +5,48 @@ import re
import sys
def PrintUsage():
- print "Usage:" + sys.argv[0] + " dir"
+ print "Usage:" + sys.argv[0] + " [-r] dir"
+ print " -r : reuse the directory if it already exists"
print " dir: directory on the host to store profile results"
-if (len(sys.argv) != 2):
+if (len(sys.argv) > 3):
PrintUsage()
sys.exit(1)
+# identify 32-bit vs 64-bit platform
+stream = os.popen("uname -m")
+arch_name = stream.readline().rstrip("\n");
+stream.close()
+
+# default path is prebuilt/linux-x86/oprofile
+# for 64-bit OS, use prebuilt/linux-x86_64/oprofile instead
+if arch_name == "x86_64":
+ arch_path = "/../../linux-x86_64/oprofile"
+else:
+ arch_path = ""
+
try:
oprofile_event_dir = os.environ['OPROFILE_EVENTS_DIR']
except:
print "OPROFILE_EVENTS_DIR not set. Run \". envsetup.sh\" first"
sys.exit(1)
-output_dir = sys.argv[1];
+if sys.argv[1] == "-r" :
+ replace_dir = 1
+ output_dir = sys.argv[2]
+else:
+ replace_dir = 0
+ output_dir = sys.argv[1]
+
+if (os.path.exists(output_dir) and (replace_dir == 1)):
+ os.system("rm -fr " + output_dir)
try:
os.makedirs(output_dir)
except:
if os.path.exists(output_dir):
print "Directory already exists:", output_dir
+ print "Try \"" + sys.argv[0] + " -r " + output_dir + "\""
else:
print "Cannot create", output_dir
sys.exit(1)
@@ -60,11 +82,12 @@ for line in stream:
if not os.path.exists(dir):
os.makedirs(dir)
- cmd = oprofile_event_dir + "/bin/opimport -a " + oprofile_event_dir + \
+ cmd = oprofile_event_dir + arch_path + "/bin/opimport -a " + \
+ oprofile_event_dir + \
"/abi/arm_abi -o samples" + middle_part + "/" + file_name + " " + line
os.system(cmd)
stream.close()
# short summary of profiling results
-os.system(oprofile_event_dir + "/bin/opreport --session-dir=.")
+os.system(oprofile_event_dir + arch_path + "/bin/opreport --session-dir=.")

0 comments on commit d6eeae3

Please sign in to comment.