Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Michael Snyder <msnyder@vmware.com>
Subject: Re: [RFA] remote.c, clean-up mix-up
Date: Thu, 06 May 2010 00:18:00 -0000	[thread overview]
Message-ID: <201005060118.26368.pedro@codesourcery.com> (raw)
In-Reply-To: <201005060044.35984.pedro@codesourcery.com>

On Thursday 06 May 2010 00:44:35, Pedro Alves wrote:
> Here's what I'm testing.

No regressions against x86_64-linux gdbserver.

> 2010-05-05  Pedro Alves  <pedro@codesourcery.com>
> 
>         * remote.c (clear_threads_parsing_context): New.
>         (remote_threads_info): Delele unused null_cleanup.  Install a
>         cleanup to clear the threads_parsing_context in case parsing
>         throws.

Applied as below with a little comment added and typo in
changelog fixed.

-- 
Pedro Alves

2010-05-06  Pedro Alves  <pedro@codesourcery.com>

	* 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.

---
 gdb/remote.c |   27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c	2010-05-06 01:01:56.000000000 +0100
+++ src/gdb/remote.c	2010-05-06 01:10:47.000000000 +0100
@@ -2482,6 +2482,21 @@ const struct gdb_xml_element threads_ele
   { 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 *
 	{
 	  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 *
 		      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);


  reply	other threads:[~2010-05-06  0:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-05 22:37 Michael Snyder
2010-05-05 23:08 ` Pedro Alves
2010-05-05 23:44   ` Pedro Alves
2010-05-06  0:18     ` Pedro Alves [this message]
2010-05-06  0:28       ` Michael Snyder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201005060118.26368.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=msnyder@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox