summaryrefslogtreecommitdiff
path: root/util/statetrace/statetrace.cc
diff options
context:
space:
mode:
Diffstat (limited to 'util/statetrace/statetrace.cc')
-rw-r--r--util/statetrace/statetrace.cc32
1 files changed, 22 insertions, 10 deletions
diff --git a/util/statetrace/statetrace.cc b/util/statetrace/statetrace.cc
index 5f7224b25..e2762ac2c 100644
--- a/util/statetrace/statetrace.cc
+++ b/util/statetrace/statetrace.cc
@@ -28,19 +28,19 @@
* Authors: Gabe Black
*/
-#include <iostream>
+#include <cstring>
+#include <errno.h>
#include <fstream>
+#include <iostream>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <stdio.h>
#include <string>
+#include <sys/ptrace.h>
+#include <sys/socket.h>
#include <sys/types.h>
#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 "printer.hh"
#include "tracechild.hh"
@@ -61,6 +61,7 @@ int main(int argc, char * argv[], char * envp[])
//Parse the command line arguments
bool printInitial = false;
bool printTrace = true;
+ string host = "localhost";
for(int x = 1; x < argc; x++)
{
if(!strcmp(argv[x], "-h"))
@@ -68,6 +69,17 @@ int main(int argc, char * argv[], char * envp[])
printUsage(argv[0]);
return 0;
}
+ if(!strcmp(argv[x], "--host"))
+ {
+ x++;
+ if(x >= argc)
+ {
+ cerr << "Incorrect usage.\n" << endl;
+ printUsage(argv[0]);
+ return 1;
+ }
+ host = argv[x];
+ }
else if(!strcmp(argv[x], "-r"))
{
cout << "Legal register names:" << endl;
@@ -111,6 +123,7 @@ int main(int argc, char * argv[], char * envp[])
cerr << "Couldn't start target program" << endl;
return 1;
}
+ child->step();
if(printInitial)
{
child->outputStartState(cout);
@@ -127,7 +140,7 @@ int main(int argc, char * argv[], char * envp[])
return 1;
}
struct hostent *server;
- server = gethostbyname("localhost");
+ server = gethostbyname(host.c_str());
if(!server)
{
cerr << "Couldn't get host ip! " << strerror(errno) << endl;
@@ -145,7 +158,6 @@ int main(int argc, char * argv[], char * envp[])
cerr << "Couldn't connect to server! " << strerror(errno) << endl;
return 1;
}
- child->step();
while(child->isTracing())
{
if(!child->sendState(sock))