Support both the generic remote protocol and the one for HP-PRO targets.
[binutils-gdb.git] / gdb / i386-nlmstub.c
index 1d0c9d684cae8ac94878de17e214a0fa5d347fe6..109aa149a1cea54d8ba2b88bb025d729ddaaad83 100644 (file)
@@ -627,7 +627,8 @@ handle_exception (frame)
 {
   int addr, length;
   char *ptr;
-  static int killed = 0;
+  static int thread_killed = 0;
+  static int thread_started = 0;
   static struct DBG_LoadDefinitionStructure *ldinfo = 0;
   static unsigned char first_insn[BREAKPOINT_SIZE]; /* The first instruction in the program.  */
 
@@ -661,8 +662,12 @@ handle_exception (frame)
       flush_i_cache ();
       return RETURN_TO_PROGRAM;
 
+    case START_THREAD_EVENT:
+      thread_started = 1;
+      return RETURN_TO_PROGRAM;
+
     case TERMINATE_NLM_EVENT:
-      if (!killed) 
+      if (!thread_killed) 
        {
          /* NetWare processes don't have an exit status so we
              generate our own  */
@@ -731,6 +736,14 @@ handle_exception (frame)
       break;
     }
 
+  /* We point the PC at _exit() and continue to kill the NLM, but that
+     won't work until it's thread has been started. */
+  if (thread_started && thread_killed) 
+    {
+      frame->ExceptionPC = &_exit;
+      return RETURN_TO_PROGRAM;
+    }
+
   /* FIXME: How do we know that this exception has anything to do with
      the program we are debugging?  We can check whether the PC is in
      the range of the module we are debugging, but that doesn't help
@@ -850,8 +863,9 @@ handle_exception (frame)
              at the start of _exit() and continue, while noting that
              we've killed the process.  */
 
-         killed = 1;
-         frame->ExceptionPC = &_exit;
+         thread_killed = 1;
+         if (thread_started)
+           frame->ExceptionPC = &_exit;
          return RETURN_TO_PROGRAM;
 
        case 'q':               /* Query message */