* gdb.texinfo (Command Files): Mention -x, use @enumerate for
[deliverable/binutils-gdb.git] / gdb / procfs.c
index d1763869eff7c789f11a543b21ce3ae49dded904..686e4bedee9edd976e1fa8dc8c6af0b5f08ddbf3 100644 (file)
@@ -24,6 +24,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "target.h"
 #include "gdbcore.h"
 #include "gdbcmd.h"
+#include "gdbthread.h"
 
 #if defined (NEW_PROC_API)
 #define _STRUCTURED_PROC 1     /* Should be done by configure script. */
@@ -33,6 +34,11 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include <sys/fault.h>
 #include <sys/syscall.h>
 #include <sys/errno.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <ctype.h>
+
+#include "proc-utils.h"
 
 /* 
  * PROCFS.C
@@ -148,6 +154,8 @@ init_procfs_ops ()
   procfs_ops.to_thread_alive       = procfs_thread_alive;
   procfs_ops.to_pid_to_str         = procfs_pid_to_str;
 
+  procfs_ops.to_has_all_memory    = 1;
+  procfs_ops.to_has_memory        = 1;
   procfs_ops.to_has_execution      = 1;
   procfs_ops.to_has_stack          = 1;
   procfs_ops.to_has_registers      = 1;
@@ -287,6 +295,8 @@ typedef prstatus_t gdb_lwpstatus_t;
 #ifndef PIDGET
 #define PIDGET(PID)            (PID)
 #define TIDGET(PID)            (PID)
+#endif
+#ifndef MERGEPID
 #define MERGEPID(PID, TID)     (PID)
 #endif
 
@@ -403,11 +413,13 @@ find_procinfo_or_die (pid, tid)
   procinfo *pi = find_procinfo (pid, tid);
 
   if (pi == NULL)
-    if (tid)
-      error ("procfs: couldn't find pid %d (kernel thread %d) in procinfo list.", 
-            pid, tid);
-    else
-      error ("procfs: couldn't find pid %d in procinfo list.", pid);
+    {
+      if (tid)
+       error ("procfs: couldn't find pid %d (kernel thread %d) in procinfo list.", 
+              pid, tid);
+      else
+       error ("procfs: couldn't find pid %d in procinfo list.", pid);
+    }
   return pi;
 }
 
@@ -431,7 +443,9 @@ open_procinfo_files (pi, which)
      procinfo *pi;
      int       which;
 {
+#ifdef NEW_PROC_API
   char tmp[MAX_PROC_NAME_SIZE];
+#endif
   int  fd;
 
   /* 
@@ -576,7 +590,7 @@ open_procinfo_files (pi, which)
  * Function: create_procinfo
  *
  * Allocate a data structure and link it into the procinfo list.
- * (First tries to find a pre-existing one (FIXME: why???)
+ * (First tries to find a pre-existing one (FIXME: why?)
  *
  * Return: pointer to new procinfo struct.
  */
@@ -2567,8 +2581,8 @@ proc_parent_pid (pi)
 
 int
 proc_set_watchpoint (pi, addr, len, wflags)
-     procinfo *pi;
-     void     *addr;
+     procinfo  *pi;
+     CORE_ADDR addr;
      int       len;
      int       wflags;
 {
@@ -2627,11 +2641,14 @@ proc_iterate_over_mappings (func)
   struct prmap *map;
   procinfo *pi;
 #ifndef NEW_PROC_API   /* avoid compiler warning */
-  int nmaps = 0, i;
+  int nmaps = 0;
+  int i;
+#else
+  int map_fd;
+  char pathname[MAX_PROC_NAME_SIZE];
 #endif
   int funcstat = 0;
-  int fd, map_fd;
-  char pathname[MAX_PROC_NAME_SIZE];
+  int fd;
 
   pi = find_procinfo_or_die (PIDGET (inferior_pid), 0);
 
@@ -3466,6 +3483,19 @@ do_detach (signo)
  * is resumed.
  */
 
+/* These could go in a header file, but the many and various
+   definitions of gregset_t would make it tricky and ugly.  Several
+   different native operating systems (notably Solaris and Linux) have
+   various different definitions for gregset_t and fpregset_t.  We
+   have been kludging around this problem for a while, it would be
+   nice if someday we came up with a prettier way of handling it
+   (FIXME).  */
+
+extern void fill_gregset (gdb_gregset_t *, int);
+extern void fill_fpregset (gdb_fpregset_t *, int);
+extern void supply_gregset (gdb_gregset_t *);
+extern void supply_fpregset (gdb_fpregset_t *);
+
 static void
 procfs_fetch_registers (regno)
      int regno;
@@ -3733,7 +3763,7 @@ wait_again:
                         return a "success" exit code.  Bogus: what if
                         it returns something else?  */
                      wstat = 0;
-                     retval = inferior_pid;  /* ??? */
+                     retval = inferior_pid;  /* ? ? ? */
                    }
                  else
                    {
@@ -3762,9 +3792,9 @@ wait_again:
                    if ((nsysargs = proc_nsysarg (pi)) > 0 &&
                        (sysargs  = proc_sysargs (pi)) != NULL)
                      {
-                       printf_filtered ("%d syscall arguments:\n", nsysargs);
+                       printf_filtered ("%ld syscall arguments:\n", nsysargs);
                        for (i = 0; i < nsysargs; i++)
-                         printf_filtered ("#%d: 0x%08x\n", 
+                         printf_filtered ("#%ld: 0x%08lx\n", 
                                           i, sysargs[i]);
                      }
 
@@ -3876,9 +3906,9 @@ wait_again:
                    if ((nsysargs = proc_nsysarg (pi)) > 0 &&
                        (sysargs  = proc_sysargs (pi)) != NULL)
                      {
-                       printf_filtered ("%d syscall arguments:\n", nsysargs);
+                       printf_filtered ("%ld syscall arguments:\n", nsysargs);
                        for (i = 0; i < nsysargs; i++)
-                         printf_filtered ("#%d: 0x%08x\n", 
+                         printf_filtered ("#%ld: 0x%08lx\n", 
                                           i, sysargs[i]);
                      }
                  }
@@ -4141,6 +4171,7 @@ invalidate_cache (parent, pi, ptr)
   return 0;
 }
 
+#if 0
 /*
  * Function: make_signal_thread_runnable
  *
@@ -4165,6 +4196,7 @@ make_signal_thread_runnable (process, pi, ptr)
 #endif
   return 0;
 }
+#endif
 
 /*
  * Function: target_resume
@@ -4216,7 +4248,7 @@ procfs_resume (pid, step, signo)
 
   /* Convert signal to host numbering.  */
   if (signo == 0 ||
-      signo == TARGET_SIGNAL_STOP && pi->ignore_next_sigstop)
+      (signo == TARGET_SIGNAL_STOP && pi->ignore_next_sigstop))
     native_signo = 0;
   else
     native_signo = target_signal_to_host (signo);
@@ -4603,7 +4635,6 @@ procfs_set_exec_trap ()
 
   procinfo *pi;
   sysset_t exitset;
-  sysset_t entryset;
 
   if ((pi = create_procinfo (getpid (), 0)) == NULL)
     perror_with_name ("procfs: create_procinfo failed in child.");
@@ -5027,11 +5058,12 @@ info_proc_cmd (args, from_tty)
 
   old_chain = make_cleanup (null_cleanup, 0);
   if (args)
-    if ((argv = buildargv (args)) == NULL)
-      nomem (0);
-    else
-      make_cleanup ((make_cleanup_func) freeargv, argv);
-
+    {
+      if ((argv = buildargv (args)) == NULL)
+       nomem (0);
+      else
+       make_cleanup ((make_cleanup_func) freeargv, argv);
+    }
   while (argv != NULL && *argv != NULL)
     {
       if (isdigit (argv[0][0]))
@@ -5173,27 +5205,6 @@ proc_untrace_sysexit_cmd (args, from_tty)
 }
 
 
-int
-mapping_test (fd, core_addr)
-     int fd;
-     CORE_ADDR core_addr;
-{
-  printf ("File descriptor %d, base address 0x%08x\n", fd, core_addr);
-  if (fd > 0)
-    close (fd);
-  return 0;
-}
-
-void
-test_mapping_cmd (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  int ret;
-  ret = proc_iterate_over_mappings (mapping_test);
-  printf ("iterate_over_mappings returned %d.\n", ret);
-}
-
 void
 _initialize_procfs ()
 {
@@ -5210,9 +5221,6 @@ Default is the process being debugged.");
           "Cancel a trace of entries into the syscall.");
   add_com ("proc-untrace-exit", no_class, proc_untrace_sysexit_cmd, 
           "Cancel a trace of exits from the syscall.");
-
-  add_com ("test-mapping", no_class, test_mapping_cmd, 
-          "test iterate-over-mappings");
 }
 
 /* =================== END, GDB  "MODULE" =================== */
@@ -5237,20 +5245,3 @@ procfs_first_available ()
   else
     return -1;
 }
-
-int
-procfs_get_pid_fd (pid)
-     int pid;
-{
-  procinfo *pi;
-
-  if (pid == -1 && inferior_pid != 0)
-    pi = find_procinfo (PIDGET (inferior_pid), 0);
-  else
-    pi = find_procinfo (PIDGET (pid), 0);
-
-  if (pi)
-    return pi->ctl_fd;
-  else
-    return -1;
-}
This page took 0.026762 seconds and 4 git commands to generate.