From 7c1d91d8166896e1358c64827a4b347b4dc69523 Mon Sep 17 00:00:00 2001 From: Ilia K Date: Wed, 15 Apr 2015 13:08:35 +0000 Subject: [PATCH] Add teardown hook to shutdown an inferior process Summary: Add teardown hook to shutdown an inferior process Reviewers: jasonmolenda, clayborg, tberghammer Reviewed By: clayborg, tberghammer Subscribers: lldb-commits, tberghammer, clayborg, jasonmolenda Differential Revision: http://reviews.llvm.org/D9018 llvm-svn: 235005 --- lldb/test/tools/lldb-server/gdbremote_testcase.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lldb/test/tools/lldb-server/gdbremote_testcase.py b/lldb/test/tools/lldb-server/gdbremote_testcase.py index a639b0130d5e..580e9dc72da1 100644 --- a/lldb/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/test/tools/lldb-server/gdbremote_testcase.py @@ -263,7 +263,7 @@ class GdbRemoteTestCaseBase(TestBase): try: server.terminate() except: - logger.warning("failed to close pexpect server for debug monitor: {}; ignoring".format(sys.exc_info()[0])) + logger.warning("failed to terminate server for debug monitor: {}; ignoring".format(sys.exc_info()[0])) self.addTearDownHook(shutdown_debug_monitor) # Schedule debug monitor to be shut down during teardown. @@ -333,7 +333,14 @@ class GdbRemoteTestCaseBase(TestBase): if sleep_seconds: args.append("sleep:%d" % sleep_seconds) - return self.spawnSubprocess(exe_path, args) + inferior = self.spawnSubprocess(exe_path, args) + def shutdown_process_for_attach(): + try: + inferior.terminate() + except: + logger.warning("failed to terminate inferior process for attach: {}; ignoring".format(sys.exc_info()[0])) + self.addTearDownHook(shutdown_process_for_attach) + return inferior def prep_debug_monitor_and_inferior(self, inferior_args=None, inferior_sleep_seconds=3, inferior_exe_path=None): """Prep the debug monitor, the inferior, and the expected packet stream.