aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2010-05-06 00:15:29 +0000
committerPedro Alves <palves@redhat.com>2010-05-06 00:15:29 +0000
commit02357a4aafd655e14222cdfa5e1c316bd1bbb092 (patch)
treee955d8a52d81151b31646042e6ca9bd96ac62d62 /gdb/remote.c
parent8c5630cb0862b06f1ee546a303a8550e424c8bbc (diff)
downloadgdb-02357a4aafd655e14222cdfa5e1c316bd1bbb092.zip
gdb-02357a4aafd655e14222cdfa5e1c316bd1bbb092.tar.gz
gdb-02357a4aafd655e14222cdfa5e1c316bd1bbb092.tar.bz2
* remote.c (clear_threads_parsing_context): New.
(remote_threads_info): Delete unused null_cleanup. Install a cleanup to clear the threads_parsing_context in case parsing throws.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 3982084..95bbc3f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2482,6 +2482,21 @@ const struct gdb_xml_element threads_elements[] = {
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
};
+/* Discard the contents of the constructed thread info context. */
+
+static void
+clear_threads_parsing_context (void *p)
+{
+ struct threads_parsing_context *context = p;
+ int i;
+ struct thread_item *item;
+
+ for (i = 0; VEC_iterate (thread_item_t, context->items, i, item); ++i)
+ xfree (item->extra);
+
+ VEC_free (thread_item_t, context->items);
+}
+
#endif
/*
@@ -2512,15 +2527,20 @@ remote_threads_info (struct target_ops *ops)
{
struct gdb_xml_parser *parser;
struct threads_parsing_context context;
- struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
+ struct cleanup *clear_parsing_context;
context.items = 0;
+ /* Note: this parser cleanup is already guarded by BACK_TO
+ above. */
parser = gdb_xml_create_parser_and_cleanup (_("threads"),
threads_elements,
&context);
gdb_xml_use_dtd (parser, "threads.dtd");
+ clear_parsing_context
+ = make_cleanup (clear_threads_parsing_context, &context);
+
if (gdb_xml_parse (parser, xml) == 0)
{
int i;
@@ -2542,13 +2562,12 @@ remote_threads_info (struct target_ops *ops)
info = demand_private_info (item->ptid);
info->core = item->core;
info->extra = item->extra;
- item->extra = 0;
+ item->extra = NULL;
}
- xfree (item->extra);
}
}
- VEC_free (thread_item_t, context.items);
+ do_cleanups (clear_parsing_context);
}
do_cleanups (back_to);