Permalink
Browse files

make very faster (working?) - pre demo udpate + log

  • Loading branch information...
dobin committed Jun 14, 2018
1 parent 8f871cc commit 2c815343b6dfb9fab80417174e28d67133bda513
View
@@ -13,7 +13,7 @@
GLOBAL_SLEEP = {
# how long to wait after server start
# can be high as it is not happening so often
"sleep_after_server_start": 1,
"sleep_after_server_start": 0.5,
}
@@ -67,18 +67,21 @@ def startAndWait(self):
logging.info("Retrying to start server...")
ret = self._startServer()
logging.info("Server PID: " + str(self.pid))
logging.info("DebugServer: Server PID: " + str(self.pid))
# notify parent about the pid
self.queue_sync.put( ("pid", self.pid) )
# block until we have a crash
# the client will send the network messages
logging.info("DebugServer: Waiting for a crash")
if self._waitForCrash():
# seems we have a crash. get details, so we
# can return it to the parent via queue_sync
logging.info("DebugServer: We have a crash")
crashData = self._getCrashDetails()
else:
logging.info("DebugServer: We have NO crash (timeout)")
crashData = None
# _getCrashDetails could return None
@@ -23,12 +23,13 @@ def __init__(self, config, queue_sync, queue_out, targetPort):
self.crashEvent = None
self.proc = None
self.p = None
if config["debug"]:
logging.basicConfig(level=logging.DEBUG)
def _startServer(self):
# create child via ptrace debugger
# API: createChild(arguments[], no_stdout, env=None)
logging.debug("START: " + str(targetutils.getInvokeTargetArgs(self.config, self.targetPort + 1000)))
logging.debug("DebugServerManager: starting " + str(targetutils.getInvokeTargetArgs(self.config, self.targetPort + 1000)))
self.pid = createChild(
targetutils.getInvokeTargetArgs(self.config, self.targetPort),
False, # no_stdout
@@ -46,7 +47,7 @@ def _startServer(self):
# FIXME
event = self.dbg.waitProcessEvent(blocking=False)
if event is not None and type(event) == ProcessExit:
logging.error("Started server, but it already exited: " + str(event))
logging.error("DebugServerManager: Started server, but it already exited: " + str(event))
return False
return True
@@ -63,9 +64,9 @@ def _stopServer(self):
def _waitForCrash(self):
while True:
logging.info("DebugServer: Waiting for process event")
logging.info("ServerManager: Debug: Waiting for process event")
event = self.dbg.waitProcessEvent()
logging.info("DebugServer: Got event: " + str(event))
logging.info("ServerManager: Debug: " + str(event))
# If this is a process exit we need to check if it was abnormal
if type(event) == ProcessExit:
if event.signum is None or event.exitcode == 0:
@@ -85,11 +86,11 @@ def _waitForCrash(self):
break
if event is not None and event.signum != 15:
logging.info("DebugServer: Event Result: Crash")
logging.info("ServerManager: Debug: Event Result: Crash")
self.crashEvent = event
return True
else:
logging.info("DebugServer: Event Result: No crash")
logging.info("ServerManager: Debug: Event Result: No crash")
self.crashEvent = None
return False
@@ -102,7 +103,7 @@ def _getCrashDetails(self):
faultAddress = event.process.getInstrPointer()
except Exception as e:
# process already dead, hmm
print(("GetCrashDetails exception: " + str(e)))
print("DebugServerManager: GetCrashDetails exception: " + str(e))
# Find the module that contains this address
# Now we need to turn the address into an offset. This way when the process
@@ -119,7 +120,7 @@ def _getCrashDetails(self):
faultOffset = faultAddress - mapping.start
break
except Exception as error:
print("getCrashDetails Exception: " + str(error))
print("DebugServerManager: getCrashDetails Exception: " + str(error))
# it always has a an exception...
pass
@@ -163,7 +164,7 @@ def _getCrashDetails(self):
except Exception as e:
# process already dead, hmm
print(("GetCrashDetails exception: " + str(e)))
print(("DebugServerManager: GetCrashDetails exception: " + str(e)))
asanOutput = targetutils.getAsanOutput(self.config, self.pid)
@@ -43,7 +43,7 @@ def _getCrashDetails(self):
def _waitForCrash(self):
logging.info("Wait for crash")
logging.info("ServerManager: GDB: Wait for crash")
# start gdb
argsGdb = [ "/usr/bin/gdb", self.config["target_bin"], '-q' ]
View
@@ -19,11 +19,11 @@
sleeptimes = {
# wait between server start and first connection attempt
# so it can settle-in
"wait_time_for_server_rdy": 0.5,
"wait_time_for_server_rdy": 0.25,
# how long we let the server run
# usually it should crash immediately
"max_server_run_time": 2,
"max_server_run_time": 0.25,
}
@@ -241,6 +241,7 @@ def _verify(self, crashData, serverManager):
res = self.networkManager.debugServerConnection()
if not res:
logging.error("Could not connect")
return None
logging.info("Verifier: Sending fuzzed messages")
@@ -258,13 +259,15 @@ def _verify(self, crashData, serverManager):
# empty result. has to be handled.
if serverCrashData:
logging.info("Verifier: I've got a crash: ")
print("Verifier: I've got a crash: ")
serverCrashData.setProcessStdout(serverStdout)
else:
logging.error("Verifier: Some server error:")
logging.error("Verifier: Output: " + serverStdout)
return serverCrashData
except Queue.Empty:
logging.info("Verifier: NO crash (empty queue)")
self.stopChild()
return None

0 comments on commit 2c81534

Please sign in to comment.