This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: segfault: what should happen when I remove an inferior that is running?


From: Pedro Alves [pedro@codesourcery.com]
Sent: December 14, 2010 10:23 AM

> On Tuesday 14 December 2010 15:08:31, Tom Tromey wrote:
> >      Removes the inferior INFNO.  It is not possible to remove an
> >      inferior that is running with this command.
> >
> > I think this means we are missing an error check somewhere.
> 
> Yeah.  I guess we could also offer to kill it or some such,
> but I guess I must have thought that it'd be simpler to
> just error out.  (either way, the user needs to take further
> action, so erroring out is simpler.)

This patch errors out for 'remove-inferior' and '-remove-inferior'
if the inferior still has a pid.

No regressions.

If it is ok, please let me know if you want it only in HEAD or
also in 7_2.

Thanks

Marc

2010-12-17  Marc Khouzam  <marc.khouzam@ericsson.com>

        * inferior.c (remove_inferior_command): Don't remove a running inferior.
	* mi/mi-main.c (mi_cmd_remove_inferior): Ditto.

### Eclipse Workspace Patch 1.0
#P src
Index: gdb/inferior.c
===================================================================
RCS file: /cvs/src/src/gdb/inferior.c,v
retrieving revision 1.20
diff -u -r1.20 inferior.c
--- gdb/inferior.c      28 Nov 2010 04:31:24 -0000      1.20
+++ gdb/inferior.c      18 Dec 2010 02:39:50 -0000
@@ -755,6 +755,9 @@
   if (inf == current_inferior ())
     error (_("Can not remove current symbol inferior."));
 
+  if (inf->pid != 0)
+    error (_("Can not remove a running inferior."));
+
   delete_inferior_1 (inf, 1);
 }
 
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.184
diff -u -r1.184 mi-main.c
--- gdb/mi/mi-main.c    18 Dec 2010 02:10:05 -0000      1.184
+++ gdb/mi/mi-main.c    18 Dec 2010 02:39:50 -0000
@@ -1772,6 +1772,9 @@
   if (!inf)
     error ("the specified thread group does not exist");
 
+  if (inf->pid != 0)
+    error ("can not remove a running inferior");
+
   if (inf == current_inferior ())
     {
       struct thread_info *tp = 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]