*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / procfs.c
index 286e81c4588040f06953c3a628474522cca9ba98..c6f50d28481046cfef66358018d1128d94b2732d 100644 (file)
@@ -51,6 +51,7 @@
 #include "inflow.h"
 #include "auxv.h"
 #include "procfs.h"
+#include "observer.h"
 
 /*
  * PROCFS.C
@@ -270,6 +271,15 @@ typedef pr_siginfo64_t gdb_siginfo_t;
 typedef struct siginfo gdb_siginfo_t;
 #endif
 
+/* On mips-irix, praddset and prdelset are defined in such a way that
+   they return a value, which causes GCC to emit a -Wunused error
+   because the returned value is not used.  Prevent this warning
+   by casting the return value to void.  On sparc-solaris, this issue
+   does not exist because the definition of these macros already include
+   that cast to void.  */
+#define gdb_praddset(sp, flag) ((void) praddset (sp, flag))
+#define gdb_prdelset(sp, flag) ((void) prdelset (sp, flag))
+
 /* gdb_premptysysset */
 #ifdef premptysysset
 #define gdb_premptysysset premptysysset
@@ -281,14 +291,14 @@ typedef struct siginfo gdb_siginfo_t;
 #ifdef praddsysset
 #define gdb_praddsysset praddsysset
 #else
-#define gdb_praddsysset praddset
+#define gdb_praddsysset gdb_praddset
 #endif
 
 /* prdelsysset */
 #ifdef prdelsysset
 #define gdb_prdelsysset prdelsysset
 #else
-#define gdb_prdelsysset prdelset
+#define gdb_prdelsysset gdb_prdelset
 #endif
 
 /* prissyssetmember */
@@ -2219,7 +2229,7 @@ proc_trace_signal (procinfo *pi, int signo)
     {
       if (proc_get_traced_signals (pi, &temp))
        {
-         praddset (&temp, signo);
+         gdb_praddset (&temp, signo);
          return proc_set_traced_signals (pi, &temp);
        }
     }
@@ -2253,7 +2263,7 @@ proc_ignore_signal (procinfo *pi, int signo)
     {
       if (proc_get_traced_signals (pi, &temp))
        {
-         prdelset (&temp, signo);
+         gdb_prdelset (&temp, signo);
          return proc_set_traced_signals (pi, &temp);
        }
     }
@@ -3491,7 +3501,7 @@ procfs_debug_inferior (procinfo *pi)
 #else
   /* Register to trace hardware faults in the child. */
   prfillset (&traced_faults);          /* trace all faults... */
-  prdelset  (&traced_faults, FLTPAGE); /* except page fault.  */
+  gdb_prdelset  (&traced_faults, FLTPAGE);     /* except page fault.  */
 #endif
   if (!proc_set_traced_faults  (pi, &traced_faults))
     return __LINE__;
@@ -4377,7 +4387,7 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
 
 #ifdef NEW_PROC_API
     case TARGET_OBJECT_AUXV:
-      return procfs_xfer_auxv (ops, object, annex, readbuf, writebuf,
+      return memory_xfer_auxv (ops, object, annex, readbuf, writebuf,
                               offset, len);
 #endif
 
@@ -4642,9 +4652,9 @@ register_gdb_signals (procinfo *pi, gdb_sigset_t *signals)
     if (signal_stop_state  (target_signal_from_host (signo)) == 0 &&
        signal_print_state (target_signal_from_host (signo)) == 0 &&
        signal_pass_state  (target_signal_from_host (signo)) == 1)
-      prdelset (signals, signo);
+      gdb_prdelset (signals, signo);
     else
-      praddset (signals, signo);
+      gdb_praddset (signals, signo);
 
   return proc_set_traced_signals (pi, signals);
 }
@@ -5137,13 +5147,27 @@ procfs_create_inferior (struct target_ops *ops, char *exec_file,
                       NULL, NULL, shell_file);
 
   procfs_init_inferior (ops, pid);
+}
+
+/* An observer for the "inferior_created" event.  */
 
+static void
+procfs_inferior_created (struct target_ops *ops, int from_tty)
+{
 #ifdef SYS_syssgi
   /* Make sure to cancel the syssgi() syscall-exit notifications.  
      They should normally have been removed by now, but they may still
      be activated if the inferior doesn't use shared libraries, or if
      we didn't locate __dbx_link, or if we never stopped in __dbx_link.
-     See procfs_init_inferior() for more details.  */
+     See procfs_init_inferior() for more details.
+
+     Since these notifications are only ever enabled when we spawned
+     the inferior ourselves, there is nothing to do when the inferior
+     was created by attaching to an already running process, or when
+     debugging a core file.  */
+  if (current_inferior ()->attach_flag || !target_can_run (&current_target))
+    return;
+
   proc_trace_syscalls_1 (find_procinfo_or_die (PIDGET (inferior_ptid), 0),
                          SYS_syssgi, PR_SYSEXIT, FLAG_RESET, 0);
 #endif
@@ -5991,6 +6015,8 @@ proc_untrace_sysexit_cmd (char *args, int from_tty)
 void
 _initialize_procfs (void)
 {
+  observer_attach_inferior_created (procfs_inferior_created);
+
   add_info ("proc", info_proc_cmd, _("\
 Show /proc process information about any running process.\n\
 Specify process id, or use the program being debugged by default.\n\
@@ -6074,7 +6100,7 @@ procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
   target_fetch_registers (regcache, -1);
 
   fill_gregset (regcache, &gregs, -1);
-#if defined (UNIXWARE)
+#if defined (NEW_PROC_API)
   note_data = (char *) elfcore_write_lwpstatus (obfd,
                                                note_data,
                                                note_size,
This page took 0.025448 seconds and 4 git commands to generate.