stack: fix gdb.dwarf2/dw2-undefined-ret-addr.exp regression
[deliverable/binutils-gdb.git] / gdb / solib-target.c
index 54b4855c2be89bb80073be2d281140c4281fec9e..e6350446ec191c8ec45e3b4456675d5019a01ea6 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions for targets which report shared library events.
 
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -26,8 +26,6 @@
 #include "vec.h"
 #include "solib-target.h"
 
-#include "gdb_string.h"
-
 /* Private data for each loaded library.  */
 struct lm_info
 {
@@ -82,9 +80,10 @@ library_list_start_segment (struct gdb_xml_parser *parser,
                            const struct gdb_xml_element *element,
                            void *user_data, VEC(gdb_xml_value_s) *attributes)
 {
-  VEC(lm_info_p) **list = user_data;
+  VEC(lm_info_p) **list = (VEC(lm_info_p) **) user_data;
   struct lm_info *last = VEC_last (lm_info_p, *list);
-  ULONGEST *address_p = xml_find_attribute (attributes, "address")->value;
+  ULONGEST *address_p
+    = (ULONGEST *) xml_find_attribute (attributes, "address")->value;
   CORE_ADDR address = (CORE_ADDR) *address_p;
 
   if (last->section_bases != NULL)
@@ -99,9 +98,10 @@ library_list_start_section (struct gdb_xml_parser *parser,
                            const struct gdb_xml_element *element,
                            void *user_data, VEC(gdb_xml_value_s) *attributes)
 {
-  VEC(lm_info_p) **list = user_data;
+  VEC(lm_info_p) **list = (VEC(lm_info_p) **) user_data;
   struct lm_info *last = VEC_last (lm_info_p, *list);
-  ULONGEST *address_p = xml_find_attribute (attributes, "address")->value;
+  ULONGEST *address_p
+    = (ULONGEST *) xml_find_attribute (attributes, "address")->value;
   CORE_ADDR address = (CORE_ADDR) *address_p;
 
   if (last->segment_bases != NULL)
@@ -118,9 +118,10 @@ library_list_start_library (struct gdb_xml_parser *parser,
                            const struct gdb_xml_element *element,
                            void *user_data, VEC(gdb_xml_value_s) *attributes)
 {
-  VEC(lm_info_p) **list = user_data;
-  struct lm_info *item = XZALLOC (struct lm_info);
-  const char *name = xml_find_attribute (attributes, "name")->value;
+  VEC(lm_info_p) **list = (VEC(lm_info_p) **) user_data;
+  struct lm_info *item = XCNEW (struct lm_info);
+  const char *name
+    = (const char *) xml_find_attribute (attributes, "name")->value;
 
   item->name = xstrdup (name);
   VEC_safe_push (lm_info_p, *list, item);
@@ -131,7 +132,7 @@ library_list_end_library (struct gdb_xml_parser *parser,
                          const struct gdb_xml_element *element,
                          void *user_data, const char *body_text)
 {
-  VEC(lm_info_p) **list = user_data;
+  VEC(lm_info_p) **list = (VEC(lm_info_p) **) user_data;
   struct lm_info *lm_info = VEC_last (lm_info_p, *list);
 
   if (lm_info->segment_bases == NULL
@@ -148,12 +149,18 @@ library_list_start_list (struct gdb_xml_parser *parser,
                         const struct gdb_xml_element *element,
                         void *user_data, VEC(gdb_xml_value_s) *attributes)
 {
-  char *version = xml_find_attribute (attributes, "version")->value;
+  struct gdb_xml_value *version = xml_find_attribute (attributes, "version");
 
-  if (strcmp (version, "1.0") != 0)
-    gdb_xml_error (parser,
-                  _("Library list has unsupported version \"%s\""),
-                  version);
+  /* #FIXED attribute may be omitted, Expat returns NULL in such case.  */
+  if (version != NULL)
+    {
+      const char *string = (const char *) version->value;
+
+      if (strcmp (string, "1.0") != 0)
+       gdb_xml_error (parser,
+                      _("Library list has unsupported version \"%s\""),
+                      version);
+    }
 }
 
 /* Discard the constructed library list.  */
@@ -161,7 +168,7 @@ library_list_start_list (struct gdb_xml_parser *parser,
 static void
 solib_target_free_library_list (void *p)
 {
-  VEC(lm_info_p) **result = p;
+  VEC(lm_info_p) **result = (VEC(lm_info_p) **) p;
   struct lm_info *info;
   int ix;
 
@@ -212,7 +219,7 @@ static const struct gdb_xml_element library_list_children[] = {
 };
 
 static const struct gdb_xml_attribute library_list_attributes[] = {
-  { "version", GDB_XML_AF_NONE, NULL, NULL },
+  { "version", GDB_XML_AF_OPTIONAL, NULL, NULL },
   { NULL, GDB_XML_AF_NONE, NULL, NULL }
 };
 
@@ -274,7 +281,7 @@ solib_target_current_sos (void)
   /* Build a struct so_list for each entry on the list.  */
   for (ix = 0; VEC_iterate (lm_info_p, library_list, ix, info); ix++)
     {
-      new_solib = XZALLOC (struct so_list);
+      new_solib = XCNEW (struct so_list);
       strncpy (new_solib->so_name, info->name, SO_NAME_MAX_PATH_SIZE - 1);
       new_solib->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
       strncpy (new_solib->so_original_name, info->name,
@@ -333,16 +340,17 @@ static void
 solib_target_relocate_section_addresses (struct so_list *so,
                                         struct target_section *sec)
 {
-  int flags = bfd_get_section_flags (sec->bfd, sec->the_bfd_section);
   CORE_ADDR offset;
 
   /* Build the offset table only once per object file.  We can not do
      it any earlier, since we need to open the file first.  */
   if (so->lm_info->offsets == NULL)
     {
-      int num_sections = bfd_count_sections (so->abfd);
+      int num_sections = gdb_bfd_count_sections (so->abfd);
 
-      so->lm_info->offsets = xzalloc (SIZEOF_N_SECTION_OFFSETS (num_sections));
+      so->lm_info->offsets
+       = ((struct section_offsets *)
+          xzalloc (SIZEOF_N_SECTION_OFFSETS (num_sections)));
 
       if (so->lm_info->section_bases)
        {
@@ -457,7 +465,9 @@ Could not relocate shared library \"%s\": bad offsets"), so->so_name);
        }
     }
 
-  offset = so->lm_info->offsets->offsets[sec->the_bfd_section->index];
+  offset = so->lm_info->offsets->offsets[gdb_bfd_section_index
+                                        (sec->the_bfd_section->owner,
+                                         sec->the_bfd_section)];
   sec->addr += offset;
   sec->endaddr += offset;
 }
@@ -476,7 +486,7 @@ solib_target_in_dynsym_resolve_code (CORE_ADDR pc)
   /* We don't have a range of addresses for the dynamic linker; there
      may not be one in the program's address space.  So only report
      PLT entries (which may be import stubs).  */
-  return in_plt_section (pc, NULL);
+  return in_plt_section (pc);
 }
 
 struct target_so_ops solib_target_so_ops;
This page took 0.026125 seconds and 4 git commands to generate.