diff options
author | Steve Reinhardt <stever@eecs.umich.edu> | 2007-07-29 13:25:14 -0700 |
---|---|---|
committer | Steve Reinhardt <stever@eecs.umich.edu> | 2007-07-29 13:25:14 -0700 |
commit | 08474ccf68e14f59b4517c6024a9bc6ecbd4a1d5 (patch) | |
tree | 5c1dc885b4fd33fc48d91a9ce489e24c88c9f3c2 /util/statetrace/statetrace.cc | |
parent | 4a7d0c4b79450e05b87da4cfc48c2361758127c1 (diff) | |
parent | 362ff1bcebd78c0c247e435eac657c8a1134b1fb (diff) | |
download | gem5-08474ccf68e14f59b4517c6024a9bc6ecbd4a1d5.tar.xz |
Merge Gabe's changes from head.
--HG--
extra : convert_revision : d00b7b09c7f19bc0e37b385ef7c124f69c0e917f
Diffstat (limited to 'util/statetrace/statetrace.cc')
-rw-r--r-- | util/statetrace/statetrace.cc | 184 |
1 files changed, 92 insertions, 92 deletions
diff --git a/util/statetrace/statetrace.cc b/util/statetrace/statetrace.cc index 4fe47dc02..5f7224b25 100644 --- a/util/statetrace/statetrace.cc +++ b/util/statetrace/statetrace.cc @@ -49,115 +49,115 @@ using namespace std; void printUsage(const char * execName) { - cout << execName << " -h | -r -- <command> <arguments>" << endl; + cout << execName << " -h | -r -- <command> <arguments>" << endl; } int main(int argc, char * argv[], char * envp[]) { - TraceChild * child = genTraceChild(); - string args; - int startProgramArgs; + TraceChild * child = genTraceChild(); + string args; + int startProgramArgs; - //Parse the command line arguments - bool printInitial = false; - bool printTrace = true; - for(int x = 1; x < argc; x++) + //Parse the command line arguments + bool printInitial = false; + bool printTrace = true; + for(int x = 1; x < argc; x++) + { + if(!strcmp(argv[x], "-h")) { - if(!strcmp(argv[x], "-h")) - { - printUsage(argv[0]); - return 0; - } - else if(!strcmp(argv[x], "-r")) - { - cout << "Legal register names:" << endl; - int numRegs = child->getNumRegs(); - for(unsigned int x = 0; x < numRegs; x++) - { - cout << "\t" << child->getRegName(x) << endl; - } - return 0; - } - else if(!strcmp(argv[x], "-i")) - { - printInitial = true; - } - else if(!strcmp(argv[x], "-nt")) - { - printTrace = false; - } - else if(!strcmp(argv[x], "--")) - { - x++; - if(x >= argc) - { - cerr << "Incorrect usage.\n" << endl; - printUsage(argv[0]); - return 1; - } - startProgramArgs = x; - break; - } - else - { - cerr << "Incorrect usage.\n" << endl; - printUsage(argv[0]); - return 1; - } + printUsage(argv[0]); + return 0; } - if(!child->startTracing(argv[startProgramArgs], - argv + startProgramArgs)) + else if(!strcmp(argv[x], "-r")) { - cerr << "Couldn't start target program" << endl; - return 1; + cout << "Legal register names:" << endl; + int numRegs = child->getNumRegs(); + for(unsigned int x = 0; x < numRegs; x++) + { + cout << "\t" << child->getRegName(x) << endl; + } + return 0; } - if(printInitial) + else if(!strcmp(argv[x], "-i")) { - child->outputStartState(cout); + printInitial = true; } - if(printTrace) + else if(!strcmp(argv[x], "-nt")) { - // Connect to m5 - bool portSet = false; - int port; - int sock = socket(AF_INET, SOCK_STREAM, 0); - if(sock < 0) - { - cerr << "Error opening socket! " << strerror(errno) << endl; - return 1; - } - struct hostent *server; - server = gethostbyname("zower.eecs.umich.edu"); - if(!server) - { - cerr << "Couldn't get host ip! " << strerror(errno) << endl; - return 1; - } - struct sockaddr_in serv_addr; - bzero((char *)&serv_addr, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - bcopy((char *)server->h_addr, - (char *)&serv_addr.sin_addr.s_addr, - server->h_length); - serv_addr.sin_port = htons(8000); - if(connect(sock, (sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) + printTrace = false; + } + else if(!strcmp(argv[x], "--")) + { + x++; + if(x >= argc) { - cerr << "Couldn't connect to server! " << strerror(errno) << endl; + cerr << "Incorrect usage.\n" << endl; + printUsage(argv[0]); return 1; } - child->step(); - while(child->isTracing()) - { - if(!child->sendState(sock)) - break; - child->step(); - } + startProgramArgs = x; + break; } - if(!child->stopTracing()) + else { - cerr << "Couldn't stop child" << endl; - return 1; + cerr << "Incorrect usage.\n" << endl; + printUsage(argv[0]); + return 1; + } + } + if(!child->startTracing(argv[startProgramArgs], + argv + startProgramArgs)) + { + cerr << "Couldn't start target program" << endl; + return 1; + } + if(printInitial) + { + child->outputStartState(cout); + } + if(printTrace) + { + // Connect to m5 + bool portSet = false; + int port; + int sock = socket(AF_INET, SOCK_STREAM, 0); + if(sock < 0) + { + cerr << "Error opening socket! " << strerror(errno) << endl; + return 1; + } + struct hostent *server; + server = gethostbyname("localhost"); + if(!server) + { + cerr << "Couldn't get host ip! " << strerror(errno) << endl; + return 1; + } + struct sockaddr_in serv_addr; + bzero((char *)&serv_addr, sizeof(serv_addr)); + serv_addr.sin_family = AF_INET; + bcopy((char *)server->h_addr, + (char *)&serv_addr.sin_addr.s_addr, + server->h_length); + serv_addr.sin_port = htons(8000); + if(connect(sock, (sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) + { + cerr << "Couldn't connect to server! " << strerror(errno) << endl; + return 1; + } + child->step(); + while(child->isTracing()) + { + if(!child->sendState(sock)) + break; + child->step(); } - return 0; + } + if(!child->stopTracing()) + { + cerr << "Couldn't stop child" << endl; + return 1; + } + return 0; } |