/* Program and address space management, for GDB, the GNU debugger.
- Copyright (C) 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This file is part of GDB.
#include "target.h"
#include "vec.h"
#include "gdb_vecs.h"
+#include "registry.h"
struct target_ops;
struct bfd;
struct exec;
struct address_space;
struct program_space_data;
+struct address_space_data;
typedef struct so_list *so_list_ptr;
DEF_VEC_P (so_list_ptr);
bfd *ebfd;
/* The last-modified time, from when the exec was brought in. */
long ebfd_mtime;
+ /* Similar to bfd_get_filename (exec_bfd) but in original form given
+ by user, without symbolic links and pathname resolved.
+ It needs to be freed by xfree. It is not NULL iff EBFD is not NULL. */
+ char *pspace_exec_filename;
/* The address space attached to this program space. More than one
program space may be bound to the same address space. In the
VEC (char_ptr) *deleted_solibs;
/* Per pspace data-pointers required by other GDB modules. */
- void **data;
- unsigned num_data;
+ REGISTRY_FIELDS;
};
/* The object file that the main symbol table was loaded from (e.g. the
pointer to the new object. */
extern struct program_space *add_program_space (struct address_space *aspace);
-/* Release PSPACE and removes it from the pspace list. */
-extern void remove_program_space (struct program_space *pspace);
+/* 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. */
+extern void delete_program_space (struct program_space *pspace);
/* Returns the number of program spaces listed. */
extern int number_of_program_spaces (void);
+/* Returns true iff there's no inferior bound to PSPACE. */
+extern int program_space_empty_p (struct program_space *pspace);
+
/* Copies program space SRC to DEST. Copies the main executable file,
and the main symbol file. Returns DEST. */
extern struct program_space *clone_program_space (struct program_space *dest,
struct program_space *src);
-/* Save the current program space so that it may be restored by a later
- call to do_cleanups. Returns the struct cleanup pointer needed for
- later doing the cleanup. */
-extern struct cleanup *save_current_program_space (void);
-
/* Sets PSPACE as the current program space. This is usually used
instead of set_current_space_and_thread when the current
thread/inferior is not important for the operations that follow.
space. */
extern void set_current_program_space (struct program_space *pspace);
-/* Saves the current thread (may be null), frame and program space in
- the current cleanup chain. */
-extern struct cleanup *save_current_space_and_thread (void);
+/* Save/restore the current program space. */
+
+class scoped_restore_current_program_space
+{
+public:
+ scoped_restore_current_program_space ()
+ : m_saved_pspace (current_program_space)
+ {}
+
+ ~scoped_restore_current_program_space ()
+ { set_current_program_space (m_saved_pspace); }
+
+ /* Disable copy. */
+ scoped_restore_current_program_space
+ (const scoped_restore_current_program_space &) = delete;
+ void operator=
+ (const scoped_restore_current_program_space &) = delete;
-/* Switches full context to program space PSPACE. Switches to the
- first thread found bound to PSPACE. */
-extern void switch_to_program_space_and_thread (struct program_space *pspace);
+private:
+ 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);
mappings. */
extern void update_address_spaces (void);
-/* Prune away automatically added program spaces that aren't required
- anymore. */
-extern void prune_program_spaces (void);
-
/* Reset saved solib data at the start of an solib event. This lets
us properly collect the data when calling solib_add, so it can then
later be printed. */
/* Keep a registry of per-pspace data-pointers required by other GDB
modules. */
-extern const struct program_space_data *register_program_space_data (void);
-extern const struct program_space_data *register_program_space_data_with_cleanup
- (void (*cleanup) (struct program_space *, void *));
-extern void clear_program_space_data (struct program_space *pspace);
-extern void set_program_space_data (struct program_space *pspace,
- const struct program_space_data *data,
- void *value);
-extern void *program_space_data (struct program_space *pspace,
- const struct program_space_data *data);
+DECLARE_REGISTRY (program_space);
+
+/* Keep a registry of per-aspace data-pointers required by other GDB
+ modules. */
+
+DECLARE_REGISTRY (address_space);
#endif