aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2012-01-06 15:35:28 -0800
committerBen Cheng <bccheng@google.com>2012-01-06 15:35:28 -0800
commite4b944c9df64336e4c2dd87be5653077ff6c415c (patch)
treedb9be1ced6046ec3a2e407ef8ee62b95bc3b272b
parent529d868851ce83328c89429d256e68afe320c51d (diff)
downloadoprofile-e4b944c9df64336e4c2dd87be5653077ff6c415c.tar.gz
Enhance the oprofile_android harness to support opannotate.
Also s/objdump/arm-eabi-objdump in opannotate.cpp. Change-Id: I51b35da926a9ad189c6758c3f10084a4b9766524
-rwxr-xr-xoprofile_android37
-rw-r--r--pp/opannotate.cpp4
2 files changed, 41 insertions, 0 deletions
diff --git a/oprofile_android b/oprofile_android
index 7716eac..4f1a940 100755
--- a/oprofile_android
+++ b/oprofile_android
@@ -40,6 +40,7 @@ except:
opimport_bin = os.path.join(oprofile_bin_dir, 'opimport')
opreport_bin = os.path.join(oprofile_bin_dir, 'opreport')
+opannotate_bin = os.path.join(oprofile_bin_dir, 'opannotate')
# Find symbol directories
@@ -136,6 +137,11 @@ class Tool:
print " -c, --callgraph : show callgraph"
print " --help : show help for additional opreport options"
print
+ print " annotate [args] : generate annotation with specified arguments to 'annotation'"
+ print " -s, --source : show source"
+ print " -a, --assembly : show assembly"
+ print " --help : show help for additional opannotate options"
+ print
def main(self):
rc = self.do_main()
@@ -187,6 +193,8 @@ class Tool:
rc = self.do_import(command_args)
elif command == 'report':
rc = self.do_report(command_args)
+ elif command == 'annotate':
+ rc = self.do_annotate(command_args)
else:
print '* Unknown command: ' + command
return 2
@@ -411,6 +419,13 @@ class Tool:
return 1
return 0
+ def do_annotate(self, command_args):
+ rc, output = self._execute_opannotate(command_args)
+ if rc != 0:
+ print '* Failed to generate annotation.'
+ return 1
+ return 0
+
def _opcontrol_verbose_arg(self):
if self.verbose:
return ['--verbose']
@@ -422,6 +437,28 @@ class Tool:
'--session-dir=' + self.session_dir,
'--image-path=' + symbols_dir + ',' + system_dir] + args)
+ def _execute_opannotate(self, command_args):
+ try:
+ opts, args = getopt.getopt(command_args, 'sa', ['source', 'assembly',
+ 'help'])
+ except getopt.GetoptError, e:
+ print '* Unsupported opannotate command arguments:', str(e)
+ return 2
+
+ anno_flag = []
+ for o, a in opts:
+ if o in ('-s', '--source'):
+ anno_flag.append('-s')
+ if o in ('-a', '--assembly'):
+ anno_flag.append('-a')
+ anno_flag.append('--objdump-params=-Cd')
+ if o in ('--help'):
+ anno_flag.append('--help')
+
+ return execute([opannotate_bin,
+ '--session-dir=' + self.session_dir,
+ '--image-path=' + symbols_dir + ',' + system_dir] + anno_flag + args)
+
# Main entry point
tool = Tool(sys.argv)
rc = tool.main()
diff --git a/pp/opannotate.cpp b/pp/opannotate.cpp
index 5c224aa..8df841b 100644
--- a/pp/opannotate.cpp
+++ b/pp/opannotate.cpp
@@ -417,7 +417,11 @@ void do_one_output_objdump(symbol_collection const & symbols,
}
args.push_back(image_name);
+#if defined(ANDROID)
+ child_reader reader("arm-eabi-objdump", args);
+#else
child_reader reader("objdump", args);
+#endif
if (reader.error()) {
cerr << "An error occur during the execution of objdump:\n\n";
cerr << reader.error_str() << endl;