diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2017-04-28 17:16:13 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-04-28 17:16:13 -0400 |
commit | d0e449a1865c741c5e0c9d43a7d61a0621163aa7 (patch) | |
tree | 2a4b4eb8eb25727b56d26d2bd70aff6fe9bb8942 /gdb/solib-aix.c | |
parent | 434a40239548115cf04a80410e4f570f35c361c1 (diff) | |
download | gdb-d0e449a1865c741c5e0c9d43a7d61a0621163aa7.zip gdb-d0e449a1865c741c5e0c9d43a7d61a0621163aa7.tar.gz gdb-d0e449a1865c741c5e0c9d43a7d61a0621163aa7.tar.bz2 |
Make various lm_info implementations inherit from a base class
The lm_info structure is used to store target specific information about
mapped libraries. It is currently defined as an opaque type in solist.h
and a pointer to it is included in solist, the target-agnostic object
representing a loaded shared library. Multiple targets define their own
implementation of lm_info.
In anticipation of using C++ stuff (e.g. vector) in the lm_info objects,
we first need to avoid different definitions of classes with the same
name (which violates the one definition rule). This patch does it by
having a base class (lm_info_base) from which all the specific lm_info
derive. Each implementation is renamed to something that makes sense
(e.g. lm_info_aix for AIX). The next logical step would probably be to
derive directly from so_list, it's not really obvious, so I'll keep that
for another day.
One special case is the Neutrino (nto) support. It uses SVR4-style
libraries, but overrides some methods. To do that, it needed to have
its own copy of SVR4's lm_info structure in nto-tdep.c, because it was
just not possible to put it in solib-svr4.h and include that file. Over
time, that copy got out of sync, which is still the case today. I can
only assume that the lm_addr function in nto-tdep.c is broken right now.
The first field of the old lm_info was a pointer (gdb_byte *), whereas
in the new lm_info it's an address in the inferior (CORE_ADDR). Trying
to use that field today probably results in a crash. With this
refactor, it's now possible to put lm_info_svr4 in solib-svr4.h and just
include it. I have adapted the code in nto-tdep.c to that it builds,
but it's probably not correct. Since I don't have the knowledge nor
setup to try this on Neutrino, somebody else would have to fix it. But
I am confident that I am not making things worse than they already are.
gdb/ChangeLog:
* solist.h (struct lm_info): Remove.
(struct lm_info_base): New class.
(struct so_list) <lm_info>: Change type to lm_info_base *.
* nto-tdep.c (struct lm_info): Remove.
(lm_addr): Adjust.
* solib-aix.c (struct lm_info): Rename to ...
(struct lm_info_aix): ... this. Extend lm_info_base.
(lm_info_p): Rename to ...
(lm_info_aix_p): ... this, and adjust.
(solib_aix_new_lm_info, solib_aix_xfree_lm_info,
solib_aix_parse_libraries, library_list_start_library,
solib_aix_free_library_list, solib_aix_parse_libraries,
solib_aix_get_library_list,
solib_aix_relocate_section_addresses, solib_aix_free_so,
solib_aix_get_section_offsets,
solib_aix_solib_create_inferior_hook, solib_aix_current_sos):
Adjust.
(struct solib_aix_inferior_data) <library_list>: Adjust.
* solib-darwin.c (struct lm_info): Rename to ...
(struct lm_info_darwin): ... this. Extend lm_info_base.
(darwin_current_sos, darwin_relocate_section_addresses): Adjust.
* solib-dsbt.c (struct lm_info): Rename to ...
(struct lm_info_dsbt): ... this. Extend lm_info_base.
(struct dsbt_info) <main_executable_lm_info): Adjust.
(dsbt_current_sos, dsbt_relocate_main_executable, dsbt_free_so,
dsbt_relocate_section_addresses): Adjust.
* solib-frv.c (struct lm_info): Rename to ...
(struct lm_info_frv): ... this. Extend lm_info_base.
(main_executable_lm_info): Adjust.
(frv_current_sos, frv_relocate_main_executable, frv_free_so,
frv_relocate_section_addresses, frv_fdpic_find_global_pointer,
find_canonical_descriptor_in_load_object,
frv_fdpic_find_canonical_descriptor): Adjust.
* solib-svr4.c (struct lm_info): Move to solib-svr4.h, renamed
to lm_info_svr4.
(lm_info_read, lm_addr_check, svr4_keep_data_in_core,
svr4_clear_so, svr4_copy_library_list,
library_list_start_library, svr4_default_sos, svr4_read_so_list,
svr4_current_sos, svr4_fetch_objfile_link_map,
solist_update_incremental): Adjust.
* solib-svr4.h (struct lm_info_svr4): Move here from
solib-svr4.c.
* solib-target.c (struct lm_info): Rename to ...
(struct lm_info_target): ... this. Extend lm_info_base.
(lm_info_p): Rename to ...
(lm_info_target_p): ... this.
(solib_target_parse_libraries, library_list_start_segment,
library_list_start_section, library_list_start_library,
library_list_end_library, solib_target_free_library_list,
solib_target_current_sos, solib_target_free_so,
solib_target_relocate_section_addresses): Adjust.
* windows-nat.c (struct lm_info): Rename to ...
(struct lm_info_windows): ... this. Extend lm_info_base.
(windows_make_so, handle_load_dll, handle_unload_dll,
windows_xfer_shared_libraries): Adjust.
Diffstat (limited to 'gdb/solib-aix.c')
-rw-r--r-- | gdb/solib-aix.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index 66add03..54b8c38 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -33,7 +33,7 @@ static int solib_aix_debug; /* Our private data in struct so_list. */ -struct lm_info +struct lm_info_aix : public lm_info_base { /* The name of the file mapped by the loader. Apart from the entry for the main executable, this is usually a shared library (which, @@ -58,17 +58,17 @@ struct lm_info ULONGEST data_size; }; -typedef struct lm_info *lm_info_p; -DEF_VEC_P(lm_info_p); +typedef lm_info_aix *lm_info_aix_p; +DEF_VEC_P(lm_info_aix_p); /* Return a deep copy of the given struct lm_info object. */ -static struct lm_info * -solib_aix_new_lm_info (struct lm_info *info) +static lm_info_aix * +solib_aix_new_lm_info (lm_info_aix *info) { - struct lm_info *result = XNEW (struct lm_info); + lm_info_aix *result = XCNEW (lm_info_aix); - memcpy (result, info, sizeof (struct lm_info)); + memcpy (result, info, sizeof (lm_info_aix)); result->filename = xstrdup (info->filename); if (info->member_name != NULL) result->member_name = xstrdup (info->member_name); @@ -79,7 +79,7 @@ solib_aix_new_lm_info (struct lm_info *info) /* Free the memory allocated for the given lm_info. */ static void -solib_aix_xfree_lm_info (struct lm_info *info) +solib_aix_xfree_lm_info (lm_info_aix *info) { xfree (info->filename); xfree (info->member_name); @@ -98,7 +98,7 @@ struct solib_aix_inferior_data the same principles applied to shared libraries also apply to the main executable. So it's simpler to keep it as part of this list. */ - VEC (lm_info_p) *library_list; + VEC (lm_info_aix_p) *library_list; }; /* Key to our per-inferior data. */ @@ -127,7 +127,7 @@ get_solib_aix_inferior_data (struct inferior *inf) /* Dummy implementation if XML support is not compiled in. */ -static VEC (lm_info_p) * +static VEC (lm_info_aix_p) * solib_aix_parse_libraries (const char *library) { static int have_warned; @@ -161,8 +161,8 @@ library_list_start_library (struct gdb_xml_parser *parser, void *user_data, VEC (gdb_xml_value_s) *attributes) { - VEC (lm_info_p) **list = (VEC (lm_info_p) **) user_data; - struct lm_info *item = XCNEW (struct lm_info); + VEC (lm_info_aix_p) **list = (VEC (lm_info_aix_p) **) user_data; + lm_info_aix *item = XCNEW (lm_info_aix); struct gdb_xml_value *attr; attr = xml_find_attribute (attributes, "name"); @@ -184,7 +184,7 @@ library_list_start_library (struct gdb_xml_parser *parser, attr = xml_find_attribute (attributes, "data_size"); item->data_size = * (ULONGEST *) attr->value; - VEC_safe_push (lm_info_p, *list, item); + VEC_safe_push (lm_info_aix_p, *list, item); } /* Handle the start of a <library-list-aix> element. */ @@ -207,16 +207,16 @@ library_list_start_list (struct gdb_xml_parser *parser, static void solib_aix_free_library_list (void *p) { - VEC (lm_info_p) **result = (VEC (lm_info_p) **) p; - struct lm_info *info; + VEC (lm_info_aix_p) **result = (VEC (lm_info_aix_p) **) p; + lm_info_aix *info; int ix; if (solib_aix_debug) fprintf_unfiltered (gdb_stdlog, "DEBUG: solib_aix_free_library_list\n"); - for (ix = 0; VEC_iterate (lm_info_p, *result, ix, info); ix++) + for (ix = 0; VEC_iterate (lm_info_aix_p, *result, ix, info); ix++) solib_aix_xfree_lm_info (info); - VEC_free (lm_info_p, *result); + VEC_free (lm_info_aix_p, *result); *result = NULL; } @@ -256,14 +256,14 @@ static const struct gdb_xml_element library_list_elements[] = }; /* Parse LIBRARY, a string containing the loader info in XML format, - and return an lm_info_p vector. + and return an lm_info_aix_p vector. Return NULL if the parsing failed. */ -static VEC (lm_info_p) * +static VEC (lm_info_aix_p) * solib_aix_parse_libraries (const char *library) { - VEC (lm_info_p) *result = NULL; + VEC (lm_info_aix_p) *result = NULL; struct cleanup *back_to = make_cleanup (solib_aix_free_library_list, &result); @@ -291,7 +291,7 @@ solib_aix_parse_libraries (const char *library) is not NULL, then print a warning including WARNING_MSG and a description of the error. */ -static VEC (lm_info_p) * +static VEC (lm_info_aix_p) * solib_aix_get_library_list (struct inferior *inf, const char *warning_msg) { struct solib_aix_inferior_data *data; @@ -394,7 +394,7 @@ solib_aix_relocate_section_addresses (struct so_list *so, struct bfd_section *bfd_sect = sec->the_bfd_section; bfd *abfd = bfd_sect->owner; const char *section_name = bfd_section_name (abfd, bfd_sect); - struct lm_info *info = so->lm_info; + lm_info_aix *info = (lm_info_aix *) so->lm_info; if (strcmp (section_name, ".text") == 0) { @@ -446,7 +446,7 @@ solib_aix_free_so (struct so_list *so) if (solib_aix_debug) fprintf_unfiltered (gdb_stdlog, "DEBUG: solib_aix_free_so (%s)\n", so->so_name); - solib_aix_xfree_lm_info (so->lm_info); + solib_aix_xfree_lm_info ((lm_info_aix *) so->lm_info); } /* Implement the "clear_solib" target_so_ops method. */ @@ -465,7 +465,7 @@ solib_aix_clear_solib (void) static struct section_offsets * solib_aix_get_section_offsets (struct objfile *objfile, - struct lm_info *info) + lm_info_aix *info) { struct section_offsets *offsets; bfd *abfd = objfile->obfd; @@ -519,8 +519,8 @@ static void solib_aix_solib_create_inferior_hook (int from_tty) { const char *warning_msg = "unable to relocate main executable"; - VEC (lm_info_p) *library_list; - struct lm_info *exec_info; + VEC (lm_info_aix_p) *library_list; + lm_info_aix *exec_info; /* We need to relocate the main executable... */ @@ -529,13 +529,13 @@ solib_aix_solib_create_inferior_hook (int from_tty) if (library_list == NULL) return; /* Warning already printed. */ - if (VEC_length (lm_info_p, library_list) < 1) + if (VEC_length (lm_info_aix_p, library_list) < 1) { warning (_("unable to relocate main executable (no info from loader)")); return; } - exec_info = VEC_index (lm_info_p, library_list, 0); + exec_info = VEC_index (lm_info_aix_p, library_list, 0); if (symfile_objfile != NULL) { @@ -554,8 +554,8 @@ static struct so_list * solib_aix_current_sos (void) { struct so_list *start = NULL, *last = NULL; - VEC (lm_info_p) *library_list; - struct lm_info *info; + VEC (lm_info_aix_p) *library_list; + lm_info_aix *info; int ix; library_list = solib_aix_get_library_list (current_inferior (), NULL); @@ -565,7 +565,7 @@ solib_aix_current_sos (void) /* Build a struct so_list for each entry on the list. We skip the first entry, since this is the entry corresponding to the main executable, not a shared library. */ - for (ix = 1; VEC_iterate (lm_info_p, library_list, ix, info); ix++) + for (ix = 1; VEC_iterate (lm_info_aix_p, library_list, ix, info); ix++) { struct so_list *new_solib = XCNEW (struct so_list); char *so_name; |