74 75# Callback to set trace flags. Not necessarily the best way to do 76# things in the long run (particularly if we change how these global 77# options are handled). 78def setTraceFlags(option, opt_str, value, parser): 79 objects.Trace.flags = value 80 81def setTraceStart(option, opt_str, value, parser): 82 objects.Trace.start = value 83 84def setTraceFile(option, opt_str, value, parser): 85 objects.Trace.file = value 86 87def usePCSymbol(option, opt_str, value, parser): 88 objects.ExecutionTrace.pc_symbol = value 89 90def printCycle(option, opt_str, value, parser): 91 objects.ExecutionTrace.print_cycle = value 92 93def printOp(option, opt_str, value, parser): 94 objects.ExecutionTrace.print_opclass = value 95 96def printThread(option, opt_str, value, parser): 97 objects.ExecutionTrace.print_thread = value 98 99def printEA(option, opt_str, value, parser): 100 objects.ExecutionTrace.print_effaddr = value 101 102def printData(option, opt_str, value, parser): 103 objects.ExecutionTrace.print_data = value 104 105def printFetchseq(option, opt_str, value, parser): 106 objects.ExecutionTrace.print_fetchseq = value 107 108def printCpseq(option, opt_str, value, parser): 109 objects.ExecutionTrace.print_cpseq = value 110 111def dumpOnExit(option, opt_str, value, parser): 112 objects.Trace.dump_on_exit = value 113 114def debugBreak(option, opt_str, value, parser): 115 objects.Debug.break_cycles = value 116 117def statsTextFile(option, opt_str, value, parser): 118 objects.Statistics.text_file = value 119 120# Extra list to help for options that are true or false 121TrueOrFalse = ['True', 'False'] 122TorF = "True | False" 123 124# Standard optparse options. Need to be explicitly included by the 125# user script when it calls optparse.OptionParser(). 126standardOptions = [ 127 optparse.make_option("--outdir", type="string", default="."), 128 optparse.make_option("--traceflags", type="string", action="callback", 129 callback=setTraceFlags), 130 optparse.make_option("--tracestart", type="int", action="callback", 131 callback=setTraceStart), 132 optparse.make_option("--tracefile", type="string", action="callback", 133 callback=setTraceFile), 134 optparse.make_option("--pcsymbol", type="choice", choices=TrueOrFalse, 135 default="True", metavar=TorF, 136 action="callback", callback=usePCSymbol, 137 help="Use PC symbols in trace output"), 138 optparse.make_option("--printcycle", type="choice", choices=TrueOrFalse, 139 default="True", metavar=TorF, 140 action="callback", callback=printCycle, 141 help="Print cycle numbers in trace output"), 142 optparse.make_option("--printopclass", type="choice", 143 choices=TrueOrFalse, 144 default="True", metavar=TorF, 145 action="callback", callback=printOp, 146 help="Print cycle numbers in trace output"), 147 optparse.make_option("--printthread", type="choice", 148 choices=TrueOrFalse, 149 default="True", metavar=TorF, 150 action="callback", callback=printThread, 151 help="Print thread number in trace output"), 152 optparse.make_option("--printeffaddr", type="choice", 153 choices=TrueOrFalse, 154 default="True", metavar=TorF, 155 action="callback", callback=printEA, 156 help="Print effective address in trace output"), 157 optparse.make_option("--printdata", type="choice", 158 choices=TrueOrFalse, 159 default="True", metavar=TorF, 160 action="callback", callback=printData, 161 help="Print result data in trace output"), 162 optparse.make_option("--printfetchseq", type="choice", 163 choices=TrueOrFalse, 164 default="True", metavar=TorF, 165 action="callback", callback=printFetchseq, 166 help="Print fetch sequence numbers in trace output"), 167 optparse.make_option("--printcpseq", type="choice", 168 choices=TrueOrFalse, 169 default="True", metavar=TorF, 170 action="callback", callback=printCpseq, 171 help="Print correct path sequence numbers in trace output"), 172 optparse.make_option("--dumponexit", type="choice", 173 choices=TrueOrFalse, 174 default="True", metavar=TorF, 175 action="callback", callback=dumpOnExit, 176 help="Dump trace buffer on exit"), 177 optparse.make_option("--debugbreak", type="int", metavar="CYCLE", 178 action="callback", callback=debugBreak, 179 help="Cycle to create a breakpoint"), 180 optparse.make_option("--statsfile", type="string", action="callback", 181 callback=statsTextFile, metavar="FILE", 182 help="Sets the output file for the statistics") 183 ] 184 185# make a SmartDict out of the build options for our local use 186import smartdict 187build_env = smartdict.SmartDict() 188build_env.update(defines.m5_build_env) 189 190# make a SmartDict out of the OS environment too 191env = smartdict.SmartDict() 192env.update(os.environ) 193 194 195# Function to provide to C++ so it can look up instances based on paths 196def resolveSimObject(name): 197 obj = config.instanceDict[name] 198 return obj.getCCObject() 199 200# The final hook to generate .ini files. Called from the user script 201# once the config is built. 202def instantiate(root): 203 config.ticks_per_sec = float(root.clock.frequency) 204 # ugly temporary hack to get output to config.ini 205 sys.stdout = file(os.path.join(options.outdir, 'config.ini'), 'w') 206 root.print_ini() 207 sys.stdout.close() # close config.ini 208 sys.stdout = sys.__stdout__ # restore to original
| 74 75# Callback to set trace flags. Not necessarily the best way to do 76# things in the long run (particularly if we change how these global 77# options are handled). 78def setTraceFlags(option, opt_str, value, parser): 79 objects.Trace.flags = value 80 81def setTraceStart(option, opt_str, value, parser): 82 objects.Trace.start = value 83 84def setTraceFile(option, opt_str, value, parser): 85 objects.Trace.file = value 86 87def usePCSymbol(option, opt_str, value, parser): 88 objects.ExecutionTrace.pc_symbol = value 89 90def printCycle(option, opt_str, value, parser): 91 objects.ExecutionTrace.print_cycle = value 92 93def printOp(option, opt_str, value, parser): 94 objects.ExecutionTrace.print_opclass = value 95 96def printThread(option, opt_str, value, parser): 97 objects.ExecutionTrace.print_thread = value 98 99def printEA(option, opt_str, value, parser): 100 objects.ExecutionTrace.print_effaddr = value 101 102def printData(option, opt_str, value, parser): 103 objects.ExecutionTrace.print_data = value 104 105def printFetchseq(option, opt_str, value, parser): 106 objects.ExecutionTrace.print_fetchseq = value 107 108def printCpseq(option, opt_str, value, parser): 109 objects.ExecutionTrace.print_cpseq = value 110 111def dumpOnExit(option, opt_str, value, parser): 112 objects.Trace.dump_on_exit = value 113 114def debugBreak(option, opt_str, value, parser): 115 objects.Debug.break_cycles = value 116 117def statsTextFile(option, opt_str, value, parser): 118 objects.Statistics.text_file = value 119 120# Extra list to help for options that are true or false 121TrueOrFalse = ['True', 'False'] 122TorF = "True | False" 123 124# Standard optparse options. Need to be explicitly included by the 125# user script when it calls optparse.OptionParser(). 126standardOptions = [ 127 optparse.make_option("--outdir", type="string", default="."), 128 optparse.make_option("--traceflags", type="string", action="callback", 129 callback=setTraceFlags), 130 optparse.make_option("--tracestart", type="int", action="callback", 131 callback=setTraceStart), 132 optparse.make_option("--tracefile", type="string", action="callback", 133 callback=setTraceFile), 134 optparse.make_option("--pcsymbol", type="choice", choices=TrueOrFalse, 135 default="True", metavar=TorF, 136 action="callback", callback=usePCSymbol, 137 help="Use PC symbols in trace output"), 138 optparse.make_option("--printcycle", type="choice", choices=TrueOrFalse, 139 default="True", metavar=TorF, 140 action="callback", callback=printCycle, 141 help="Print cycle numbers in trace output"), 142 optparse.make_option("--printopclass", type="choice", 143 choices=TrueOrFalse, 144 default="True", metavar=TorF, 145 action="callback", callback=printOp, 146 help="Print cycle numbers in trace output"), 147 optparse.make_option("--printthread", type="choice", 148 choices=TrueOrFalse, 149 default="True", metavar=TorF, 150 action="callback", callback=printThread, 151 help="Print thread number in trace output"), 152 optparse.make_option("--printeffaddr", type="choice", 153 choices=TrueOrFalse, 154 default="True", metavar=TorF, 155 action="callback", callback=printEA, 156 help="Print effective address in trace output"), 157 optparse.make_option("--printdata", type="choice", 158 choices=TrueOrFalse, 159 default="True", metavar=TorF, 160 action="callback", callback=printData, 161 help="Print result data in trace output"), 162 optparse.make_option("--printfetchseq", type="choice", 163 choices=TrueOrFalse, 164 default="True", metavar=TorF, 165 action="callback", callback=printFetchseq, 166 help="Print fetch sequence numbers in trace output"), 167 optparse.make_option("--printcpseq", type="choice", 168 choices=TrueOrFalse, 169 default="True", metavar=TorF, 170 action="callback", callback=printCpseq, 171 help="Print correct path sequence numbers in trace output"), 172 optparse.make_option("--dumponexit", type="choice", 173 choices=TrueOrFalse, 174 default="True", metavar=TorF, 175 action="callback", callback=dumpOnExit, 176 help="Dump trace buffer on exit"), 177 optparse.make_option("--debugbreak", type="int", metavar="CYCLE", 178 action="callback", callback=debugBreak, 179 help="Cycle to create a breakpoint"), 180 optparse.make_option("--statsfile", type="string", action="callback", 181 callback=statsTextFile, metavar="FILE", 182 help="Sets the output file for the statistics") 183 ] 184 185# make a SmartDict out of the build options for our local use 186import smartdict 187build_env = smartdict.SmartDict() 188build_env.update(defines.m5_build_env) 189 190# make a SmartDict out of the OS environment too 191env = smartdict.SmartDict() 192env.update(os.environ) 193 194 195# Function to provide to C++ so it can look up instances based on paths 196def resolveSimObject(name): 197 obj = config.instanceDict[name] 198 return obj.getCCObject() 199 200# The final hook to generate .ini files. Called from the user script 201# once the config is built. 202def instantiate(root): 203 config.ticks_per_sec = float(root.clock.frequency) 204 # ugly temporary hack to get output to config.ini 205 sys.stdout = file(os.path.join(options.outdir, 'config.ini'), 'w') 206 root.print_ini() 207 sys.stdout.close() # close config.ini 208 sys.stdout = sys.__stdout__ # restore to original
|