From 4d0fdd9b357aff1fea3ef3def55d12464a41bf5b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 7 Jan 2018 09:29:52 -0500 Subject: Replace VEC(gdb_xml_value_s) with std::vector This patch replaces VEC(gdb_xml_value_s), which is passed to XML visitors, with an std::vector. In order to be able to remove the cleanup in gdb_xml_parser::start_element, the gdb_xml_parser structure is made to own the value with a gdb::unique_xmalloc_ptr. This patch has been tested on the buildbot. gdb/ChangeLog: * xml-support.h (struct gdb_xml_value): Add constructor. : Change type to unique_xmalloc_ptr. (gdb_xml_value_s): Remove typedef. (DEF_VEC_O (gdb_xml_value_s)): Remove. (gdb_xml_element_start_handler): Change parameter type to std::vector. (xml_find_attribute): Likewise. * xml-support.c (xml_find_attribute): Change parameter type to std::vector and adjust. (gdb_xml_values_cleanup): Remove. (gdb_xml_parser::start_element): Adjust to std::vector. (xinclude_start_include): Change paraeter type to std::vector and adjust. * btrace.c (check_xml_btrace_version): Likewise. (parse_xml_btrace_block): Likewise. (parse_xml_btrace_pt_config_cpu): Likewise. (parse_xml_btrace_pt): Likewise. (parse_xml_btrace_conf_bts): Likewise. (parse_xml_btrace_conf_pt): Likewise. * memory-map.c (memory_map_start_memory): Likewise. (memory_map_start_property): Likewise. * osdata.c (osdata_start_osdata): Likewise. (osdata_start_item): Likewise. (osdata_start_column): Likewise. * remote.c (start_thread): Likewise. * solib-aix.c (library_list_start_library): Likewise. (library_list_start_list): Likewise. * solib-svr4.c (library_list_start_library): Likewise. (svr4_library_list_start_list): Likewise. * solib-target.c (library_list_start_segment): Likewise. (library_list_start_section): Likewise. (library_list_start_library): Likewise. (library_list_start_list): Likewise. * tracepoint.c (traceframe_info_start_memory): Likewise. (traceframe_info_start_tvar): Likewise. * xml-syscall.c (syscall_start_syscall): Likewise. * xml-tdesc.c (tdesc_start_target): Likewise. (tdesc_start_feature): Likewise. (tdesc_start_reg): Likewise. (tdesc_start_union): Likewise. (tdesc_start_struct): Likewise. (tdesc_start_flags): Likewise. (tdesc_start_enum): Likewise. (tdesc_start_field): Likewise. (tdesc_start_enum_value): Likewise. (tdesc_start_vector): Likewise. --- gdb/btrace.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'gdb/btrace.c') diff --git a/gdb/btrace.c b/gdb/btrace.c index 8823046..ffcf53a 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -2002,10 +2002,11 @@ btrace_free_objfile (struct objfile *objfile) static void check_xml_btrace_version (struct gdb_xml_parser *parser, const struct gdb_xml_element *element, - void *user_data, VEC (gdb_xml_value_s) *attributes) + void *user_data, + std::vector &attributes) { const char *version - = (const char *) xml_find_attribute (attributes, "version")->value; + = (const char *) xml_find_attribute (attributes, "version")->value.get (); if (strcmp (version, "1.0") != 0) gdb_xml_error (parser, _("Unsupported btrace version: \"%s\""), version); @@ -2016,7 +2017,8 @@ check_xml_btrace_version (struct gdb_xml_parser *parser, static void parse_xml_btrace_block (struct gdb_xml_parser *parser, const struct gdb_xml_element *element, - void *user_data, VEC (gdb_xml_value_s) *attributes) + void *user_data, + std::vector &attributes) { struct btrace_data *btrace; struct btrace_block *block; @@ -2038,8 +2040,8 @@ parse_xml_btrace_block (struct gdb_xml_parser *parser, gdb_xml_error (parser, _("Btrace format error.")); } - begin = (ULONGEST *) xml_find_attribute (attributes, "begin")->value; - end = (ULONGEST *) xml_find_attribute (attributes, "end")->value; + begin = (ULONGEST *) xml_find_attribute (attributes, "begin")->value.get (); + end = (ULONGEST *) xml_find_attribute (attributes, "end")->value.get (); block = VEC_safe_push (btrace_block_s, btrace->variant.bts.blocks, NULL); block->begin = *begin; @@ -2092,16 +2094,20 @@ static void parse_xml_btrace_pt_config_cpu (struct gdb_xml_parser *parser, const struct gdb_xml_element *element, void *user_data, - VEC (gdb_xml_value_s) *attributes) + std::vector &attributes) { struct btrace_data *btrace; const char *vendor; ULONGEST *family, *model, *stepping; - vendor = (const char *) xml_find_attribute (attributes, "vendor")->value; - family = (ULONGEST *) xml_find_attribute (attributes, "family")->value; - model = (ULONGEST *) xml_find_attribute (attributes, "model")->value; - stepping = (ULONGEST *) xml_find_attribute (attributes, "stepping")->value; + vendor = + (const char *) xml_find_attribute (attributes, "vendor")->value.get (); + family + = (ULONGEST *) xml_find_attribute (attributes, "family")->value.get (); + model + = (ULONGEST *) xml_find_attribute (attributes, "model")->value.get (); + stepping + = (ULONGEST *) xml_find_attribute (attributes, "stepping")->value.get (); btrace = (struct btrace_data *) user_data; @@ -2132,7 +2138,8 @@ parse_xml_btrace_pt_raw (struct gdb_xml_parser *parser, static void parse_xml_btrace_pt (struct gdb_xml_parser *parser, const struct gdb_xml_element *element, - void *user_data, VEC (gdb_xml_value_s) *attributes) + void *user_data, + std::vector &attributes) { struct btrace_data *btrace; @@ -2226,7 +2233,8 @@ parse_xml_btrace (struct btrace_data *btrace, const char *buffer) static void parse_xml_btrace_conf_bts (struct gdb_xml_parser *parser, const struct gdb_xml_element *element, - void *user_data, VEC (gdb_xml_value_s) *attributes) + void *user_data, + std::vector &attributes) { struct btrace_config *conf; struct gdb_xml_value *size; @@ -2237,7 +2245,7 @@ parse_xml_btrace_conf_bts (struct gdb_xml_parser *parser, size = xml_find_attribute (attributes, "size"); if (size != NULL) - conf->bts.size = (unsigned int) *(ULONGEST *) size->value; + conf->bts.size = (unsigned int) *(ULONGEST *) size->value.get (); } /* Parse a btrace-conf "pt" xml record. */ @@ -2245,7 +2253,8 @@ parse_xml_btrace_conf_bts (struct gdb_xml_parser *parser, static void parse_xml_btrace_conf_pt (struct gdb_xml_parser *parser, const struct gdb_xml_element *element, - void *user_data, VEC (gdb_xml_value_s) *attributes) + void *user_data, + std::vector &attributes) { struct btrace_config *conf; struct gdb_xml_value *size; @@ -2256,7 +2265,7 @@ parse_xml_btrace_conf_pt (struct gdb_xml_parser *parser, size = xml_find_attribute (attributes, "size"); if (size != NULL) - conf->pt.size = (unsigned int) *(ULONGEST *) size->value; + conf->pt.size = (unsigned int) *(ULONGEST *) size->value.get (); } static const struct gdb_xml_attribute btrace_conf_pt_attributes[] = { -- cgit v1.1