Handle "p S::method()::static_var" in the C++ parser
[deliverable/binutils-gdb.git] / gdb / procfs.c
index 87c317f375866db9a4d9da225078aace538c29e6..504d74c05fba3c648cff9e3256621d8e2986d871 100644 (file)
@@ -122,8 +122,8 @@ static void procfs_pass_signals (struct target_ops *self,
                                 int, unsigned char *);
 static void procfs_kill_inferior (struct target_ops *ops);
 static void procfs_mourn_inferior (struct target_ops *ops);
-static void procfs_create_inferior (struct target_ops *, char *,
-                                   char *, char **, int);
+static void procfs_create_inferior (struct target_ops *, const char *,
+                                   const std::string &, char **, int);
 static ptid_t procfs_wait (struct target_ops *,
                           ptid_t, struct target_waitstatus *, int);
 static enum target_xfer_status procfs_xfer_memory (gdb_byte *,
@@ -4377,7 +4377,7 @@ procfs_init_inferior (struct target_ops *ops, int pid)
   thread_change_ptid (pid_to_ptid (pid),
                      ptid_build (pid, lwpid, 0));
 
-  startup_inferior (START_INFERIOR_TRAPS_EXPECTED);
+  gdb_startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED);
 
 #ifdef SYS_syssgi
   /* On mips-irix, we need to stop the inferior early enough during
@@ -4526,8 +4526,8 @@ procfs_set_exec_trap (void)
    inf-ptrace?  */
 
 static void
-procfs_create_inferior (struct target_ops *ops, char *exec_file,
-                       char *allargs, char **env, int from_tty)
+procfs_create_inferior (struct target_ops *ops, const char *exec_file,
+                       const std::string &allargs, char **env, int from_tty)
 {
   char *shell_file = getenv ("SHELL");
   char *tryname;
@@ -4604,6 +4604,11 @@ procfs_create_inferior (struct target_ops *ops, char *exec_file,
   pid = fork_inferior (exec_file, allargs, env, procfs_set_exec_trap,
                       NULL, NULL, shell_file, NULL);
 
+  /* We have something that executes now.  We'll be running through
+     the shell at this point (if startup-with-shell is true), but the
+     pid shouldn't change.  */
+  add_thread_silent (pid_to_ptid (pid));
+
   procfs_init_inferior (ops, pid);
 }
 
@@ -5095,7 +5100,6 @@ procfs_info_proc (struct target_ops *ops, const char *args,
   struct cleanup *old_chain;
   procinfo *process  = NULL;
   procinfo *thread   = NULL;
-  char    **argv     = NULL;
   char     *tmp      = NULL;
   int       pid      = 0;
   int       tid      = 0;
@@ -5116,24 +5120,19 @@ procfs_info_proc (struct target_ops *ops, const char *args,
     }
 
   old_chain = make_cleanup (null_cleanup, 0);
-  if (args)
-    {
-      argv = gdb_buildargv (args);
-      make_cleanup_freeargv (argv);
-    }
-  while (argv != NULL && *argv != NULL)
+  gdb_argv built_argv (args);
+  for (char *arg : argv)
     {
-      if (isdigit (argv[0][0]))
+      if (isdigit (arg[0]))
        {
-         pid = strtoul (argv[0], &tmp, 10);
+         pid = strtoul (arg, &tmp, 10);
          if (*tmp == '/')
            tid = strtoul (++tmp, NULL, 10);
        }
-      else if (argv[0][0] == '/')
+      else if (arg[0] == '/')
        {
-         tid = strtoul (argv[0] + 1, NULL, 10);
+         tid = strtoul (arg + 1, NULL, 10);
        }
-      argv++;
     }
   if (pid == 0)
     pid = ptid_get_pid (inferior_ptid);
@@ -5317,7 +5316,6 @@ procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
   gdb_gregset_t gregs;
   gdb_fpregset_t fpregs;
   unsigned long merged_pid;
-  struct cleanup *old_chain;
 
   merged_pid = ptid_get_lwp (ptid) << 16 | ptid_get_pid (ptid);
 
@@ -5326,7 +5324,7 @@ procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
      once it is implemented in this platform:
      gdbarch_iterate_over_regset_sections().  */
 
-  old_chain = save_inferior_ptid ();
+  scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
   inferior_ptid = ptid;
   target_fetch_registers (regcache, -1);
 
@@ -5353,8 +5351,6 @@ procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
                                              &fpregs,
                                              sizeof (fpregs));
 
-  do_cleanups (old_chain);
-
   return note_data;
 }
 
This page took 0.02583 seconds and 4 git commands to generate.