Fix some exception safety problems


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10859 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Debugger/Debugger.cpp b/lib/Debugger/Debugger.cpp
index fd11f23..02c4a8a 100644
--- a/lib/Debugger/Debugger.cpp
+++ b/lib/Debugger/Debugger.cpp
@@ -117,7 +117,12 @@
 /// there is no program currently running, this just silently succeeds.
 void Debugger::killProgram() {
   // The destructor takes care of the dirty work.
-  delete Process;
+  try {
+    delete Process;
+  } catch (...) {
+    Process = 0;
+    throw;
+  }
   Process = 0;
 }
 
@@ -128,10 +133,12 @@
   try {
     Process->stepProgram();
   } catch (InferiorProcessDead &IPD) {
-    delete Process;
-    Process = 0;
+    killProgram();
     throw NonErrorException("The program stopped with exit code " +
                             itostr(IPD.getExitCode()));
+  } catch (...) {
+    killProgram();
+    throw;
   }
 }
 
@@ -176,10 +183,12 @@
     }
 
   } catch (InferiorProcessDead &IPD) {
-    delete Process;
-    Process = 0;
+    killProgram();
     throw NonErrorException("The program stopped with exit code " +
                             itostr(IPD.getExitCode()));
+  } catch (...) {
+    killProgram();
+    throw;
   }
 }
 
@@ -190,10 +199,12 @@
   try {
     Process->finishProgram(Frame);
   } catch (InferiorProcessDead &IPD) {
-    delete Process;
-    Process = 0;
+    killProgram();
     throw NonErrorException("The program stopped with exit code " +
                             itostr(IPD.getExitCode()));
+  } catch (...) {
+    killProgram();
+    throw;
   }
 }
 
@@ -204,9 +215,11 @@
   try {
     Process->contProgram();
   } catch (InferiorProcessDead &IPD) {
-    delete Process;
-    Process = 0;
+    killProgram();
     throw NonErrorException("The program stopped with exit code " +
                             itostr(IPD.getExitCode()));
+  } catch (...) {
+    killProgram();
+    throw;
   }
 }