def Run(self):
        """
        Get the user options, format command line for the lower level script and
        run it.

        @return exit code from lower level script
        """

        options, parser = self.ParseCommandLine()

        # Add the directory where this script is located to PATH so other
        # Python scripts can be run from this kit.
        #
        util.AddScriptPath()

        # Get any Pin knobs (not pintool) specific to this module.
        #
        pin_knobs = self.AddPinKnobs()

        # Get the script and options require to run the low levels script for
        # logging.
        #
        # import pdb;  pdb.set_trace()
        cmd, kit_script_path = drd_util.DrDebugScriptCmd(
            'log.py --mpi_options="-np 4"', pin_knobs, options)

        # If use just wants 'pintool_help', then call the appropriate low level
        # script with this option.  Then exit this script.  This needs to be
        # after the call to drd_util.DrDebugScriptCmd() in order to run the
        # script for the correct kit.
        #
        if hasattr(options, 'pintool_help') and options.pintool_help:
            result = drd_util.PintoolHelpCmd(cmd, options)

            return result

        # Module specific setup
        #
        self.Initialize()

        # Always use these options to the script
        #
        cmd += ' --no_print_cmd --mode ' + options.mode

        # Option '--log_options' needs some knobs which are always used
        # and also might have additional knobs from the user.
        #
        log_o = self.GetDrdLogOpt()
        if hasattr(options, 'pintool_options') and options.pintool_options:
            log_o += ' ' + options.pintool_options
        if hasattr(options, 'mode') and options.mode:
            # Need to add PID to pinball name for multi-process log files.
            #
            if options.mode == config.MPI_MODE or \
               options.mode == config.MPI_MT_MODE or \
               options.mode == config.MP_MODE or \
               options.mode == config.MP_MT_MODE:
                log_o += ' -log:pid'
        cmd += ' --log_options "%s"' % (log_o)

        # Add optional arguments the user may have passed on the command line
        #
        if hasattr(options, 'log_file') and options.log_file:
            cmd += ' --log_file ' + options.log_file
        else:
            cmd += ' --log_file pinball/log'  # Default name
        if hasattr(options, 'pid') and options.pid:
            cmd += ' --pid ' + str(options.pid)
        if hasattr(options, 'pintool') and options.pintool:
            cmd += ' --pintool ' + options.pintool
        if hasattr(options, 'arch') and options.arch:
            cmd += ' --arch ' + options.arch
        if hasattr(options, 'verbose') and options.verbose:
            cmd += ' --verbose '

        # Add the configuration files, if needed
        #
        cmd += util.AddCfgFile(options)

        # Add the binary to the command line.
        #
        # If the command is not already in double quotes, then quote it now.
        # This takes care of cases where the command may redirect input or output
        # or the command has options which contain the char '-'.
        #
        # Assume if there is one double quote, then a 2nd double quote should
        # also already be in the command.
        #
        if not (hasattr(options, 'pid') and options.pid):
            if options.command.find('"') == -1:
                cmd += ' "' + options.command + '" '
            else:
                cmd += ' ' + options.command

        # Print the script command line
        #
        if hasattr(options, 'verbose') and options.verbose or \
           hasattr(options, 'debug') and options.debug:
            string = '\n' + cmd
            msg.PrintMsg(string)

        # Run low level script.
        #
        result = self.RunScript(cmd, options)

        # Final phase of the script is module specific.
        #
        result = self.Finalize(kit_script_path, options)

        return result
    def Run(self):
        """
        Get all the user options and relog the pinball.

        @return exit code from this script
        """

        options, replay_pb, log_pb = self.ParseCommandLine()

        # Add the directory where the script is executed to PATH
        #
        util.AddScriptPath()

        # Get any Pin knobs (not pintool) specific to this module.
        #
        pin_knobs = self.AddPinKnobs()

        # Get the script and options require to run the low levels script for
        # replaying a pinball.  NOTE: return value 'kit_script_path' is not used.
        #
        cmd, kit_script_path = drd_util.DrDebugScriptCmd(
            'replayer.py', pin_knobs, options)

        # If use just wants 'pintool_help', then call the appropriate
        # low level script with this option.  Then exit this script.
        #
        if hasattr(options, 'pintool_help') and options.pintool_help:
            result = drd_util.PintoolHelpCmd(cmd, options)

            return result

        # Module specific setup
        #
        self.Initialize()

        # Add any pintool options given on the command line.
        #
        cmd += self.GetPintoolOptions(replay_pb, log_pb, options)

        # Don't print the Pin/Pintool command
        #
        cmd += ' --no_print_cmd'

        # We want the application output when we replay it.
        #
        cmd += ' --playout'

        # Add optional arguments the user may have passed on the command line
        #
        if hasattr(options, 'pintool') and options.pintool:
            cmd += ' --pintool ' + options.pintool
        if hasattr(options, 'verbose') and options.verbose:
            cmd += ' --verbose '
        if hasattr(options, 'cross_os') and options.cross_os:
            cmd += ' --cross_os '

        # Add the configuration files if needed
        #
        cmd += util.AddCfgFile(options)

        # Add the name of the old pinball to replay
        #
        cmd += ' %s' % (replay_pb)

        # Print the script command line
        #
        if hasattr(options, 'verbose') and options.verbose or \
           hasattr(options, 'debug') and options.debug:
            string = '\n' + cmd
            msg.PrintMsg(string)

        # Run low level script
        #
        result = self.RunScript(cmd, options)

        # Final phase of the script is module specific.
        #
        result = self.Finalize(kit_script_path, options)

        return result