def test_remote_exec(self): """ Tests execution on a remote target """ self.log.info("Testing execution on a remote target") hit_breakpoint = False s = gdb.GDBServer() g = gdb.GDB() cmd = '-file-exec-and-symbols %s' % self.return99_binary_path r = g.cmd(cmd) self.assertEqual(r.result.class_, 'done') cmd = 'set remote exec-file %s' % self.return99_binary_path r = g.cmd(cmd) self.assertEqual(r.result.class_, 'done') cmd = "-break-insert %s" % 'main' r = g.cmd(cmd) self.assertEqual(r.result.class_, 'done') r = g.cmd('-exec-run') other_messages = g.read_until_break() for msg in other_messages: parsed_msg = gdb.parse_mi(msg) if (hasattr(parsed_msg, 'class_') and parsed_msg.class_ == 'stopped' and parsed_msg.result.reason == 'breakpoint-hit'): hit_breakpoint = True self.assertTrue(hit_breakpoint) g.exit() s.exit()
def test_generate_core(self): """ Load a file that will cause a segfault and produce a core dump """ self.log.info("Testing that a core dump will be generated") g = gdb.GDB() file_cmd = "-file-exec-and-symbols %s" % self.segfault_binary_path r = g.cmd(file_cmd) self.assertEqual(r.result.class_, 'done') run_cmd = "-exec-run" r = g.cmd(run_cmd) self.assertEqual(r.result.class_, 'running') other_messages = g.read_until_break() core_path = None for msg in other_messages: parsed_msg = gdb.parse_mi(msg) if (hasattr(parsed_msg, 'class_') and (parsed_msg.class_ == 'stopped') and (parsed_msg.result.signal_name == 'SIGSEGV')): core_path = "%s.core" % self.segfault_binary_path gcore_cmd = 'gcore %s' % core_path gcore_cmd = gdb.encode_mi_cli(gcore_cmd) r = g.cmd(gcore_cmd) self.assertEqual(r.result.class_, 'done') self.assertTrue(os.path.exists(core_path)) g.exit()
def test_remote_exec(self): """ Tests execution on a remote target """ self.log.info("Testing execution on a remote target") hit_breakpoint = False s = gdb.GDBServer() g = gdb.GDB() cmd = '-file-exec-and-symbols %s' % self.return99_binary_path r = g.cmd(cmd) self.assertEqual(r.result.class_, 'done') cmd = 'set remote exec-file %s' % self.return99_binary_path r = g.cmd(cmd) self.assertEqual(r.result.class_, 'done') cmd = "-break-insert %s" % 'main' r = g.cmd(cmd) self.assertEqual(r.result.class_, 'done') r = g.cmd('-exec-run') other_messages = g.read_until_break() for msg in other_messages: parsed_msg = gdb.parse_mi(msg) if (hasattr(parsed_msg, 'class_') and parsed_msg.class_ == 'stopped' and parsed_msg.result.reason == 'breakpoint-hit'): hit_breakpoint = True self.assertTrue(hit_breakpoint) g.exit() s.exit()
def test_generate_core(self): """ Load a file that will cause a segfault and produce a core dump """ self.log.info("Testing that a core dump will be generated") g = gdb.GDB() file_cmd = "-file-exec-and-symbols %s" % self.segfault_binary_path r = g.cmd(file_cmd) self.assertEqual(r.result.class_, 'done') run_cmd = "-exec-run" r = g.cmd(run_cmd) self.assertEqual(r.result.class_, 'running') other_messages = g.read_until_break() core_path = None for msg in other_messages: parsed_msg = gdb.parse_mi(msg) if (hasattr(parsed_msg, 'class_') and (parsed_msg.class_ == 'stopped') and (parsed_msg.result.signal_name == 'SIGSEGV')): core_path = "%s.core" % self.segfault_binary_path gcore_cmd = 'gcore %s' % core_path gcore_cmd = gdb.encode_mi_cli(gcore_cmd) r = g.cmd(gcore_cmd) self.assertEqual(r.result.class_, 'done') self.assertTrue(os.path.exists(core_path)) g.exit()
def test_generate_core(self): """ Load a file that will cause a segfault and produce a core dump """ self.log.info("Testing that a core dump will be generated") g = gdb.GDB() file_cmd = f"-file-exec-and-symbols {self.segfault_binary_path}" r = g.cmd(file_cmd) self.assertEqual(r.result.class_, "done") run_cmd = "-exec-run" r = g.cmd(run_cmd) self.assertEqual(r.result.class_, "running") other_messages = g.read_until_break() core_path = None for msg in other_messages: parsed_msg = gdb.parse_mi(msg.decode()) if ( hasattr(parsed_msg, "class_") and (parsed_msg.class_ == "stopped") and (parsed_msg.result.signal_name == "SIGSEGV") ): core_path = f"{self.segfault_binary_path}.core" gcore_cmd = f"gcore {core_path}" gcore_cmd = gdb.encode_mi_cli(gcore_cmd) r = g.cmd(gcore_cmd) self.assertEqual(r.result.class_, "done") self.assertTrue(os.path.exists(core_path)) g.exit()
def test_remote_exec(self): """ Tests execution on a remote target """ self.log.info("Testing execution on a remote target") hit_breakpoint = False s = gdb.GDBServer() g = gdb.GDB() cmd = f"-file-exec-and-symbols {self.return99_binary_path}" r = g.cmd(cmd) self.assertEqual(r.result.class_, "done") cmd = f"set remote exec-file {self.return99_binary_path}" r = g.cmd(cmd) self.assertEqual(r.result.class_, "done") cmd = f"-break-insert {'main'}" r = g.cmd(cmd) self.assertEqual(r.result.class_, "done") r = g.cmd("-exec-run") other_messages = g.read_until_break() for msg in other_messages: parsed_msg = gdb.parse_mi(msg.decode()) if ( hasattr(parsed_msg, "class_") and parsed_msg.class_ == "stopped" and parsed_msg.result.reason == "breakpoint-hit" ): hit_breakpoint = True self.assertTrue(hit_breakpoint) g.exit() s.exit()