diff options
-rw-r--r-- | gdb/ChangeLog | 17 | ||||
-rw-r--r-- | gdb/memory-map.c | 8 | ||||
-rw-r--r-- | gdb/osdata.c | 4 | ||||
-rw-r--r-- | gdb/remote.c | 9 | ||||
-rw-r--r-- | gdb/solib-target.c | 8 | ||||
-rw-r--r-- | gdb/xml-support.c | 18 | ||||
-rw-r--r-- | gdb/xml-support.h | 6 | ||||
-rw-r--r-- | gdb/xml-tdesc.c | 41 |
8 files changed, 76 insertions, 35 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3dc3067..aa694be 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,20 @@ +2011-02-02 Pedro Alves <pedro@codesourcery.com> + + * xml-support.c (xml_find_attribute): New. + (xinclude_start_include): Use it. + * xml-support.h (xml_find_attribute): Declare. + * memory-map.c (memory_map_start_memory) + (memory_map_start_property): Use xml_find_attribute. + * osdata.c (osdata_start_osdata, osdata_start_column): Use + xml_find_attribute. + * remote.c (start_thread): Use xml_find_attribute. + * solib-target.c (library_list_start_segment) + (library_list_start_section, library_list_start_library) + (library_list_start_list): Use xml_find_attribute. + * xml-tdesc.c (tdesc_start_target, tdesc_start_feature) + (tdesc_start_union, tdesc_start_struct, tdesc_start_flags) + (tdesc_start_field): Use xml_find_attribute. + 2011-02-02 Ulrich Weigand <uweigand@de.ibm.com> * opencl-lang.c (STRINGIFY): Rename to OCL_STRING. diff --git a/gdb/memory-map.c b/gdb/memory-map.c index 77389eb..5e61ca5 100644 --- a/gdb/memory-map.c +++ b/gdb/memory-map.c @@ -64,9 +64,9 @@ memory_map_start_memory (struct gdb_xml_parser *parser, struct mem_region *r = VEC_safe_push (mem_region_s, *data->memory_map, NULL); ULONGEST *start_p, *length_p, *type_p; - start_p = VEC_index (gdb_xml_value_s, attributes, 0)->value; - length_p = VEC_index (gdb_xml_value_s, attributes, 1)->value; - type_p = VEC_index (gdb_xml_value_s, attributes, 2)->value; + start_p = xml_find_attribute (attributes, "start")->value; + length_p = xml_find_attribute (attributes, "length")->value; + type_p = xml_find_attribute (attributes, "type")->value; mem_region_init (r); r->lo = *start_p; @@ -101,7 +101,7 @@ memory_map_start_property (struct gdb_xml_parser *parser, struct memory_map_parsing_data *data = user_data; char *name; - name = VEC_index (gdb_xml_value_s, attributes, 0)->value; + name = xml_find_attribute (attributes, "name")->value; snprintf (data->property_name, sizeof (data->property_name), "%s", name); } diff --git a/gdb/osdata.c b/gdb/osdata.c index 88190e2..c82746f 100644 --- a/gdb/osdata.c +++ b/gdb/osdata.c @@ -68,7 +68,7 @@ osdata_start_osdata (struct gdb_xml_parser *parser, if (data->osdata) gdb_xml_error (parser, _("Seen more than on osdata element")); - type = VEC_index (gdb_xml_value_s, attributes, 0)->value; + type = xml_find_attribute (attributes, "type")->value; osdata = XZALLOC (struct osdata); osdata->type = xstrdup (type); data->osdata = osdata; @@ -95,7 +95,7 @@ osdata_start_column (struct gdb_xml_parser *parser, void *user_data, VEC(gdb_xml_value_s) *attributes) { struct osdata_parsing_data *data = user_data; - const char *name = VEC_index (gdb_xml_value_s, attributes, 0)->value; + const char *name = xml_find_attribute (attributes, "name")->value; data->property_name = xstrdup (name); } diff --git a/gdb/remote.c b/gdb/remote.c index b440e9e..c79f6e2 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -2505,13 +2505,14 @@ start_thread (struct gdb_xml_parser *parser, struct thread_item item; char *id; + struct gdb_xml_value *attr; - id = VEC_index (gdb_xml_value_s, attributes, 0)->value; + id = xml_find_attribute (attributes, "id")->value; item.ptid = read_ptid (id, NULL); - if (VEC_length (gdb_xml_value_s, attributes) > 1) - item.core = *(ULONGEST *) VEC_index (gdb_xml_value_s, - attributes, 1)->value; + attr = xml_find_attribute (attributes, "core"); + if (attr != NULL) + item.core = *(ULONGEST *) attr->value; else item.core = -1; diff --git a/gdb/solib-target.c b/gdb/solib-target.c index a3f5982..b6032e0 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -86,7 +86,7 @@ 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) @@ -103,7 +103,7 @@ 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) @@ -122,7 +122,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 +150,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, diff --git a/gdb/xml-support.c b/gdb/xml-support.c index 0bcb975..e0ac8de 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -138,6 +138,22 @@ gdb_xml_error (struct gdb_xml_parser *parser, const char *format, ...) throw_verror (XML_PARSE_ERROR, format, ap); } +/* Find the attribute named NAME in the set of parsed attributes + ATTRIBUTES. Returns NULL if not found. */ + +struct gdb_xml_value * +xml_find_attribute (VEC(gdb_xml_value_s) *attributes, const char *name) +{ + struct gdb_xml_value *value; + int ix; + + for (ix = 0; VEC_iterate (gdb_xml_value_s, attributes, ix, value); ix++) + if (strcmp (value->name, name) == 0) + return value; + + return NULL; +} + /* Clean up a vector of parsed attribute values. */ static void @@ -758,7 +774,7 @@ xinclude_start_include (struct gdb_xml_parser *parser, void *user_data, VEC(gdb_xml_value_s) *attributes) { struct xinclude_parsing_data *data = user_data; - char *href = VEC_index (gdb_xml_value_s, attributes, 0)->value; + char *href = xml_find_attribute (attributes, "href")->value; struct cleanup *back_to; char *text, *output; diff --git a/gdb/xml-support.h b/gdb/xml-support.h index 0cfc62c..4d5df5c 100644 --- a/gdb/xml-support.h +++ b/gdb/xml-support.h @@ -220,6 +220,12 @@ void gdb_xml_debug (struct gdb_xml_parser *parser, const char *format, ...) void gdb_xml_error (struct gdb_xml_parser *parser, const char *format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 0); +/* Find the attribute named NAME in the set of parsed attributes + ATTRIBUTES. Returns NULL if not found. */ + +struct gdb_xml_value *xml_find_attribute (VEC(gdb_xml_value_s) *attributes, + const char *name); + /* Parse an integer attribute into a ULONGEST. */ extern gdb_xml_attribute_handler gdb_xml_parse_attr_ulongest; diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c index 7568a73..5073e7b 100644 --- a/gdb/xml-tdesc.c +++ b/gdb/xml-tdesc.c @@ -152,7 +152,7 @@ tdesc_start_target (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, @@ -168,7 +168,7 @@ tdesc_start_feature (struct gdb_xml_parser *parser, void *user_data, VEC(gdb_xml_value_s) *attributes) { struct tdesc_parsing_data *data = user_data; - char *name = VEC_index (gdb_xml_value_s, attributes, 0)->value; + char *name = xml_find_attribute (attributes, "name")->value; data->current_feature = tdesc_create_feature (data->tdesc, name); } @@ -233,7 +233,7 @@ tdesc_start_union (struct gdb_xml_parser *parser, void *user_data, VEC(gdb_xml_value_s) *attributes) { struct tdesc_parsing_data *data = user_data; - char *id = VEC_index (gdb_xml_value_s, attributes, 0)->value; + char *id = xml_find_attribute (attributes, "id")->value; data->current_type = tdesc_create_union (data->current_feature, id); data->current_type_size = 0; @@ -249,18 +249,19 @@ tdesc_start_struct (struct gdb_xml_parser *parser, void *user_data, VEC(gdb_xml_value_s) *attributes) { struct tdesc_parsing_data *data = user_data; - char *id = VEC_index (gdb_xml_value_s, attributes, 0)->value; + char *id = xml_find_attribute (attributes, "id")->value; struct tdesc_type *type; + struct gdb_xml_value *attr; type = tdesc_create_struct (data->current_feature, id); data->current_type = type; data->current_type_size = 0; data->current_type_is_flags = 0; - if (VEC_length (gdb_xml_value_s, attributes) > 1) + attr = xml_find_attribute (attributes, "size"); + if (attr != NULL) { - int size = (int) * (ULONGEST *) - VEC_index (gdb_xml_value_s, attributes, 1)->value; + int size = (int) * (ULONGEST *) attr->value; tdesc_set_struct_size (type, size); data->current_type_size = size; @@ -273,9 +274,9 @@ tdesc_start_flags (struct gdb_xml_parser *parser, void *user_data, VEC(gdb_xml_value_s) *attributes) { struct tdesc_parsing_data *data = user_data; - char *id = VEC_index (gdb_xml_value_s, attributes, 0)->value; + char *id = xml_find_attribute (attributes, "id")->value; int length = (int) * (ULONGEST *) - VEC_index (gdb_xml_value_s, attributes, 1)->value; + xml_find_attribute (attributes, "size")->value; struct tdesc_type *type; type = tdesc_create_flags (data->current_feature, id, length); @@ -294,28 +295,28 @@ tdesc_start_field (struct gdb_xml_parser *parser, void *user_data, VEC(gdb_xml_value_s) *attributes) { struct tdesc_parsing_data *data = user_data; - int ix = 0, length; - struct gdb_xml_value *attrs = VEC_address (gdb_xml_value_s, attributes); + struct gdb_xml_value *attr; struct tdesc_type *field_type; char *field_name, *field_type_id; int start, end; - length = VEC_length (gdb_xml_value_s, attributes); + field_name = xml_find_attribute (attributes, "name")->value; - field_name = attrs[ix++].value; - - if (ix < length && strcmp (attrs[ix].name, "type") == 0) - field_type_id = attrs[ix++].value; + attr = xml_find_attribute (attributes, "type"); + if (attr != NULL) + field_type_id = attr->value; else field_type_id = NULL; - if (ix < length && strcmp (attrs[ix].name, "start") == 0) - start = * (ULONGEST *) attrs[ix++].value; + attr = xml_find_attribute (attributes, "start"); + if (attr != NULL) + start = * (ULONGEST *) attr->value; else start = -1; - if (ix < length && strcmp (attrs[ix].name, "end") == 0) - end = * (ULONGEST *) attrs[ix++].value; + attr = xml_find_attribute (attributes, "end"); + if (attr != NULL) + end = * (ULONGEST *) attr->value; else end = -1; |