/* Definitions for targets which report shared library events.
- Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2007-2015 Free Software Foundation, Inc.
This file is part of GDB.
#include "vec.h"
#include "solib-target.h"
-#include "gdb_string.h"
-
-DEF_VEC_I(CORE_ADDR);
-
/* Private data for each loaded library. */
struct lm_info
{
void *user_data, VEC(gdb_xml_value_s) *attributes)
{
VEC(lm_info_p) **list = user_data;
- struct lm_info *item = XZALLOC (struct lm_info);
+ struct lm_info *item = XCNEW (struct lm_info);
const char *name = xml_find_attribute (attributes, "name")->value;
item->name = xstrdup (name);
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 = version->value;
+
+ if (strcmp (string, "1.0") != 0)
+ gdb_xml_error (parser,
+ _("Library list has unsupported version \"%s\""),
+ version);
+ }
}
/* Discard the constructed library list. */
/* The allowed elements and attributes for an XML library list.
The root element is a <library-list>. */
-const struct gdb_xml_attribute segment_attributes[] = {
+static const struct gdb_xml_attribute segment_attributes[] = {
{ "address", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
-const struct gdb_xml_attribute section_attributes[] = {
+static const struct gdb_xml_attribute section_attributes[] = {
{ "address", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
-const struct gdb_xml_element library_children[] = {
+static const struct gdb_xml_element library_children[] = {
{ "segment", segment_attributes, NULL,
GDB_XML_EF_REPEATABLE | GDB_XML_EF_OPTIONAL,
library_list_start_segment, NULL },
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
};
-const struct gdb_xml_attribute library_attributes[] = {
+static const struct gdb_xml_attribute library_attributes[] = {
{ "name", GDB_XML_AF_NONE, NULL, NULL },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
-const struct gdb_xml_element library_list_children[] = {
+static const struct gdb_xml_element library_list_children[] = {
{ "library", library_attributes, library_children,
GDB_XML_EF_REPEATABLE | GDB_XML_EF_OPTIONAL,
library_list_start_library, library_list_end_library },
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
};
-const struct gdb_xml_attribute library_list_attributes[] = {
- { "version", GDB_XML_AF_NONE, NULL, NULL },
+static const struct gdb_xml_attribute library_list_attributes[] = {
+ { "version", GDB_XML_AF_OPTIONAL, NULL, NULL },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
-const struct gdb_xml_element library_list_elements[] = {
+static const struct gdb_xml_element library_list_elements[] = {
{ "library-list", library_list_attributes, library_list_children,
GDB_XML_EF_NONE, library_list_start_list, NULL },
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
solib_target_current_sos (void)
{
struct so_list *new_solib, *start = NULL, *last = NULL;
- const char *library_document;
+ char *library_document;
+ struct cleanup *old_chain;
VEC(lm_info_p) *library_list;
struct lm_info *info;
int ix;
if (library_document == NULL)
return NULL;
+ /* solib_target_parse_libraries may throw, so we use a cleanup. */
+ old_chain = make_cleanup (xfree, library_document);
+
/* Parse the list. */
library_list = solib_target_parse_libraries (library_document);
+
+ /* library_document string is not needed behind this point. */
+ do_cleanups (old_chain);
+
if (library_list == NULL)
return NULL;
/* 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,
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));
}
}
- 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;
}
/* 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;