X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fsolib-target.c;h=23cb2e7f14e313da9c3f6ea9c7e36fd1e384f9aa;hb=45a466b578083a05f1138eff9232254b1a30f683;hp=a3f598299de6046a4d6446026a7a9615a7d1974c;hpb=efc0eabd6019406ff92286a36713d41a42515e09;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/solib-target.c b/gdb/solib-target.c index a3f598299d..23cb2e7f14 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -1,6 +1,6 @@ /* Definitions for targets which report shared library events. - Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2007-2013 Free Software Foundation, Inc. This file is part of GDB. @@ -28,8 +28,6 @@ #include "gdb_string.h" -DEF_VEC_O(CORE_ADDR); - /* Private data for each loaded library. */ struct lm_info { @@ -86,14 +84,14 @@ library_list_start_segment (struct gdb_xml_parser *parser, { VEC(lm_info_p) **list = user_data; struct lm_info *last = VEC_last (lm_info_p, *list); - ULONGEST *address_p = VEC_index (gdb_xml_value_s, attributes, 0)->value; + ULONGEST *address_p = xml_find_attribute (attributes, "address")->value; CORE_ADDR address = (CORE_ADDR) *address_p; if (last->section_bases != NULL) gdb_xml_error (parser, _("Library list with both segments and sections")); - VEC_safe_push (CORE_ADDR, last->segment_bases, &address); + VEC_safe_push (CORE_ADDR, last->segment_bases, address); } static void @@ -103,14 +101,14 @@ library_list_start_section (struct gdb_xml_parser *parser, { VEC(lm_info_p) **list = user_data; struct lm_info *last = VEC_last (lm_info_p, *list); - ULONGEST *address_p = VEC_index (gdb_xml_value_s, attributes, 0)->value; + ULONGEST *address_p = xml_find_attribute (attributes, "address")->value; CORE_ADDR address = (CORE_ADDR) *address_p; if (last->segment_bases != NULL) gdb_xml_error (parser, _("Library list with both segments and sections")); - VEC_safe_push (CORE_ADDR, last->section_bases, &address); + VEC_safe_push (CORE_ADDR, last->section_bases, address); } /* Handle the start of a element. */ @@ -122,7 +120,7 @@ library_list_start_library (struct gdb_xml_parser *parser, { VEC(lm_info_p) **list = user_data; struct lm_info *item = XZALLOC (struct lm_info); - const char *name = VEC_index (gdb_xml_value_s, attributes, 0)->value; + const char *name = xml_find_attribute (attributes, "name")->value; item->name = xstrdup (name); VEC_safe_push (lm_info_p, *list, item); @@ -150,7 +148,7 @@ 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 = VEC_index (gdb_xml_value_s, attributes, 0)->value; + char *version = xml_find_attribute (attributes, "version")->value; if (strcmp (version, "1.0") != 0) gdb_xml_error (parser, @@ -181,17 +179,17 @@ solib_target_free_library_list (void *p) /* The allowed elements and attributes for an XML library list. The root element is a . */ -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 }, @@ -201,24 +199,24 @@ const struct gdb_xml_element library_children[] = { { 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[] = { +static const struct gdb_xml_attribute library_list_attributes[] = { { "version", GDB_XML_AF_NONE, 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 } @@ -248,7 +246,8 @@ static struct so_list * 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; @@ -260,8 +259,15 @@ solib_target_current_sos (void) 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;