aboutsummaryrefslogtreecommitdiff
path: root/gdb/xml-tdesc.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-02-02 16:12:59 +0000
committerPedro Alves <palves@redhat.com>2011-02-02 16:12:59 +0000
commit3d2c1d41d4b6cdaa6052ddfd99b0745cc70c9cbb (patch)
treeaddbf54d22e8398af15ff23704ed86fd84b94bd8 /gdb/xml-tdesc.c
parent0af3e2db57c384891ab4f6905ea619930d953ae6 (diff)
downloadgdb-3d2c1d41d4b6cdaa6052ddfd99b0745cc70c9cbb.zip
gdb-3d2c1d41d4b6cdaa6052ddfd99b0745cc70c9cbb.tar.gz
gdb-3d2c1d41d4b6cdaa6052ddfd99b0745cc70c9cbb.tar.bz2
* 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.
Diffstat (limited to 'gdb/xml-tdesc.c')
-rw-r--r--gdb/xml-tdesc.c41
1 files changed, 21 insertions, 20 deletions
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;