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; --- 15 unchanged lines hidden (view full) --- 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/// 30/// @file sim/main.cc 31/// |
32#include <Python.h> // must be before system headers... see Python docs 33 |
34#include <sys/types.h> 35#include <sys/stat.h> 36#include <errno.h> 37#include <libgen.h> 38#include <stdlib.h> 39#include <signal.h> 40 41#include <list> 42#include <string> 43#include <vector> 44 |
45#include "base/inifile.hh" 46#include "base/misc.hh" 47#include "base/output.hh" 48#include "base/pollevent.hh" 49#include "base/statistics.hh" 50#include "base/str.hh" 51#include "base/time.hh" 52#include "cpu/base.hh" 53#include "cpu/smt.hh" |
54#include "sim/async.hh" 55#include "sim/builder.hh" 56#include "sim/configfile.hh" 57#include "sim/host.hh" 58#include "sim/sim_events.hh" 59#include "sim/sim_exit.hh" 60#include "sim/sim_object.hh" 61#include "sim/stat_control.hh" --- 43 unchanged lines hidden (view full) --- 105 // dump trace buffer, if there is one 106 Trace::theLog.dump(cerr); 107#endif 108} 109 110/// Simulator executable name 111char *myProgName = ""; 112 |
113/// 114/// Echo the command line for posterity in such a way that it can be 115/// used to rerun the same simulation (given the same .ini files). 116/// 117void 118echoCommandLine(int argc, char **argv, ostream &out) 119{ 120 out << "command line: " << argv[0]; --- 20 unchanged lines hidden (view full) --- 141 string rhs(body.substr(eq_pos + 1)); 142 143 out << quote(lhs) << "=" << quote(rhs); 144 } 145 } 146 out << endl << endl; 147} 148 |
149#include "config/python_build_env.hh" |
150 |
151int 152main(int argc, char **argv) 153{ 154 // Save off program name 155 myProgName = argv[0]; 156 157 signal(SIGFPE, SIG_IGN); // may occur on misspeculated paths 158 signal(SIGTRAP, SIG_IGN); 159 signal(SIGUSR1, dumpStatsHandler); // dump intermediate stats 160 signal(SIGUSR2, dumprstStatsHandler); // dump and reset stats 161 signal(SIGINT, exitNowHandler); // dump final stats and exit 162 signal(SIGABRT, abortHandler); 163 |
164 // Python embedded interpreter invocation 165 Py_SetProgramName(argv[0]); 166 const char *fileName = Py_GetProgramFullPath(); 167 Py_Initialize(); 168 PySys_SetArgv(argc, argv); |
169 |
170 // loadSwigModules(); |
171 |
172 // Set Python module path to include current file to find embedded 173 // zip archive 174 PyRun_SimpleString("import sys"); 175 string pathCmd = csprintf("sys.path[1:1] = ['%s']", fileName); 176 PyRun_SimpleString(pathCmd.c_str()); |
177 |
178 // Pass compile timestamp string to Python 179 extern const char *compileDate; // from date.cc 180 string setCompileDate = csprintf("compileDate = '%s'", compileDate); 181 PyRun_SimpleString(setCompileDate.c_str()); |
182 |
183 // PyRun_InteractiveLoop(stdin, "stdin"); 184 // m5/__init__.py currently contains main argv parsing loop etc., 185 // and will write out config.ini file before returning. 186 PyImport_ImportModule("defines"); 187 PyImport_ImportModule("m5"); 188 Py_Finalize(); |
189 |
190 configStream = simout.find("config.out"); |
191 |
192 // The configuration database is now complete; start processing it. 193 IniFile inifile; |
194 inifile.load("config.ini"); |
195 196 // Initialize statistics database 197 Stats::InitSimStats(); 198 199 // Now process the configuration hierarchy and create the SimObjects. 200 ConfigHierarchy configHierarchy(inifile); 201 configHierarchy.build(); 202 configHierarchy.createSimObjects(); 203 204 // Parse and check all non-config-hierarchy parameters. 205 ParamContext::parseAllContexts(inifile); 206 ParamContext::checkAllContexts(); 207 |
208 // Echo command line and all parameter settings to stats file as well. 209 echoCommandLine(argc, argv, *outputStream); 210 ParamContext::showAllContexts(*configStream); 211 212 // Any objects that can't connect themselves until after construction should 213 // do so now 214 SimObject::connectAll(); 215 --- 72 unchanged lines hidden --- |