diff options
author | Pedro Alves <palves@redhat.com> | 2011-01-25 09:49:59 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2011-01-25 09:49:59 +0000 |
commit | efc0eabd6019406ff92286a36713d41a42515e09 (patch) | |
tree | ba00441bc43cc80496e16e09e2e9ae366e2079dd /gdb/memory-map.c | |
parent | f30f86fa955570721c2c0c95468d975f216bf754 (diff) | |
download | binutils-gdb-efc0eabd6019406ff92286a36713d41a42515e09.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.c | 23 |
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 */ |