This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[gdbserver] Make it safe for the callback function to delete the currently iterated inferior.
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 22 Mar 2009 22:32:42 +0000
- Subject: [gdbserver] Make it safe for the callback function to delete the currently iterated inferior.
I've been carrying this for non-stop + multiprocess changes, but
since this is a common idiom in GDB, I'm checking it in separately
as obvious.
--
Pedro Alves
2009-03-22 Pedro Alves <pedro@codesourcery.com>
* inferiors.c (find_inferior): Make it safe for the callback
function to delete the currently iterated inferior.
---
gdb/gdbserver/inferiors.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: src/gdb/gdbserver/inferiors.c
===================================================================
--- src.orig/gdb/gdbserver/inferiors.c 2009-03-22 22:26:44.000000000 +0000
+++ src/gdb/gdbserver/inferiors.c 2009-03-22 22:26:51.000000000 +0000
@@ -180,9 +180,12 @@ find_inferior (struct inferior_list *lis
while (inf != NULL)
{
+ struct inferior_list_entry *next;
+
+ next = inf->next;
if ((*func) (inf, arg))
return inf;
- inf = inf->next;
+ inf = next;
}
return NULL;