main.cc (2667:fe64b8353b1c) | main.cc (2729:d5b88a725a9b) |
---|---|
1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 27 unchanged lines hidden (view full) --- 36#include <Python.h> // must be before system headers... see Python docs 37 38#include <sys/types.h> 39#include <sys/stat.h> 40#include <errno.h> 41#include <libgen.h> 42#include <stdlib.h> 43#include <signal.h> | 1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 27 unchanged lines hidden (view full) --- 36#include <Python.h> // must be before system headers... see Python docs 37 38#include <sys/types.h> 39#include <sys/stat.h> 40#include <errno.h> 41#include <libgen.h> 42#include <stdlib.h> 43#include <signal.h> |
44#include <unistd.h> | 44#include <getopt.h> |
45 46#include <list> 47#include <string> 48#include <vector> 49 50#include "base/callback.hh" 51#include "base/inifile.hh" 52#include "base/misc.hh" --- 55 unchanged lines hidden (view full) --- 108 cerr << "Program aborted at cycle " << curTick << endl; 109 110#if TRACING_ON 111 // dump trace buffer, if there is one 112 Trace::theLog.dump(cerr); 113#endif 114} 115 | 45 46#include <list> 47#include <string> 48#include <vector> 49 50#include "base/callback.hh" 51#include "base/inifile.hh" 52#include "base/misc.hh" --- 55 unchanged lines hidden (view full) --- 108 cerr << "Program aborted at cycle " << curTick << endl; 109 110#if TRACING_ON 111 // dump trace buffer, if there is one 112 Trace::theLog.dump(cerr); 113#endif 114} 115 |
116/// Simulator executable name 117char *myProgName = ""; |
|
116 | 118 |
119/// Show brief help message. 120void 121showBriefHelp(ostream &out) 122{ 123 char *prog = basename(myProgName); 124 125 ccprintf(out, "Usage:\n"); 126 ccprintf(out, 127"%s [-p <path>] [-i ] [-h] <config file>\n" 128"\n" 129" -p, --path <path> prepends <path> to PYTHONPATH instead of using\n" 130" built-in zip archive. Useful when developing/debugging\n" 131" changes to built-in Python libraries, as the new Python\n" 132" can be tested without building a new m5 binary.\n\n" 133" -i, --interactive forces entry into interactive mode after the supplied\n" 134" script is executed (just like the -i option to the\n" 135" Python interpreter).\n\n" 136" -h Prints this help\n\n" 137" <configfile> config file name (ends in .py)\n\n", 138 prog); 139 140} 141 |
|
117const char *briefCopyright = 118"Copyright (c) 2001-2006\n" 119"The Regents of The University of Michigan\n" 120"All Rights Reserved\n"; 121 122/// Print welcome message. 123void 124sayHello(ostream &out) --- 15 unchanged lines hidden (view full) --- 140} 141 142 143extern "C" { void init_main(); } 144 145int 146main(int argc, char **argv) 147{ | 142const char *briefCopyright = 143"Copyright (c) 2001-2006\n" 144"The Regents of The University of Michigan\n" 145"All Rights Reserved\n"; 146 147/// Print welcome message. 148void 149sayHello(ostream &out) --- 15 unchanged lines hidden (view full) --- 165} 166 167 168extern "C" { void init_main(); } 169 170int 171main(int argc, char **argv) 172{ |
173 // Saze off program name 174 myProgName = argv[0]; 175 |
|
148 sayHello(cerr); 149 150 signal(SIGFPE, SIG_IGN); // may occur on misspeculated paths 151 signal(SIGTRAP, SIG_IGN); 152 signal(SIGUSR1, dumpStatsHandler); // dump intermediate stats 153 signal(SIGUSR2, dumprstStatsHandler); // dump and reset stats 154 signal(SIGINT, exitNowHandler); // dump final stats and exit 155 signal(SIGABRT, abortHandler); 156 157 Py_SetProgramName(argv[0]); 158 159 // default path to m5 python code is the currently executing 160 // file... Python ZipImporter will find embedded zip archive 161 char *pythonpath = argv[0]; 162 163 bool interactive = false; | 176 sayHello(cerr); 177 178 signal(SIGFPE, SIG_IGN); // may occur on misspeculated paths 179 signal(SIGTRAP, SIG_IGN); 180 signal(SIGUSR1, dumpStatsHandler); // dump intermediate stats 181 signal(SIGUSR2, dumprstStatsHandler); // dump and reset stats 182 signal(SIGINT, exitNowHandler); // dump final stats and exit 183 signal(SIGABRT, abortHandler); 184 185 Py_SetProgramName(argv[0]); 186 187 // default path to m5 python code is the currently executing 188 // file... Python ZipImporter will find embedded zip archive 189 char *pythonpath = argv[0]; 190 191 bool interactive = false; |
192 bool show_help = false; |
|
164 bool getopt_done = false; | 193 bool getopt_done = false; |
194 int opt_index = 0; 195 196 static struct option long_options[] = { 197 {"python", 1, 0, 'p'}, 198 {"interactive", 0, 0, 'i'}, 199 {"help", 0, 0, 'h'}, 200 {0,0,0,0} 201 }; 202 |
|
165 do { | 203 do { |
166 switch (getopt(argc, argv, "+p:i")) { | 204 switch (getopt_long(argc, argv, "+p:ih", long_options, &opt_index)) { |
167 // -p <path> prepends <path> to PYTHONPATH instead of 168 // using built-in zip archive. Useful when 169 // developing/debugging changes to built-in Python 170 // libraries, as the new Python can be tested without 171 // building a new m5 binary. 172 case 'p': 173 pythonpath = optarg; 174 break; 175 176 // -i forces entry into interactive mode after the 177 // supplied script is executed (just like the -i option to 178 // the Python interpreter). 179 case 'i': 180 interactive = true; 181 break; 182 | 205 // -p <path> prepends <path> to PYTHONPATH instead of 206 // using built-in zip archive. Useful when 207 // developing/debugging changes to built-in Python 208 // libraries, as the new Python can be tested without 209 // building a new m5 binary. 210 case 'p': 211 pythonpath = optarg; 212 break; 213 214 // -i forces entry into interactive mode after the 215 // supplied script is executed (just like the -i option to 216 // the Python interpreter). 217 case 'i': 218 interactive = true; 219 break; 220 |
221 case 'h': 222 show_help = true; 223 break; |
|
183 case -1: 184 getopt_done = true; 185 break; 186 187 default: 188 fatal("Unrecognized option %c\n", optopt); 189 } 190 } while (!getopt_done); 191 | 224 case -1: 225 getopt_done = true; 226 break; 227 228 default: 229 fatal("Unrecognized option %c\n", optopt); 230 } 231 } while (!getopt_done); 232 |
233 if (show_help) { 234 showBriefHelp(cerr); 235 exit(1); 236 } 237 |
|
192 // Fix up argc & argv to hide arguments we just processed. 193 // getopt() sets optind to the index of the first non-processed 194 // argv element. 195 argc -= optind; 196 argv += optind; 197 198 // Set up PYTHONPATH to make sure the m5 module is found 199 string newpath(pythonpath); --- 227 unchanged lines hidden --- | 238 // Fix up argc & argv to hide arguments we just processed. 239 // getopt() sets optind to the index of the first non-processed 240 // argv element. 241 argc -= optind; 242 argv += optind; 243 244 // Set up PYTHONPATH to make sure the m5 module is found 245 string newpath(pythonpath); --- 227 unchanged lines hidden --- |