OSDN Git Service

* gdbarch.sh (info_proc): New callback.
[pf3gnuchains/pf3gnuchains4x.git] / gdb / linux-nat.c
index 6b3c68f..0a46e83 100644 (file)
@@ -58,7 +58,6 @@
 #include <sys/vfs.h>
 #include "solib.h"
 #include "linux-osdata.h"
-#include "cli/cli-utils.h"
 
 #ifndef SPUFS_MAGIC
 #define SPUFS_MAGIC 0x23c9b64e
@@ -4801,251 +4800,6 @@ linux_nat_make_corefile_notes (bfd *obfd, int *note_size)
   return note_data;
 }
 
-/* Implement the "info proc" command.  */
-
-static void
-linux_nat_info_proc (struct target_ops *ops, char *args,
-                    enum info_proc_what what)
-{
-  /* A long is used for pid instead of an int to avoid a loss of precision
-     compiler warning from the output of strtoul.  */
-  long pid = PIDGET (inferior_ptid);
-  FILE *procfile;
-  char buffer[MAXPATHLEN];
-  char fname1[MAXPATHLEN], fname2[MAXPATHLEN];
-  int cmdline_f = (what == IP_MINIMAL || what == IP_CMDLINE || what == IP_ALL);
-  int cwd_f = (what == IP_MINIMAL || what == IP_CWD || what == IP_ALL);
-  int exe_f = (what == IP_MINIMAL || what == IP_EXE || what == IP_ALL);
-  int mappings_f = (what == IP_MAPPINGS || what == IP_ALL);
-  int status_f = (what == IP_STATUS || what == IP_ALL);
-  int stat_f = (what == IP_STAT || what == IP_ALL);
-  struct stat dummy;
-
-  if (args && isdigit (args[0]))
-    pid = strtoul (args, &args, 10);
-
-  args = skip_spaces (args);
-  if (args && args[0])
-    error (_("Too many parameters: %s"), args);
-
-  if (pid == 0)
-    error (_("No current process: you must name one."));
-
-  sprintf (fname1, "/proc/%ld", pid);
-  if (stat (fname1, &dummy) != 0)
-    error (_("No /proc directory: '%s'"), fname1);
-
-  printf_filtered (_("process %ld\n"), pid);
-  if (cmdline_f)
-    {
-      sprintf (fname1, "/proc/%ld/cmdline", pid);
-      if ((procfile = fopen (fname1, "r")) != NULL)
-       {
-         struct cleanup *cleanup = make_cleanup_fclose (procfile);
-
-          if (fgets (buffer, sizeof (buffer), procfile))
-            printf_filtered ("cmdline = '%s'\n", buffer);
-          else
-            warning (_("unable to read '%s'"), fname1);
-         do_cleanups (cleanup);
-       }
-      else
-       warning (_("unable to open /proc file '%s'"), fname1);
-    }
-  if (cwd_f)
-    {
-      sprintf (fname1, "/proc/%ld/cwd", pid);
-      memset (fname2, 0, sizeof (fname2));
-      if (readlink (fname1, fname2, sizeof (fname2)) > 0)
-       printf_filtered ("cwd = '%s'\n", fname2);
-      else
-       warning (_("unable to read link '%s'"), fname1);
-    }
-  if (exe_f)
-    {
-      sprintf (fname1, "/proc/%ld/exe", pid);
-      memset (fname2, 0, sizeof (fname2));
-      if (readlink (fname1, fname2, sizeof (fname2)) > 0)
-       printf_filtered ("exe = '%s'\n", fname2);
-      else
-       warning (_("unable to read link '%s'"), fname1);
-    }
-  if (mappings_f)
-    {
-      sprintf (fname1, "/proc/%ld/maps", pid);
-      if ((procfile = fopen (fname1, "r")) != NULL)
-       {
-         long long addr, endaddr, size, offset, inode;
-         char permissions[8], device[8], filename[MAXPATHLEN];
-         struct cleanup *cleanup;
-
-         cleanup = make_cleanup_fclose (procfile);
-         printf_filtered (_("Mapped address spaces:\n\n"));
-         if (gdbarch_addr_bit (target_gdbarch) == 32)
-           {
-             printf_filtered ("\t%10s %10s %10s %10s %7s\n",
-                          "Start Addr",
-                          "  End Addr",
-                          "      Size", "    Offset", "objfile");
-            }
-         else
-            {
-             printf_filtered ("  %18s %18s %10s %10s %7s\n",
-                          "Start Addr",
-                          "  End Addr",
-                          "      Size", "    Offset", "objfile");
-           }
-
-         while (read_mapping (procfile, &addr, &endaddr, &permissions[0],
-                              &offset, &device[0], &inode, &filename[0]))
-           {
-             size = endaddr - addr;
-
-             /* FIXME: carlton/2003-08-27: Maybe the printf_filtered
-                calls here (and possibly above) should be abstracted
-                out into their own functions?  Andrew suggests using
-                a generic local_address_string instead to print out
-                the addresses; that makes sense to me, too.  */
-
-             if (gdbarch_addr_bit (target_gdbarch) == 32)
-               {
-                 printf_filtered ("\t%#10lx %#10lx %#10x %#10x %7s\n",
-                              (unsigned long) addr,    /* FIXME: pr_addr */
-                              (unsigned long) endaddr,
-                              (int) size,
-                              (unsigned int) offset,
-                              filename[0] ? filename : "");
-               }
-             else
-               {
-                 printf_filtered ("  %#18lx %#18lx %#10x %#10x %7s\n",
-                              (unsigned long) addr,    /* FIXME: pr_addr */
-                              (unsigned long) endaddr,
-                              (int) size,
-                              (unsigned int) offset,
-                              filename[0] ? filename : "");
-               }
-           }
-
-         do_cleanups (cleanup);
-       }
-      else
-       warning (_("unable to open /proc file '%s'"), fname1);
-    }
-  if (status_f)
-    {
-      sprintf (fname1, "/proc/%ld/status", pid);
-      if ((procfile = fopen (fname1, "r")) != NULL)
-       {
-         struct cleanup *cleanup = make_cleanup_fclose (procfile);
-
-         while (fgets (buffer, sizeof (buffer), procfile) != NULL)
-           puts_filtered (buffer);
-         do_cleanups (cleanup);
-       }
-      else
-       warning (_("unable to open /proc file '%s'"), fname1);
-    }
-  if (stat_f)
-    {
-      sprintf (fname1, "/proc/%ld/stat", pid);
-      if ((procfile = fopen (fname1, "r")) != NULL)
-       {
-         int itmp;
-         char ctmp;
-         long ltmp;
-         struct cleanup *cleanup = make_cleanup_fclose (procfile);
-
-         if (fscanf (procfile, "%d ", &itmp) > 0)
-           printf_filtered (_("Process: %d\n"), itmp);
-         if (fscanf (procfile, "(%[^)]) ", &buffer[0]) > 0)
-           printf_filtered (_("Exec file: %s\n"), buffer);
-         if (fscanf (procfile, "%c ", &ctmp) > 0)
-           printf_filtered (_("State: %c\n"), ctmp);
-         if (fscanf (procfile, "%d ", &itmp) > 0)
-           printf_filtered (_("Parent process: %d\n"), itmp);
-         if (fscanf (procfile, "%d ", &itmp) > 0)
-           printf_filtered (_("Process group: %d\n"), itmp);
-         if (fscanf (procfile, "%d ", &itmp) > 0)
-           printf_filtered (_("Session id: %d\n"), itmp);
-         if (fscanf (procfile, "%d ", &itmp) > 0)
-           printf_filtered (_("TTY: %d\n"), itmp);
-         if (fscanf (procfile, "%d ", &itmp) > 0)
-           printf_filtered (_("TTY owner process group: %d\n"), itmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("Flags: 0x%lx\n"), ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("Minor faults (no memory page): %lu\n"),
-                            (unsigned long) ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("Minor faults, children: %lu\n"),
-                            (unsigned long) ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("Major faults (memory page faults): %lu\n"),
-                            (unsigned long) ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("Major faults, children: %lu\n"),
-                            (unsigned long) ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("utime: %ld\n"), ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("stime: %ld\n"), ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("utime, children: %ld\n"), ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("stime, children: %ld\n"), ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("jiffies remaining in current "
-                              "time slice: %ld\n"), ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("'nice' value: %ld\n"), ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("jiffies until next timeout: %lu\n"),
-                            (unsigned long) ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("jiffies until next SIGALRM: %lu\n"),
-                            (unsigned long) ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("start time (jiffies since "
-                              "system boot): %ld\n"), ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("Virtual memory size: %lu\n"),
-                            (unsigned long) ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("Resident set size: %lu\n"),
-                            (unsigned long) ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("rlim: %lu\n"), (unsigned long) ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("Start of text: 0x%lx\n"), ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("End of text: 0x%lx\n"), ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)
-           printf_filtered (_("Start of stack: 0x%lx\n"), ltmp);
-#if 0  /* Don't know how architecture-dependent the rest is...
-          Anyway the signal bitmap info is available from "status".  */
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)     /* FIXME arch?  */
-           printf_filtered (_("Kernel stack pointer: 0x%lx\n"), ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)     /* FIXME arch?  */
-           printf_filtered (_("Kernel instr pointer: 0x%lx\n"), ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("Pending signals bitmap: 0x%lx\n"), ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("Blocked signals bitmap: 0x%lx\n"), ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("Ignored signals bitmap: 0x%lx\n"), ltmp);
-         if (fscanf (procfile, "%ld ", &ltmp) > 0)
-           printf_filtered (_("Catched signals bitmap: 0x%lx\n"), ltmp);
-         if (fscanf (procfile, "%lu ", &ltmp) > 0)     /* FIXME arch?  */
-           printf_filtered (_("wchan (system call): 0x%lx\n"), ltmp);
-#endif
-         do_cleanups (cleanup);
-       }
-      else
-       warning (_("unable to open /proc file '%s'"), fname1);
-    }
-}
-
 /* Implement the to_xfer_partial interface for memory reads using the /proc
    filesystem.  Because we can use a single read() call for /proc, this
    can be much more efficient than banging away at PTRACE_PEEKTEXT,
@@ -5340,7 +5094,6 @@ linux_target_install_ops (struct target_ops *t)
   t->to_follow_fork = linux_child_follow_fork;
   t->to_find_memory_regions = linux_nat_find_memory_regions;
   t->to_make_corefile_notes = linux_nat_make_corefile_notes;
-  t->to_info_proc = linux_nat_info_proc;
 
   super_xfer_partial = t->to_xfer_partial;
   t->to_xfer_partial = linux_xfer_partial;