Orderfile: add manual symbol offsets to the orderfile generator.
Adds --manual-symbol-offsets, --manual-libname and --manual-objdir to
the orderfile generator, allowing custom profiling. For example, with
this one can easily collect profile information manual, process it with
phased_orderfile.py, and then use the resulting symbol lists to produce
a properly patched orderfile that is suitable for performance comparison
against the production orderfile.
Bug: 758566
Change-Id: I0e41319dfcd537cd7f076e0236dc96b853dd7a4f
Reviewed-on: https://chromium-review.googlesource.com/1095274
Reviewed-by: Benoit L <lizeb@chromium.org>
Commit-Queue: Matthew Cary <mattcary@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567284}
diff --git a/tools/cygprofile/orderfile_generator_backend.py b/tools/cygprofile/orderfile_generator_backend.py
index 129cc7c..be4d52d 100755
--- a/tools/cygprofile/orderfile_generator_backend.py
+++ b/tools/cygprofile/orderfile_generator_backend.py
@@ -26,6 +26,7 @@
import tempfile
import time
+import cyglog_to_orderfile
import cygprofile_utils
import patch_orderfile
import process_profiles
@@ -615,6 +616,9 @@
profile_uploaded = False
orderfile_uploaded = False
+ assert (bool(self._options.profile) ^
+ bool(self._options.manual_symbol_offsets))
+
if self._options.profile:
try:
_UnstashOutputDirectory(self._instrumented_out_dir)
@@ -630,6 +634,22 @@
finally:
self._DeleteTempFiles()
_StashOutputDirectory(self._instrumented_out_dir)
+ elif self._options.manual_symbol_offsets:
+ assert self._options.manual_libname
+ assert self._options.manual_objdir
+ with file(self._options.manual_symbol_offsets) as f:
+ symbol_offsets = [int(x) for x in f.xreadlines()]
+ processor = process_profiles.SymbolOffsetProcessor(
+ self._options.manual_libname)
+ generator = cyglog_to_orderfile.OffsetOrderfileGenerator(
+ processor, cyglog_to_orderfile.ObjectFileProcessor(
+ self._options.manual_objdir))
+ ordered_sections = generator.GetOrderedSections(symbol_offsets)
+ if not ordered_sections: # Either None or empty is a problem.
+ raise Exception('Failed to get ordered sections')
+ with open(self._GetUnpatchedOrderfileFilename(), 'w') as orderfile:
+ orderfile.write('\n'.join(ordered_sections))
+
if self._options.patch:
if self._options.profile:
self._RemoveBlanks(self._GetUnpatchedOrderfileFilename(),
@@ -711,6 +731,18 @@
parser.add_argument(
'--use-goma', action='store_true', help='Enable GOMA.', default=False)
parser.add_argument('--adb-path', help='Path to the adb binary.')
+
+ parser.add_argument('--manual-symbol-offsets', default=None, type=str,
+ help=('File of list of ordered symbol offsets generated '
+ 'by manual profiling. Must set other --manual* '
+ 'flags if this is used, and must --skip-profile.'))
+ parser.add_argument('--manual-libname', default=None, type=str,
+ help=('Library filename corresponding to '
+ '--manual-symbol-offsets.'))
+ parser.add_argument('--manual-objdir', default=None, type=str,
+ help=('Root of object file directory corresponding to '
+ '--manual-symbol-offsets.'))
+
profile_android_startup.AddProfileCollectionArguments(parser)
return parser