def AddAdditionalOptions(self, parser): """ Add any additional options besides the default for all scripts. @param parser Command line parser @return No return value """ cmd_options.bb_add_filename(parser) cmd_options.log_options(parser) cmd_options.pin_options(parser) cmd_options.pinplayhome(parser, '') cmd_options.playout(parser) cmd_options.relog_focus(parser, '') cmd_options.replay_options(parser) cmd_options.sdehome(parser, '') cmd_options.sim_add_filename(parser) cmd_options.wp_relog_dir(parser)
def ParseCommandLine(self): """ Process command line arguments, get Kit, tool options, and their paths. @return List containing: pin_options, pintool_options, options.replay_file, kit_obj """ # import pdb; pdb.set_trace() version = '$Revision: 1.63 $' version = version.replace(' ', '') ver = version.replace(' $', '') us = '%prog [options] pinball_basename \nVersion: ' + ver desc = 'Replays one pinball. Use \'--replay_options\' or ' \ '\'--log_options\' to modify the pintool behavior during replay.' util.CheckNonPrintChar(sys.argv) parser = optparse.OptionParser(usage=us, version=ver, description=desc) # Define the command line options which control the behavior of the # script. # # Some of these methods take a 2nd argument which is the empty string # ''. If this script used option groups, then the 2nd parameter would # be the group. However, this script does not use option groups, so # the argument is empty. # cmd_options.arch(parser, '') cmd_options.config_file(parser) cmd_options.cross_os(parser, '') cmd_options.debug(parser) cmd_options.global_file(parser) cmd_options.log_options(parser) cmd_options.msgfile_ext(parser) cmd_options.no_print_cmd(parser) cmd_options.pintool(parser) cmd_options.pintool_help(parser) cmd_options.pin_options(parser) cmd_options.pinplayhome(parser, '') cmd_options.playout(parser) cmd_options.replay_file(parser) cmd_options.replay_options(parser) cmd_options.save_global(parser) cmd_options.sdehome(parser, '') cmd_options.verbose(parser) # import pdb; pdb.set_trace() (options, args) = parser.parse_args() if options.verbose: msg.PrintMsg('Started replayer.py') # Check to make sure the pinball basename has been given as an argument or # command line option. # # import pdb; pdb.set_trace() if options.replay_file == '' and \ not (hasattr(options, 'pintool_help') and options.pintool_help): if len(sys.argv) == 1 or len(args) == 0: msg.PrintMsg( "ERROR: Must have a trace basename on the command line.\n" "Usage: %s [options] pinball_basename" % os.path.basename(sys.argv[0])) util.CheckResult(-1, options, 'Checking command line options') options.replay_file = args[0] # Read in an optional configuration files and set global variables. # config_obj = config.ConfigClass() config_obj.GetCfgGlobals(options, False) # Don't need to require 4 variables # Once the tracing configuration parameters are read, get the kit in # case pinplayhome was set on the command line. # # import pdb; pdb.set_trace() kit_obj = self.GetKit() # If user just wants 'pintool_help' go ahead and print it, then exit # the script. # if hasattr(options, 'pintool_help') and options.pintool_help: result = util.PintoolHelpKit(kit_obj, options) sys.exit(result) # Translate the 'arch' value given by the user into # the internal arch type used by the scripts. # if hasattr(options, 'arch') and options.arch: if 'intel64' in options.arch: options.arch = config.ARCH_INTEL64 elif 'ia32' in options.arch: options.arch = config.ARCH_IA32 else: options.arch = config.ARCH_INVALID # Now that we know the type of the binary, set the user defined pintool, # if one exists. Need to wait until now to set the tool because the # user may only have the tool in the architecture dependent directory # for this type of application. Thus we need the binary type in order # to find it. # # import pdb; pdb.set_trace() kit_obj.binary_type = options.arch pin_options = '' pintool_options = '' # Check to see if there is a pinball to replay. # if options.replay_file == "": msg.PrintHelpAndExit('Replay file not specified!') # If the user specified a pintool, replace the default pintool in the kit with # it. # if hasattr(options, "pintool") and options.pintool: kit_obj.SetPinTool(options.pintool, options.replay_file) platform = util.Platform() if platform == config.LINUX: pin_options = ' ' + kit_obj.prefix + ' -xyzzy ' # If using NOT using Linux tools to work with whole program pinballs generated on Windows, # then need a set of knobs for the pin binary itself. # if not options.cross_os: pin_options += kit_obj.prefix + ' -reserve_memory ' pin_options += kit_obj.prefix + ' ' + options.replay_file + '.address ' pintool_options += ' -replay:basename ' + options.replay_file if options.playout or '-replay:playout 1' in options.replay_options: # If present, need to remove the knob '-replay:playout 1' from # options.replay_options because it can only be given once on the # command line. # pintool_options += ' -replay:playout 1 ' options.replay_options = options.replay_options.replace( '-replay:playout 1', '') else: pintool_options += ' -replay:playout 0 ' # If running Windows WP pinballs on Linux, then need this knob for the replayer pintool. # if options.cross_os: pintool_options += ' -replay:addr_trans' # Add knobs for Pin and replay/logging user gave on the command line. # pin_options += ' ' + options.pin_options pintool_options += ' ' + options.replay_options + ' ' + options.log_options # If user has log options, then may need to at multi-thread knob. # if options.log_options: pintool_options += util.AddMt(options, options.replay_file) return pin_options, pintool_options, options.replay_file, kit_obj, options