def start(self): #TODO: Handle timeout if self._verbose: log.info("Trying to connect to target gdb server at %s:%d", self._sockaddress[0], self._sockaddress[1]) self._gdb_interface = GdbDebugger(gdb_executable=self.gdb_exec) self._gdb_interface.set_async_message_handler( self.handle_gdb_async_message) self._gdb_interface.connect( ("tcp", self._sockaddress[0], "%d" % self._sockaddress[1]))
def run_s2e_process(self): try: log.info("Starting S2E process: %s", " ".join(["'%s'" % x for x in self._cmdline])) self._s2e_process = subprocess.Popen( self._cmdline, cwd=self._configuration.get_output_directory(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) self._s2e_stdout_tee_process = subprocess.Popen( [ "tee", os.path.normpath( os.path.join( self._configuration.get_output_directory(), "s2e_stdout.log")) ], stdin=self._s2e_process.stdout, cwd=self._configuration.get_output_directory()) self._s2e_stderr_tee_process = subprocess.Popen( [ "tee", os.path.normpath( os.path.join( self._configuration.get_output_directory(), "s2e_stderr.log")) ], stdin=self._s2e_process.stderr, cwd=self._configuration.get_output_directory()) remote_target = False if "RemoteMemory" in self._configuration._s2e_configuration[ "plugins"]: remote_target = True if remote_target: self._remote_memory_interface = S2ERemoteMemoryInterface( self._configuration.get_remote_memory_listen_address()) self._remote_memory_interface.set_read_handler( self._notify_read_request_handler) self._remote_memory_interface.set_write_handler( self._notify_write_request_handler) self._remote_memory_interface.set_set_cpu_state_handler( self._notify_set_cpu_state_handler) self._remote_memory_interface.set_get_cpu_state_handler( self._notify_get_cpu_state_handler) self._remote_memory_interface.set_continue_handler( self._notify_continue_handler) self._remote_memory_interface.set_get_checksum_handler( self._system.get_target().get_checksum) time.sleep(2) #Wait a bit for the S2E process to start self._remote_memory_interface.start() try: gdb_path = self._configuration._s2e_configuration[ "emulator_gdb_path"] except KeyError: gdb_path = "arm-none-eabi-gdb" log.warn("Using default gdb executable path: %s" % gdb_path) try: gdb_additional_args = self._configuration._s2e_configuration[ "emulator_gdb_additional_arguments"] except KeyError: gdb_additional_args = [] self._gdb_interface = GdbDebugger( gdb_executable=gdb_path, cwd=".", additional_args=gdb_additional_args) self._gdb_interface.set_async_message_handler( self.handle_gdb_async_message) count = 10 while count != 0: try: log.debug("Trying to connect to emulator.") self._gdb_interface.connect( ("tcp", "127.0.0.1", "%d" % self._configuration.get_s2e_gdb_port())) break except: count -= 1 if count > 0: log.warning("Failed to connect to emulator, retrying.") time.sleep(3) if count == 0: raise Exception("Failed to connect to emulator. Giving up!") log.info("Successfully connected to emulator.") self._is_s2e_running.set() self._s2e_process.wait() except KeyboardInterrupt: pass self.exit()
def run_panda_process(self): try: log.info("Starting Panda process: %s", " ".join(["'%s'" % x for x in self._cmdline])) self._panda_process = subprocess.Popen( self._cmdline, #cwd = self._configuration.get_output_directory(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) self._panda_stdout_tee_process = subprocess.Popen( [ "tee", os.path.normpath( os.path.join(OUTPUT_DIRECTORY, "panda_stdout.log")) ], stdin=self._panda_process.stdout, cwd=OUTPUT_DIRECTORY) self._panda_stderr_tee_process = subprocess.Popen( [ "tee", os.path.normpath( os.path.join(OUTPUT_DIRECTORY, "panda_stderr.log")) ], stdin=self._panda_process.stderr, cwd=OUTPUT_DIRECTORY) self._remote_memory_interface = PandaRemoteMemoryInterface( ("127.0.0.1", 5555)) # Uebergebe callbacks, ein callback ist z.B. self._notify_read_request_handler self._remote_memory_interface.set_read_handler( self._notify_read_request_handler) self._remote_memory_interface.set_write_handler( self._notify_write_request_handler) self._remote_memory_interface.set_set_cpu_state_handler( self._notify_set_cpu_state_handler) self._remote_memory_interface.set_get_cpu_state_handler( self._notify_get_cpu_state_handler) self._remote_memory_interface.set_continue_handler( self._notify_continue_handler) self._remote_memory_interface.set_get_checksum_handler( self._system.get_target().get_checksum) # We need some time until the sockets from the RemoteMemory plugin are open time.sleep( 2 ) #Wait a bit for the Panda process to start, der socket vom Panda Plugin wird # tatsaechlich vor dem GDB-emulaor-server socket aufgemacht self._remote_memory_interface.start() # We need some time until the (potential) sockets from the QMP are open AND # until the QEMU-gdb-server socket is open time.sleep(2) self._monitor_socket = socket.create_connection( ("127.0.0.1", 4000)) try: #TODO: Path fuer GDB fuer emulator hier finden raise KeyError() #gdb_path = self._configuration._panda_configuration["emulator_gdb_path"] except KeyError: gdb_path = "arm-none-eabi-gdb" log.warn("Using default gdb executable path: %s" % gdb_path) # try: # gdb_additional_args = self._configuration._panda_configuration["emulator_gdb_additional_arguments"] # except KeyError: gdb_additional_args = [] self._gdb_interface = GdbDebugger( gdb_executable=gdb_path, cwd=".", additional_args=gdb_additional_args) self._gdb_interface.set_async_message_handler( self.handle_gdb_async_message) count = 10 while count != 0: try: log.debug("Trying to connect to emulator.") self._gdb_interface.connect( ("tcp", "127.0.0.1", "%d" % 5000)) break except: count -= 1 if count > 0: log.warning("Failed to connect to emulator, retrying.") time.sleep(3) if count == 0: raise Exception("Failed to connect to emulator. Giving up!") log.info("Successfully connected to emulator.") self._is_panda_running.set() self._panda_process.wait() except KeyboardInterrupt: pass self.exit()