Statetrace: Fix indendation. Set the default hostname to "localhost" instead of my...
authorGabe Black <gblack@eecs.umich.edu>
Sun, 29 Jul 2007 03:35:33 +0000 (20:35 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Sun, 29 Jul 2007 03:35:33 +0000 (20:35 -0700)
--HG--
extra : convert_revision : f268c04e39fd384e0ac17253faae2233b58e9373

util/statetrace/statetrace.cc

index 4fe47dc02a02f49273b58c69e22bdfc66eff5d68..5f7224b257f579c5b227f1e9516a991312f11ee3 100644 (file)
@@ -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;
 }