def test_disconnect(self): process = gdb_rsp.PopenDebugStub(COMMAND) try: # Connect. connection = gdb_rsp.GdbRspConnection() connection.Close() # Reconnect 3 times. for _ in range(3): connection = gdb_rsp.GdbRspConnection() connection.Close() finally: gdb_rsp.KillProcess(process)
def Main(args): port = int(args[0]) name = args[1] connection = gdb_rsp.GdbRspConnection(('localhost', port)) if name == 'continue': TestContinue(connection) else: raise AssertionError('Unknown test name: %r' % name)
def test_detach(self): process = gdb_rsp.PopenDebugStub(COMMAND) try: connection = gdb_rsp.GdbRspConnection() # Request detaching from the target. # This resumes execution, so we get the normal exit() status. reply = connection.RspRequest('D') self.assertEqual(reply, 'OK') finally: gdb_rsp.KillProcess(process)
def test_kill(self): sel_ldr = PopenDebugStub('test_exit_code') try: connection = gdb_rsp.GdbRspConnection() # Request killing the target. reply = connection.RspRequest('k') self.assertEquals(reply, 'OK') self.assertEquals(sel_ldr.wait(), RETURNCODE_KILL) finally: KillProcess(sel_ldr)
def test_kill(self): process = gdb_rsp.PopenDebugStub(COMMAND) try: connection = gdb_rsp.GdbRspConnection() # Request killing the target. reply = connection.RspRequest('k') self.assertEqual(reply, 'OK') signal = c_byte(process.wait()).value self.assertEqual(signal, gdb_rsp.RETURNCODE_KILL) finally: gdb_rsp.KillProcess(process)
def test_detach(self): sel_ldr = PopenDebugStub('test_exit_code') try: connection = gdb_rsp.GdbRspConnection() # Request detaching from the target. # This resumes execution, so we get the nexe's normal exit() status. reply = connection.RspRequest('D') self.assertEquals(reply, 'OK') self.assertEquals(sel_ldr.wait(), 2) finally: KillProcess(sel_ldr)
def test_disconnect(self): sel_ldr = PopenDebugStub('test_exit_code') try: # Connect and record the instruction pointer. connection = gdb_rsp.GdbRspConnection() # Check something basic responds with sane results. reply = connection.RspRequest('vCont?') self.assertEqual(reply, 'vCont;s;S;c;C') # Store the instruction pointer. registers = DecodeRegs(connection.RspRequest('g')) initial_ip = registers[IP_REG[ARCH]] connection.Close() # Reconnect 5 times. for _ in range(5): connection = gdb_rsp.GdbRspConnection() # Confirm the instruction pointer stays where it was, indicating that # the thread stayed suspended. registers = DecodeRegs(connection.RspRequest('g')) self.assertEquals(registers[IP_REG[ARCH]], initial_ip) connection.Close() finally: KillProcess(sel_ldr)
def __enter__(self): try: return gdb_rsp.GdbRspConnection() except: KillProcess(self._proc) raise