tools/cygprofile/orderfile_generator_backend.py
def Generate(self):
    """Generates and maybe upload an order."""
    assert (bool(self._options.profile) ^
            bool(self._options.manual_symbol_offsets))
    if self._options.system_health_orderfile and not self._options.profile:
      raise AssertionError('--system_health_orderfile must be not be used '
                           'with --skip-profile')
    if (self._options.manual_symbol_offsets and
        not self._options.system_health_orderfile):
      raise AssertionError('--manual-symbol-offsets must be used with '
                           '--system_health_orderfile.')

    if self._options.profile:
      try:
        _UnstashOutputDirectory(self._instrumented_out_dir)
        self._compiler = ClankCompiler(
            self._instrumented_out_dir, self._step_recorder, self._options.arch,
            self._options.use_goma, self._options.goma_dir,
            self._options.system_health_orderfile, self._monochrome,
            self._options.public, self._GetPathToOrderfile())
        if not self._options.pregenerated_profiles:
          # If there are pregenerated profiles, the instrumented build should
          # not be changed to avoid invalidating the pregenerated profile
          # offsets.
          self._compiler.CompileChromeApk(instrumented=True,
                                          use_call_graph=
                                          self._options.use_call_graph)
        self._GenerateAndProcessProfile()
        self._MaybeArchiveOrderfile(self._GetUnpatchedOrderfileFilename())
      finally:
        _StashOutputDirectory(self._instrumented_out_dir)
    elif self._options.manual_symbol_offsets:
      assert self._options.manual_libname
      assert self._options.manual_objdir
      with open(self._options.manual_symbol_offsets) as f:
        symbol_offsets = [int(x) for x in f]
      processor = process_profiles.SymbolOffsetProcessor(
          self._compiler.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(),
                           self._GetPathToOrderfile())
      try:
        _UnstashOutputDirectory(self._uninstrumented_out_dir)
        self._compiler = ClankCompiler(
            self._uninstrumented_out_dir, self._step_recorder,
            self._options.arch, self._options.use_goma, self._options.goma_dir,
            self._options.system_health_orderfile, self._monochrome,
            self._options.public, self._GetPathToOrderfile())

        self._compiler.CompileLibchrome(instrumented=False,
                                        use_call_graph=False)
        self._PatchOrderfile()
        # Because identical code folding is a bit different with and without
        # the orderfile build, we need to re-patch the orderfile with code
        # folding as close to the final version as possible.
        self._compiler.CompileLibchrome(instrumented=False,
                                        use_call_graph=False, force_relink=True)
        self._PatchOrderfile()
        self._compiler.CompileLibchrome(instrumented=False,
                                        use_call_graph=False, force_relink=True)
        self._VerifySymbolOrder()
        self._MaybeArchiveOrderfile(self._GetPathToOrderfile())
      finally:
        _StashOutputDirectory(self._uninstrumented_out_dir)

    if self._options.benchmark:
      self._output_data['orderfile_benchmark_results'] = self.RunBenchmark(
          self._uninstrumented_out_dir)
      self._output_data['no_orderfile_benchmark_results'] = self.RunBenchmark(
          self._no_orderfile_out_dir, no_orderfile=True)

    if self._options.buildbot:
      self._orderfile_updater._GitStash()
    self._step_recorder.EndStep()
    return not self._step_recorder.ErrorRecorded()
Generates and maybe upload an order.
Generates and maybe upload an order.
Generates and maybe upload an order .
def Generate(self):
    assert (bool(self._options.profile) ^
            bool(self._options.manual_symbol_offsets))
    if self._options.system_health_orderfile and not self._options.profile:
      raise AssertionError('--system_health_orderfile must be not be used '
                           'with --skip-profile')
    if (self._options.manual_symbol_offsets and
        not self._options.system_health_orderfile):
      raise AssertionError('--manual-symbol-offsets must be used with '
                           '--system_health_orderfile.')
    if self._options.profile:
      try:
        _UnstashOutputDirectory(self._instrumented_out_dir)
        self._compiler = ClankCompiler(
            self._instrumented_out_dir, self._step_recorder, self._options.arch,
            self._options.use_goma, self._options.goma_dir,
            self._options.system_health_orderfile, self._monochrome,
            self._options.public, self._GetPathToOrderfile())
        if not self._options.pregenerated_profiles:
          self._compiler.CompileChromeApk(instrumented=True,
                                          use_call_graph=
                                          self._options.use_call_graph)
        self._GenerateAndProcessProfile()
        self._MaybeArchiveOrderfile(self._GetUnpatchedOrderfileFilename())
      finally:
        _StashOutputDirectory(self._instrumented_out_dir)
    elif self._options.manual_symbol_offsets:
      assert self._options.manual_libname
      assert self._options.manual_objdir
      with open(self._options.manual_symbol_offsets) as f:
        symbol_offsets = [int(x) for x in f]
      processor = process_profiles.SymbolOffsetProcessor(
          self._compiler.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:  
        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(),
                           self._GetPathToOrderfile())
      try:
        _UnstashOutputDirectory(self._uninstrumented_out_dir)
        self._compiler = ClankCompiler(
            self._uninstrumented_out_dir, self._step_recorder,
            self._options.arch, self._options.use_goma, self._options.goma_dir,
            self._options.system_health_orderfile, self._monochrome,
            self._options.public, self._GetPathToOrderfile())
        self._compiler.CompileLibchrome(instrumented=False,
                                        use_call_graph=False)
        self._PatchOrderfile()
        self._compiler.CompileLibchrome(instrumented=False,
                                        use_call_graph=False, force_relink=True)
        self._PatchOrderfile()
        self._compiler.CompileLibchrome(instrumented=False,
                                        use_call_graph=False, force_relink=True)
        self._VerifySymbolOrder()
        self._MaybeArchiveOrderfile(self._GetPathToOrderfile())
      finally:
        _StashOutputDirectory(self._uninstrumented_out_dir)
    if self._options.benchmark:
      self._output_data['orderfile_benchmark_results'] = self.RunBenchmark(
          self._uninstrumented_out_dir)
      self._output_data['no_orderfile_benchmark_results'] = self.RunBenchmark(
          self._no_orderfile_out_dir, no_orderfile=True)
    if self._options.buildbot:
      self._orderfile_updater._GitStash()
    self._step_recorder.EndStep()
    return not self._step_recorder.ErrorRecorded()
def Generate ( self ) : assert ( bool ( self . _options . profile ) ^ bool ( self . _options . manual_symbol_offsets ) ) if self . _options . system_health_orderfile and not self . _options . profile : raise AssertionError ( '--system_health_orderfile must be not be used ' 'with --skip-profile' ) if ( self . _options . manual_symbol_offsets and not self . _options . system_health_orderfile ) : raise AssertionError ( '--manual-symbol-offsets must be used with ' '--system_health_orderfile.' ) if self . _options . profile : try : _UnstashOutputDirectory ( self . _instrumented_out_dir ) self . _compiler = ClankCompiler ( self . _instrumented_out_dir , self . _step_recorder , self . _options . arch , self . _options . use_goma , self . _options . goma_dir , self . _options . system_health_orderfile , self . _monochrome , self . _options . public , self . _GetPathToOrderfile ( ) ) if not self . _options . pregenerated_profiles : self . _compiler . CompileChromeApk ( instrumented = True , use_call_graph = self . _options . use_call_graph ) self . _GenerateAndProcessProfile ( ) self . _MaybeArchiveOrderfile ( self . _GetUnpatchedOrderfileFilename ( ) ) finally : _StashOutputDirectory ( self . _instrumented_out_dir ) elif self . _options . manual_symbol_offsets : assert self . _options . manual_libname assert self . _options . manual_objdir with open ( self . _options . manual_symbol_offsets ) as f : symbol_offsets = [ int ( x ) for x in f ] processor = process_profiles . SymbolOffsetProcessor ( self . _compiler . 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 : 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 ( ) , self . _GetPathToOrderfile ( ) ) try : _UnstashOutputDirectory ( self . _uninstrumented_out_dir ) self . _compiler = ClankCompiler ( self . _uninstrumented_out_dir , self . _step_recorder , self . _options . arch , self . _options . use_goma , self . _options . goma_dir , self . _options . system_health_orderfile , self . _monochrome , self . _options . public , self . _GetPathToOrderfile ( ) ) self . _compiler . CompileLibchrome ( instrumented = False , use_call_graph = False ) self . _PatchOrderfile ( ) self . _compiler . CompileLibchrome ( instrumented = False , use_call_graph = False , force_relink = True ) self . _PatchOrderfile ( ) self . _compiler . CompileLibchrome ( instrumented = False , use_call_graph = False , force_relink = True ) self . _VerifySymbolOrder ( ) self . _MaybeArchiveOrderfile ( self . _GetPathToOrderfile ( ) ) finally : _StashOutputDirectory ( self . _uninstrumented_out_dir ) if self . _options . benchmark : self . _output_data [ 'orderfile_benchmark_results' ] = self . RunBenchmark ( self . _uninstrumented_out_dir ) self . _output_data [ 'no_orderfile_benchmark_results' ] = self . RunBenchmark ( self . _no_orderfile_out_dir , no_orderfile = True ) if self . _options . buildbot : self . _orderfile_updater . _GitStash ( ) self . _step_recorder . EndStep ( ) return not self . _step_recorder . ErrorRecorded ( )
Generates and maybe upload an order.
Generates and maybe upload an order .
"""Generates and maybe upload an order.""" # If there are pregenerated profiles, the instrumented build should # not be changed to avoid invalidating the pregenerated profile # offsets. # Either None or empty is a problem. # Because identical code folding is a bit different with and without # the orderfile build, we need to re-patch the orderfile with code # folding as close to the final version as possible.
self