[FT32] gdb: Correctly interpret function prologs
[deliverable/binutils-gdb.git] / gdb / progspace.c
index a74b6abbd97deeb647399c9fe2542c4d4e3f42e0..3d7e4759772858556ef732f52a2e58fa35bcda13 100644 (file)
@@ -1,6 +1,6 @@
 /* Program and address space management, for GDB, the GNU debugger.
 
-   Copyright (C) 2009-2014 Free Software Foundation, Inc.
+   Copyright (C) 2009-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -215,7 +215,7 @@ set_current_program_space (struct program_space *pspace)
 static void
 restore_program_space (void *arg)
 {
-  struct program_space *saved_pspace = arg;
+  struct program_space *saved_pspace = (struct program_space *) arg;
 
   set_current_program_space (saved_pspace);
 }
@@ -235,8 +235,8 @@ save_current_program_space (void)
 
 /* Returns true iff there's no inferior bound to PSPACE.  */
 
-static int
-pspace_empty_p (struct program_space *pspace)
+int
+program_space_empty_p (struct program_space *pspace)
 {
   if (find_inferior_for_program_space (pspace) != NULL)
       return 0;
@@ -244,30 +244,31 @@ pspace_empty_p (struct program_space *pspace)
   return 1;
 }
 
-/* Prune away automatically added program spaces that aren't required
-   anymore.  */
+/* Remove a program space from the program spaces list and release it.  It is
+   an error to call this function while PSPACE is the current program space. */
 
 void
-prune_program_spaces (void)
+delete_program_space (struct program_space *pspace)
 {
   struct program_space *ss, **ss_link;
-  struct program_space *current = current_program_space;
+  gdb_assert (pspace != NULL);
+  gdb_assert (pspace != current_program_space);
 
   ss = program_spaces;
   ss_link = &program_spaces;
-  while (ss)
+  while (ss != NULL)
     {
-      if (ss == current || !pspace_empty_p (ss))
+      if (ss == pspace)
        {
-         ss_link = &ss->next;
-         ss = *ss_link;
-         continue;
+         *ss_link = ss->next;
+         break;
        }
 
-      *ss_link = ss->next;
-      release_program_space (ss);
+      ss_link = &ss->next;
       ss = *ss_link;
     }
+
+  release_program_space (pspace);
 }
 
 /* Prints the list of program spaces and their details on UIOUT.  If
@@ -281,10 +282,6 @@ print_program_space (struct ui_out *uiout, int requested)
   int count = 0;
   struct cleanup *old_chain;
 
-  /* Might as well prune away unneeded ones, so the user doesn't even
-     seem them.  */
-  prune_program_spaces ();
-
   /* Compute number of pspaces we will print.  */
   ALL_PSPACES (pspace)
     {
@@ -463,8 +460,7 @@ save_current_space_and_thread (void)
   return old_chain;
 }
 
-/* Switches full context to program space PSPACE.  Switches to the
-   first thread found bound to PSPACE.  */
+/* See progspace.h  */
 
 void
 switch_to_program_space_and_thread (struct program_space *pspace)
@@ -472,7 +468,7 @@ switch_to_program_space_and_thread (struct program_space *pspace)
   struct inferior *inf;
 
   inf = find_inferior_for_program_space (pspace);
-  if (inf != NULL)
+  if (inf != NULL && inf->pid != 0)
     {
       struct thread_info *tp;
 
This page took 0.030365 seconds and 4 git commands to generate.