diff options
author | Gabe Black <gblack@eecs.umich.edu> | 2007-03-15 06:10:50 -0400 |
---|---|---|
committer | Gabe Black <gblack@eecs.umich.edu> | 2007-03-15 06:10:50 -0400 |
commit | b33f4623abeb82acf87714ada95682ceb0993d31 (patch) | |
tree | 80144e7e7717352d5627e5ca2eb5e2eb9da9a30c /util/statetrace/statetrace.cc | |
parent | ff90b8c1aa99711eeb55c5eba29519f77cbc041c (diff) | |
download | gem5-b33f4623abeb82acf87714ada95682ceb0993d31.tar.xz |
Update to statetrace. This will break it, but I want to make sure it gets into mercurial.
--HG--
extra : convert_revision : 6960d2f728c85e99e32bf9b752e45b3cb5e30e3e
Diffstat (limited to 'util/statetrace/statetrace.cc')
-rw-r--r-- | util/statetrace/statetrace.cc | 114 |
1 files changed, 42 insertions, 72 deletions
diff --git a/util/statetrace/statetrace.cc b/util/statetrace/statetrace.cc index e5baee395..4fe47dc02 100644 --- a/util/statetrace/statetrace.cc +++ b/util/statetrace/statetrace.cc @@ -35,88 +35,48 @@ #include <sys/wait.h> #include <sys/ptrace.h> #include <unistd.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netdb.h> +#include <errno.h> -#include "tracechild.hh" #include "printer.hh" +#include "tracechild.hh" using namespace std; void printUsage(const char * execName) { - cout << execName << " -f <output format file> | -h | -r -- <command> <arguments>" << endl; + cout << execName << " -h | -r -- <command> <arguments>" << endl; } int main(int argc, char * argv[], char * envp[]) { TraceChild * child = genTraceChild(); - NestingPrinter printer(child); string args; int startProgramArgs; //Parse the command line arguments - bool formatStringSet = false; bool printInitial = false; bool printTrace = true; - string format; for(int x = 1; x < argc; x++) { - if(!strcmp(argv[x], "-f")) - { - if(formatStringSet) - { - cerr << "Attempted to set format twice!" - << endl; - printUsage(argv[0]); - return 1; - } - formatStringSet = true; - x++; - if(x >= argc) - { - cerr << "Incorrect usage.\n" << endl; - printUsage(argv[0]); - return 1; - } - ifstream formatFile(argv[x]); - if(!formatFile) - { - cerr << "Problem opening file " - << argv[x] << "." << endl; - return 1; - } - format = ""; - while(formatFile) - { - string line; - getline(formatFile, line); - if(formatFile.eof()) - { - format += line; - break; - } - if(!formatFile) - { - cerr << "Problem reading from file " - << argv[x] << "." << endl; - return 1; - } - format += line + '\n'; - } - } - else 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; + 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")) { @@ -145,11 +105,6 @@ int main(int argc, char * argv[], char * envp[]) return 1; } } - /*for(unsigned int x = startProgramArgs; x < argc; x++) - { - cout << "Adding argument " << argv[x]; - args += string(" ") + argv[x]; - }*/ if(!child->startTracing(argv[startProgramArgs], argv + startProgramArgs)) { @@ -162,26 +117,41 @@ int main(int argc, char * argv[], char * envp[]) } if(printTrace) { - if(!formatStringSet) + // Connect to m5 + bool portSet = false; + int port; + int sock = socket(AF_INET, SOCK_STREAM, 0); + if(sock < 0) { - cerr << "No output format set!" << endl; - child->stopTracing(); - printUsage(argv[0]); - return 1; + cerr << "Error opening socket! " << strerror(errno) << endl; + return 1; } - if(!printer.configure(format)) + struct hostent *server; + server = gethostbyname("zower.eecs.umich.edu"); + if(!server) { - cerr << "Problem in the output format" << endl; - child->stopTracing(); - return 1; + 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()) { - cout << printer; + if(!child->sendState(sock)) + break; child->step(); } - cout << printer; } if(!child->stopTracing()) { |