}
else
{
- child_inf->aspace = new_address_space ();
+ child_inf->aspace = new address_space ();
child_inf->pspace = new program_space (child_inf->aspace);
child_inf->removable = 1;
clone_program_space (child_inf->pspace, parent_inf->pspace);
child_inf->aspace = parent_inf->aspace;
child_inf->pspace = parent_inf->pspace;
- parent_inf->aspace = new_address_space ();
+ parent_inf->aspace = new address_space ();
parent_inf->pspace = new program_space (parent_inf->aspace);
clone_program_space (parent_inf->pspace, child_inf->pspace);
}
else
{
- child_inf->aspace = new_address_space ();
+ child_inf->aspace = new address_space ();
child_inf->pspace = new program_space (child_inf->aspace);
child_inf->removable = 1;
child_inf->symfile_flags = SYMFILE_NO_READ;
/* Create a new address space object, and add it to the list. */
-struct address_space *
-new_address_space (void)
+address_space::address_space ()
+ : m_num (++highest_address_space_num)
{
- struct address_space *aspace;
-
- aspace = XCNEW (struct address_space);
- aspace->num = ++highest_address_space_num;
- address_space_alloc_data (aspace);
-
- return aspace;
+ address_space_alloc_data (this);
}
/* Maybe create a new address space object, and add it to the list, or
return program_spaces[0]->aspace;
}
- return new_address_space ();
-}
-
-static void
-free_address_space (struct address_space *aspace)
-{
- address_space_free_data (aspace);
- xfree (aspace);
+ return new address_space ();
}
-int
-address_space_num (struct address_space *aspace)
+address_space::~address_space ()
{
- return aspace->num;
+ address_space_free_data (this);
}
/* Start counting over from scratch. */
locations for this pspace which we're tearing down. */
clear_symtab_users (SYMFILE_DEFER_BP_RESET);
if (!gdbarch_has_shared_address_space (target_gdbarch ()))
- free_address_space (this->aspace);
+ delete this->aspace;
/* Discard any data modules have associated with the PSPACE. */
program_space_free_data (this);
}
if (shared_aspace)
{
- struct address_space *aspace = new_address_space ();
+ struct address_space *aspace = new address_space ();
- free_address_space (current_program_space->aspace);
+ delete current_program_space->aspace;
for (struct program_space *pspace : program_spaces)
pspace->aspace = aspace;
}
else
for (struct program_space *pspace : program_spaces)
{
- free_address_space (pspace->aspace);
- pspace->aspace = new_address_space ();
+ delete pspace->aspace;
+ pspace->aspace = new address_space ();
}
for (inferior *inf : all_inferiors ())
modules have done that. Do this before
initialize_current_architecture, because that accesses the ebfd
of current_program_space. */
- current_program_space = new program_space (new_address_space ());
+ current_program_space = new program_space (new address_space ());
}
associating caches to each address space. */
struct address_space
{
- int num;
+ /* Create a new address space object, and add it to the list. */
+ address_space ();
+ ~address_space ();
+ DISABLE_COPY_AND_ASSIGN (address_space);
+
+ /* Returns the integer address space id of this address space. */
+ int num () const
+ {
+ return m_num;
+ }
/* Per aspace data-pointers required by other GDB modules. */
- REGISTRY_FIELDS;
+ REGISTRY_FIELDS {};
+
+private:
+ int m_num;
};
/* The list of all program spaces. There's always at least one. */
program_space *m_saved_pspace;
};
-/* Create a new address space object, and add it to the list. */
-extern struct address_space *new_address_space (void);
-
/* Maybe create a new address space object, and add it to the list, or
return a pointer to an existing address space, in case inferiors
share an address space. */
extern struct address_space *maybe_new_address_space (void);
-/* Returns the integer address space id of ASPACE. */
-extern int address_space_num (struct address_space *aspace);
-
/* Update all program spaces matching to address spaces. The user may
have created several program spaces, and loaded executables into
them before connecting to the target interface that will create the
Target mock_target;
ptid_t mock_ptid {1, 1};
- program_space mock_pspace {new_address_space ()};
+ program_space mock_pspace {new address_space ()};
inferior mock_inferior {mock_ptid.pid ()};
thread_info mock_thread {&mock_inferior, mock_ptid};
#define target_debug_print_LONGEST_p(X) \
target_debug_do_print (phex (*(X), 0))
#define target_debug_print_struct_address_space_p(X) \
- target_debug_do_print (plongest (address_space_num (X)))
+ target_debug_do_print (plongest ((X)->num ()))
#define target_debug_print_struct_bp_target_info_p(X) \
target_debug_do_print (core_addr_to_string ((X)->placed_address))
#define target_debug_print_struct_expression_p(X) \