fix error in nios2-tdep.c
[deliverable/binutils-gdb.git] / gdb / progspace.c
index 6498738909af9e97564373761b655d91b698fb4f..14507ef11cedaf2b82a5e0c167e27a01123f5def 100644 (file)
@@ -1,6 +1,6 @@
 /* Program and address space management, for GDB, the GNU debugger.
 
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -42,19 +42,27 @@ static int highest_address_space_num;
 /* Keep a registry of per-program_space data-pointers required by other GDB
    modules.  */
 
-DEFINE_REGISTRY (program_space)
+DEFINE_REGISTRY (program_space, REGISTRY_ACCESS_FIELD)
 
-\f
-
-/* An address space.  Currently this is not used for much other than
-   for comparing if pspaces/inferior/threads see the same address
+/* An address space.  It is used for comparing if pspaces/inferior/threads
+   see the same address space and for associating caches to each address
    space.  */
 
 struct address_space
 {
   int num;
+
+  /* Per aspace data-pointers required by other GDB modules.  */
+  REGISTRY_FIELDS;
 };
 
+/* Keep a registry of per-address_space data-pointers required by other GDB
+   modules.  */
+
+DEFINE_REGISTRY (address_space, REGISTRY_ACCESS_FIELD)
+
+\f
+
 /* Create a new address space object, and add it to the list.  */
 
 struct address_space *
@@ -62,8 +70,9 @@ new_address_space (void)
 {
   struct address_space *aspace;
 
-  aspace = XZALLOC (struct address_space);
+  aspace = XCNEW (struct address_space);
   aspace->num = ++highest_address_space_num;
+  address_space_alloc_data (aspace);
 
   return aspace;
 }
@@ -75,7 +84,7 @@ new_address_space (void)
 struct address_space *
 maybe_new_address_space (void)
 {
-  int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch);
+  int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch ());
 
   if (shared_aspace)
     {
@@ -89,6 +98,7 @@ maybe_new_address_space (void)
 static void
 free_address_space (struct address_space *aspace)
 {
+  address_space_free_data (aspace);
   xfree (aspace);
 }
 
@@ -116,7 +126,7 @@ add_program_space (struct address_space *aspace)
 {
   struct program_space *pspace;
 
-  pspace = XZALLOC (struct program_space);
+  pspace = XCNEW (struct program_space);
 
   pspace->num = ++last_program_space_num;
   pspace->aspace = aspace;
@@ -148,7 +158,7 @@ release_program_space (struct program_space *pspace)
   no_shared_libraries (NULL, 0);
   exec_close ();
   free_all_objfiles ();
-  if (!gdbarch_has_shared_address_space (target_gdbarch))
+  if (!gdbarch_has_shared_address_space (target_gdbarch ()))
     free_address_space (pspace->aspace);
   resize_section_table (&pspace->target_sections,
                        -resize_section_table (&pspace->target_sections, 0));
@@ -196,11 +206,11 @@ clone_program_space (struct program_space *dest, struct program_space *src)
 
   set_current_program_space (dest);
 
-  if (src->ebfd != NULL)
-    exec_file_attach (bfd_get_filename (src->ebfd), 0);
+  if (src->pspace_exec_filename != NULL)
+    exec_file_attach (src->pspace_exec_filename, 0);
 
   if (src->symfile_object_file != NULL)
-    symbol_file_add_main (src->symfile_object_file->name, 0);
+    symbol_file_add_main (objfile_name (src->symfile_object_file), 0);
 
   do_cleanups (old_chain);
   return dest;
@@ -336,9 +346,8 @@ print_program_space (struct ui_out *uiout, int requested)
 
       ui_out_field_int (uiout, "id", pspace->num);
 
-      if (pspace->ebfd)
-       ui_out_field_string (uiout, "exec",
-                            bfd_get_filename (pspace->ebfd));
+      if (pspace->pspace_exec_filename)
+       ui_out_field_string (uiout, "exec", pspace->pspace_exec_filename);
       else
        ui_out_field_skip (uiout, "exec");
 
@@ -432,7 +441,7 @@ number_of_program_spaces (void)
 void
 update_address_spaces (void)
 {
-  int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch);
+  int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch ());
   struct program_space *pspace;
   struct inferior *inf;
 
@@ -454,7 +463,7 @@ update_address_spaces (void)
       }
 
   for (inf = inferior_list; inf; inf = inf->next)
-    if (gdbarch_has_global_solist (target_gdbarch))
+    if (gdbarch_has_global_solist (target_gdbarch ()))
       inf->aspace = maybe_new_address_space ();
     else
       inf->aspace = inf->pspace->aspace;
@@ -472,7 +481,8 @@ save_current_space_and_thread (void)
   /* If restoring to null thread, we need to restore the pspace as
      well, hence, we need to save the current program space first.  */
   old_chain = save_current_program_space ();
-  save_current_inferior ();
+  /* There's no need to save the current inferior here.
+     That is handled by make_cleanup_restore_current_thread.  */
   make_cleanup_restore_current_thread ();
 
   return old_chain;
This page took 0.036828 seconds and 4 git commands to generate.