summaryrefslogtreecommitdiff
path: root/gdb/memory-map.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2011-01-25 09:49:58 +0000
committerPedro Alves <pedro@codesourcery.com>2011-01-25 09:49:58 +0000
commit5f6f9139e39b1e2b926f88b884f998b733053e5f (patch)
treee78b06a8817e966ad2dc59c6f3e8edaf46129825 /gdb/memory-map.c
parentd1a96080833408808c09bdb6c9263b9abe27ac39 (diff)
downloadgdb-5f6f9139e39b1e2b926f88b884f998b733053e5f.tar.gz
Simplify XML parsing a bit.
* xml-support.h (gdb_xml_parse_quick): Declare. * xml-support.c (gdb_xml_create_parser_and_cleanup_1): Renamed from gdb_xml_create_parser_and_cleanup, and added `old_chain' parameter. (gdb_xml_create_parser_and_cleanup): Reimplement on top of gdb_xml_create_parser_and_cleanup_1. (gdb_xml_parse_quick): New. * memory-map.c (parse_memory_map): Use gdb_xml_parse_quick. * osdata.c (osdata_parse): Ditto. * remote.c (remote_threads_info): Ditto. * solib-target.c (solib_target_parse_libraries): Ditto. * xml-syscall.c (syscall_parse_xml): Ditto. * xml-tdesc.c (tdesc_parse_xml): Ditto.
Diffstat (limited to 'gdb/memory-map.c')
-rw-r--r--gdb/memory-map.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/gdb/memory-map.c b/gdb/memory-map.c
index d10419c8e59..77389eb9938 100644
--- a/gdb/memory-map.c
+++ b/gdb/memory-map.c
@@ -178,25 +178,22 @@ const struct gdb_xml_element memory_map_elements[] = {
VEC(mem_region_s) *
parse_memory_map (const char *memory_map)
{
- struct gdb_xml_parser *parser;
VEC(mem_region_s) *result = NULL;
- struct cleanup *before_deleting_result, *back_to;
+ struct cleanup *back_to;
struct memory_map_parsing_data data = { NULL };
- back_to = make_cleanup (null_cleanup, NULL);
- parser = gdb_xml_create_parser_and_cleanup (_("target memory map"),
- memory_map_elements, &data);
-
- /* Note: 'clear_result' will zero 'result'. */
- before_deleting_result = make_cleanup (clear_result, &result);
data.memory_map = &result;
-
- if (gdb_xml_parse (parser, memory_map) == 0)
- /* Parsed successfully, don't need to delete the result. */
- discard_cleanups (before_deleting_result);
+ back_to = make_cleanup (clear_result, &result);
+ if (gdb_xml_parse_quick (_("target memory map"), NULL, memory_map_elements,
+ memory_map, &data) == 0)
+ {
+ /* Parsed successfully, keep the result. */
+ discard_cleanups (back_to);
+ return result;
+ }
do_cleanups (back_to);
- return result;
+ return NULL;
}
#endif /* HAVE_LIBEXPAT */