Add forgotten ChangeLog snippet for last elf64-x86-64.c patch.
[deliverable/binutils-gdb.git] / gdb / infttrace.c
index 7433b7c7292f03a8d4ff1e55aa819202ca7c38b8..e0238e8bc55d8b9c34d1ded9252288998a8905aa 100644 (file)
@@ -1,6 +1,6 @@
 /* Low level Unix child interface to ttrace, for GDB when running under HP-UX.
    Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
-   1999, 2000, 2001
+   1999, 2000, 2001, 2003
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -27,6 +27,7 @@
 #include "gdb_string.h"
 #include "gdb_wait.h"
 #include "command.h"
+#include "gdbthread.h"
 
 /* We need pstat functionality so that we can get the exec file
    for a process we attach to.
@@ -141,12 +142,6 @@ static startup_semaphore_t startup_semaphore;
 static int vforking_child_pid = 0;
 static int vfork_in_flight = 0;
 
-/* To support PREPARE_TO_PROCEED (hppa_prepare_to_proceed).
- */
-static pid_t old_gdb_pid = 0;
-static pid_t reported_pid = 0;
-static int reported_bpt = 0;
-
 /* 1 if ok as results of a ttrace or ttrace_wait call, 0 otherwise.
  */
 #define TT_OK( _status, _errno ) \
@@ -2289,7 +2284,7 @@ call_ttrace_wait (int pid, ttwopt_t option, ttstate_t *tsp, size_t tsp_size)
      thread descriptor.
 
      This caches the state.  The implementation of queries like
-     target_has_execd can then use this cached state, rather than
+     hpux_has_execd can then use this cached state, rather than
      be forced to make an explicit ttrace call to get it.
 
      (Guard against the condition that this is the first time we've
@@ -2911,12 +2906,6 @@ ptrace_wait (ptid_t ptid, int *status)
    */
   return_pid = map_to_gdb_tid (real_tid);
 
-  /* Remember this for later use in "hppa_prepare_to_proceed".
-   */
-  old_gdb_pid = PIDGET (inferior_ptid);
-  reported_pid = return_pid;
-  reported_bpt = ((tsp.tts_event & TTEVT_SIGNAL) && (5 == tsp.tts_u.tts_signal.tts_signo));
-
   if (real_tid == 0 || return_pid == 0)
     {
       warning ("Internal error: process-wait failed.");
@@ -2947,7 +2936,7 @@ ptrace_wait (ptid_t ptid, int *status)
    child_acknowledge_created_inferior.)
  */
 int
-parent_attach_all (void)
+parent_attach_all (int p1, PTRACE_ARG3_TYPE p2, int p3)
 {
   int tt_status;
 
@@ -3357,8 +3346,6 @@ child_remove_vfork_catchpoint (int tid)
 }
 #endif
 
-#if defined(CHILD_HAS_FORKED)
-
 /* Q: Do we need to map the returned process ID to a thread ID?
 
  * A: I don't think so--here we want a _real_ pid.  Any later
@@ -3366,7 +3353,7 @@ child_remove_vfork_catchpoint (int tid)
  *    start the mapping.
  */
 int
-child_has_forked (int tid, int *childpid)
+hpux_has_forked (int tid, int *childpid)
 {
   int tt_status;
   ttstate_t ttrace_state;
@@ -3403,15 +3390,11 @@ child_has_forked (int tid, int *childpid)
 
   return 0;
 }
-#endif
-
 
-#if defined(CHILD_HAS_VFORKED)
-
-/* See child_has_forked for pid discussion.
+/* See hpux_has_forked for pid discussion.
  */
 int
-child_has_vforked (int tid, int *childpid)
+hpux_has_vforked (int tid, int *childpid)
 {
   int tt_status;
   ttstate_t ttrace_state;
@@ -3446,22 +3429,6 @@ child_has_vforked (int tid, int *childpid)
 
   return 0;
 }
-#endif
-
-
-#if defined(CHILD_CAN_FOLLOW_VFORK_PRIOR_TO_EXEC)
-int
-child_can_follow_vfork_prior_to_exec (void)
-{
-  /* ttrace does allow this.
-
-     ??rehrauer: However, I had major-league problems trying to
-     convince wait_for_inferior to handle that case.  Perhaps when
-     it is rewritten to grok multiple processes in an explicit way...
-   */
-  return 0;
-}
-#endif
 
 
 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
@@ -3490,9 +3457,8 @@ child_remove_exec_catchpoint (int tid)
 #endif
 
 
-#if defined(CHILD_HAS_EXECD)
 int
-child_has_execd (int tid, char **execd_pathname)
+hpux_has_execd (int tid, char **execd_pathname)
 {
   int tt_status;
   ttstate_t ttrace_state;
@@ -3531,12 +3497,10 @@ child_has_execd (int tid, char **execd_pathname)
 
   return 0;
 }
-#endif
 
 
-#if defined(CHILD_HAS_SYSCALL_EVENT)
 int
-child_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
+hpux_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
 {
   int tt_status;
   ttstate_t ttrace_state;
@@ -3576,7 +3540,6 @@ child_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
   *syscall_id = ttrace_state.tts_scno;
   return 1;
 }
-#endif
 \f
 
 
@@ -3700,7 +3663,7 @@ call_ptrace (int pt_request, int gdb_tid, PTRACE_ARG3_TYPE addr, int data)
          there's no need for any "break" statements.
        */
     case PT_SETTRC:
-      return parent_attach_all ();
+      return parent_attach_all (0, 0, 0);
 
     case PT_RUREGS:
       tt_status = read_from_register_save_state (gdb_tid,
@@ -3977,7 +3940,7 @@ threads_continue_all_but_one (lwpid_t gdb_tid, int signal)
        * state.tts_flags & TTS_STATEMASK == TTS_WASSUSPENDED
        */
       if (debug_on)
-       if (state.tts_flags & TTS_STATEMASK != TTS_WASSUSPENDED)
+       if ((state.tts_flags & TTS_STATEMASK) != TTS_WASSUSPENDED)
          printf ("About to continue non-stopped thread %d\n", scan_tid);
 #endif
 
@@ -4111,7 +4074,7 @@ threads_continue_all_with_signals (lwpid_t gdb_tid, int signal)
 
 #ifdef THREAD_DEBUG
       if (debug_on)
-       if (state.tts_flags & TTS_STATEMASK != TTS_WASSUSPENDED)
+       if ((state.tts_flags & TTS_STATEMASK) != TTS_WASSUSPENDED)
          warning ("About to continue non-stopped thread %d\n", scan_tid);
 #endif
 
@@ -4539,98 +4502,49 @@ child_resume (ptid_t ptid, int step, enum target_signal signal)
 
   else
     {
-      /* TT_LWP_CONTINUE can pass signals to threads,
-       * TT_PROC_CONTINUE can't.  So if there are any
-       * signals to pass, we have to use the (slower)
-       * loop over the stopped threads.
-       *
-       * Equally, if we have to not continue some threads,
-       * due to saved events, we have to use the loop.
-       */
-      if ((signal != 0) || saved_signals_exist ())
+      /* TT_LWP_CONTINUE can pass signals to threads, TT_PROC_CONTINUE can't.
+        Therefore, we really can't use TT_PROC_CONTINUE here.
+
+        Consider a process which stopped due to signal which gdb decides
+        to handle and not pass on to the inferior.  In that case we must
+        clear the pending signal by restarting the inferior using
+        TT_LWP_CONTINUE and pass zero as the signal number.  Else the
+        pending signal will be passed to the inferior.  interrupt.exp
+        in the testsuite does this precise thing and fails due to the
+        unwanted signal delivery to the inferior.  */
+      /* drow/2002-12-05: However, note that we must use TT_PROC_CONTINUE
+        if we are tracing a vfork.  */
+      if (vfork_in_flight)
+       {
+         call_ttrace (TT_PROC_CONTINUE, tid, TT_NIL, TT_NIL, TT_NIL);
+         clear_all_handled ();
+         clear_all_stepping_mode ();
+       }
+      else if (resume_all_threads)
        {
-         if (resume_all_threads)
-           {
-
-#ifdef THREAD_DEBUG
-             if (debug_on)
-               printf ("Doing a continue by loop of all threads\n");
-#endif
-
-             threads_continue_all_with_signals (tid, signal);
-
-             clear_all_handled ();
-             clear_all_stepping_mode ();
-           }
-
-         else
-           {
 #ifdef THREAD_DEBUG
-             printf ("Doing a continue w/signal of just thread %d\n", tid);
+         if (debug_on)
+           printf ("Doing a continue by loop of all threads\n");
 #endif
 
-             threads_continue_one_with_signal (tid, signal);
+         threads_continue_all_with_signals (tid, signal);
 
-             /* Clear the "handled" state of this thread, because
-              * we'll soon get a new event for it.  Other events
-              * can stay as they were.
-              */
-             clear_handled (tid);
-             clear_stepping_mode (tid);
-           }
+         clear_all_handled ();
+         clear_all_stepping_mode ();
        }
-
       else
        {
-         /* No signals to send.
-          */
-         if (resume_all_threads)
-           {
-#ifdef THREAD_DEBUG
-             if (debug_on)
-               printf ("Doing a continue by process of process %d\n", tid);
-#endif
-
-             if (more_events_left > 0)
-               {
-                 warning ("Losing buffered events on continue.");
-                 more_events_left = 0;
-               }
-
-             call_ttrace (TT_PROC_CONTINUE,
-                          tid,
-                          TT_NIL,
-                          TT_NIL,
-                          TT_NIL);
-
-             clear_all_handled ();
-             clear_all_stepping_mode ();
-           }
-
-         else
-           {
 #ifdef THREAD_DEBUG
-             if (debug_on)
-               {
-                 printf ("Doing a continue of just thread %d\n", tid);
-                 if (is_terminated (tid))
-                   printf ("Why are we continuing a dead thread? (5)\n");
-               }
+         printf ("Doing a continue w/signal of just thread %d\n", tid);
 #endif
 
-             call_ttrace (TT_LWP_CONTINUE,
-                          tid,
-                          TT_NIL,
-                          TT_NIL,
-                          TT_NIL);
+         threads_continue_one_with_signal (tid, signal);
 
-             /* Clear the "handled" state of this thread, because
-              * we'll soon get a new event for it.  Other events
-              * can stay as they were.
-              */
-             clear_handled (tid);
-             clear_stepping_mode (tid);
-           }
+         /* Clear the "handled" state of this thread, because we
+            will soon get a new event for it.  Other events can
+            stay as they were.  */
+         clear_handled (tid);
+         clear_stepping_mode (tid);
        }
     }
 
@@ -5125,9 +5039,7 @@ pre_fork_inferior (void)
     }
 }
 
-/* Called via #define REQUIRE_ATTACH from inftarg.c,
- * ultimately from "follow_inferior_fork" in infrun.c,
- * itself called from "resume".
+/* Called from child_follow_fork in hppah-nat.c.
  *
  * This seems to be intended to attach after a fork or
  * vfork, while "attach" is used to attach to a pid
@@ -5455,8 +5367,7 @@ hppa_insert_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type)
    watchpoints.
  */
 int
-hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len,
-                          enum bptype type)
+hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type)
 {
   CORE_ADDR page_start;
   int dictionary_is_empty;
@@ -5516,7 +5427,7 @@ hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len,
    hardware support.
  */
 int
-hppa_can_use_hw_watchpoint (enum bptype type, int cnt, enum bptype ot)
+hppa_can_use_hw_watchpoint (int type, int cnt, int ot)
 {
   return (type == bp_hardware_watchpoint);
 }
@@ -5613,64 +5524,6 @@ hppa_pid_or_tid_to_str (ptid_t ptid)
 }
 \f
 
-/* If the current pid is not the pid this module reported
- * from "ptrace_wait" with the most recent event, then the
- * user has switched threads.
- *
- * If the last reported event was a breakpoint, then return
- * the old thread id, else return 0.
- */
-pid_t
-hppa_switched_threads (pid_t gdb_pid)
-{
-  if (gdb_pid == old_gdb_pid)
-    {
-      /*
-       * Core gdb is working with the same pid that it
-       * was before we reported the last event.  This
-       * is ok: e.g. we reported hitting a thread-specific
-       * breakpoint, but we were reporting the wrong
-       * thread, so the core just ignored the event.
-       *
-       * No thread switch has happened.
-       */
-      return (pid_t) 0;
-    }
-  else if (gdb_pid == reported_pid)
-    {
-      /*
-       * Core gdb is working with the pid we reported, so
-       * any continue or step will be able to figure out
-       * that it needs to step over any hit breakpoints
-       * without our (i.e. PREPARE_TO_PROCEED's) help.
-       */
-      return (pid_t) 0;
-    }
-  else if (!reported_bpt)
-    {
-      /*
-       * The core switched, but we didn't just report a
-       * breakpoint, so there's no just-hit breakpoint
-       * instruction at "reported_pid"'s PC, and thus there
-       * is no need to step over it.
-       */
-      return (pid_t) 0;
-    }
-  else
-    {
-      /* There's been a real switch, and we reported
-       * a hit breakpoint.  Let "hppa_prepare_to_proceed"
-       * know, so it can see whether the breakpoint is
-       * still active.
-       */
-      return reported_pid;
-    }
-
-  /* Keep compiler happy with an obvious return at the end.
-   */
-  return (pid_t) 0;
-}
-
 void
 hppa_ensure_vforking_parent_remains_stopped (int pid)
 {
This page took 0.064337 seconds and 4 git commands to generate.