* RFC: fix crash when inferior exits during "continue"
@ 2012-02-07 19:14 Tom Tromey
2012-02-10 14:41 ` Jan Kratochvil
0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2012-02-07 19:14 UTC (permalink / raw)
To: gdb-patches
I'd appreciate comments on this patch.
This patch fixes PR 13653. The bug is that you can make gdb crash with
a certain sequence:
set detach-on-fork off
set target-async on
set non-stop on
... run inferior, which forks; then the child stops somewhere
inferior 2
continue
... inferior 2 exits, gdb crashes
The crash happens because do_restore_current_thread_cleanup tries to
select a deleted inferior, causing the assertion in set_current_inferior
to fail.
This patch fixes the problem by noticing that the saved inferior no
longer exists, and arbitrarily selecting some other inferior instead.
Two questions for the reader:
1. Is this the right approach? I am not sure. It seems pretty
reasonable to me, but I don't know this area very well.
2. Are the conditions in the new .exp file correct? I mostly copied
these from elsewhere, not knowing what is really right.
Built and regtested on x86-64 Fedora 15.
New test case included.
Tom
b/gdb/ChangeLog:
2012-02-07 Tom Tromey <tromey@redhat.com>
PR c++/13653:
* thread.c (choose_first_inferior): New function.
(do_restore_current_thread_cleanup): Handle case where inferior
died.
diff --git a/gdb/testsuite/gdb.base/inferior-died.c b/gdb/testsuite/gdb.base/inferior-died.c
new file mode 100644
index 0000000..66227cf
--- /dev/null
+++ b/gdb/testsuite/gdb.base/inferior-died.c
@@ -0,0 +1,37 @@
+/* Test for fork-related gdb bug
+
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+void function(void)
+{
+ exit (0); /* Break here */
+}
+
+int main()
+{
+ pid_t child = fork ();
+
+ if (child == 0)
+ function ();
+ else
+ waitpid (child, NULL, 0);
+}
diff --git a/gdb/testsuite/gdb.base/inferior-died.exp b/gdb/testsuite/gdb.base/inferior-died.exp
new file mode 100644
index 0000000..458dd61
--- /dev/null
+++ b/gdb/testsuite/gdb.base/inferior-died.exp
@@ -0,0 +1,56 @@
+# Copyright 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if { [is_remote target] || ![isnative] } then {
+ unsupported "inferior-died.exp"
+ continue
+}
+
+# Until "set follow-fork-mode" and "catch fork" are implemented on
+# other targets...
+#
+if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-*-linux*"]} then {
+ unsupported "inferior-died.exp"
+ continue
+}
+
+if { ![support_displaced_stepping] } {
+ unsupported "inferior-died.exp"
+ return -1
+}
+
+set testfile "inferior-died"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c] } {
+ return -1
+}
+
+gdb_test_no_output "set detach-on-fork off"
+gdb_test_no_output "set target-async on"
+gdb_test_no_output "set non-stop on"
+
+if ![runto_main] {
+ return
+}
+
+set line [gdb_get_line_number "Break here"]
+gdb_breakpoint $srcfile:$line
+
+gdb_continue_to_breakpoint "breakpoint"
+
+gdb_test "inferior 2" "Switching to inferior 2.*"
+gdb_test "continue" "exited normally.*"
diff --git a/gdb/thread.c b/gdb/thread.c
index 9a29383..6a667d6 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1074,6 +1074,16 @@ struct current_thread_cleanup
int inf_id;
};
+/* A helper function for do_restore_current_thread_cleanup. This is
+ passed to iterate_over_inferiors and simply returns the first
+ inferior. */
+
+static int
+choose_first_inferior (struct inferior *inf, void *ignore)
+{
+ return 1;
+}
+
static void
do_restore_current_thread_cleanup (void *arg)
{
@@ -1091,8 +1101,15 @@ do_restore_current_thread_cleanup (void *arg)
restore_current_thread (old->inferior_ptid);
else
{
+ struct inferior *inf = find_inferior_id (old->inf_id);
+
restore_current_thread (null_ptid);
- set_current_inferior (find_inferior_id (old->inf_id));
+
+ /* If the inferior was deleted, choose some other inferior. */
+ if (inf == NULL)
+ inf = iterate_over_inferiors (choose_first_inferior, NULL);
+
+ set_current_inferior (inf);
}
/* The running state of the originally selected thread may have
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: RFC: fix crash when inferior exits during "continue"
2012-02-07 19:14 RFC: fix crash when inferior exits during "continue" Tom Tromey
@ 2012-02-10 14:41 ` Jan Kratochvil
2012-02-10 20:05 ` Tom Tromey
0 siblings, 1 reply; 12+ messages in thread
From: Jan Kratochvil @ 2012-02-10 14:41 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Tue, 07 Feb 2012 20:13:54 +0100, Tom Tromey wrote:
> Built and regtested on x86-64 Fedora 15.
It does crash for me on F-15 but it does not crash on either F-16 or F-17.
> b/gdb/ChangeLog:
Missing testsuite/ ChangeLog.
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/inferior-died.exp
> @@ -0,0 +1,56 @@
> +# Copyright 2012 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +
> +if { [is_remote target] || ![isnative] } then {
"isnative" is excessive"; but linux-nat cannot be cross-target anyway.
> + unsupported "inferior-died.exp"
> + continue
> +}
> +
> +# Until "set follow-fork-mode" and "catch fork" are implemented on
> +# other targets...
> +#
> +if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-*-linux*"]} then {
> + unsupported "inferior-died.exp"
> + continue
> +}
> +
> +if { ![support_displaced_stepping] } {
> + unsupported "inferior-died.exp"
> + return -1
> +}
> +
[...]
> --- a/gdb/thread.c
> +++ b/gdb/thread.c
[...]
> @@ -1091,8 +1101,15 @@ do_restore_current_thread_cleanup (void *arg)
> restore_current_thread (old->inferior_ptid);
> else
> {
> + struct inferior *inf = find_inferior_id (old->inf_id);
> +
> restore_current_thread (null_ptid);
> - set_current_inferior (find_inferior_id (old->inf_id));
> +
> + /* If the inferior was deleted, choose some other inferior. */
Maybe during make_cleanup_restore_current_thread temporarily remember + clear
inferior->removable instead.
> + if (inf == NULL)
> + inf = iterate_over_inferiors (choose_first_inferior, NULL);
> +
> + set_current_inferior (inf);
> }
>
> /* The running state of the originally selected thread may have
Thanks,
Jan
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: RFC: fix crash when inferior exits during "continue"
2012-02-10 14:41 ` Jan Kratochvil
@ 2012-02-10 20:05 ` Tom Tromey
2012-02-14 13:44 ` Gary Benson
0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2012-02-10 20:05 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> Maybe during make_cleanup_restore_current_thread temporarily
Jan> remember + clear inferior-> removable instead.
I hadn't considered this, but it is an interesting idea.
It would have the maybe odd effect of leaving the dead inferior around
as long as it was selected. Maybe this is even the clearest thing to
do; I am not sure.
Do you (or anybody) have an opinion on which is better?
Tom
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: RFC: fix crash when inferior exits during "continue"
2012-02-10 20:05 ` Tom Tromey
@ 2012-02-14 13:44 ` Gary Benson
2012-02-14 14:19 ` Pedro Alves
0 siblings, 1 reply; 12+ messages in thread
From: Gary Benson @ 2012-02-14 13:44 UTC (permalink / raw)
To: Tom Tromey; +Cc: Jan Kratochvil, gdb-patches
Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> Jan> Maybe during make_cleanup_restore_current_thread temporarily
> Jan> remember + clear inferior-> removable instead.
>
> I hadn't considered this, but it is an interesting idea.
>
> It would have the maybe odd effect of leaving the dead inferior
> around as long as it was selected. Maybe this is even the clearest
> thing to do; I am not sure.
>
> Do you (or anybody) have an opinion on which is better?
I'm not especially familiar with this area of GDB, but I prefer the
idea of holding the selection on the dead inferior over arbitrarily
selecting another. I think the latter could be confusing.
Gary
--
http://gbenson.net/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: RFC: fix crash when inferior exits during "continue"
2012-02-14 13:44 ` Gary Benson
@ 2012-02-14 14:19 ` Pedro Alves
2012-02-15 22:24 ` Tom Tromey
0 siblings, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2012-02-14 14:19 UTC (permalink / raw)
To: Tom Tromey, Jan Kratochvil, gdb-patches
On 02/14/2012 01:44 PM, Gary Benson wrote:
> Tom Tromey wrote:
>>>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>>
>> Jan> Maybe during make_cleanup_restore_current_thread temporarily
>> Jan> remember + clear inferior-> removable instead.
>>
>> I hadn't considered this, but it is an interesting idea.
>>
>> It would have the maybe odd effect of leaving the dead inferior
>> around as long as it was selected. Maybe this is even the clearest
>> thing to do; I am not sure.
>>
>> Do you (or anybody) have an opinion on which is better?
>
> I'm not especially familiar with this area of GDB, but I prefer the
> idea of holding the selection on the dead inferior over arbitrarily
> selecting another. I think the latter could be confusing.
Yeah. We also don't randomly switch to another thread if the previous
selected thread exits (and this is the reason we have "exited" threads).
Otherwise, if the user is typing
(gdb) some_command_that_applies_to_the_current_thread <enter>
and the current thread disappears while the user is typing,
the command ends up being applied to a random thread, which is
not good.
In this case, we need to step back a little. Why are we removing
the inferior at all? The whole idea of inf->removable was that
when you run, say, "make check" under gdb, and you follow all forks,
you don't want to end up with 1000 inferiors loaded. So gdb marks
inferiors/forks that appeared not by explicit user action
as "removable". Those that are removable are pruned by prune_inferiors,
roughly whenever we handle an event that gives the prompt to the
user (at the end of normal_stop).
But in this case, the user explicitly switched to a "removable"
inferior, and then resumed (inferior 2; continue; <crash, inf2 is gone>)
So we may consider two things:
- The inferior should no longer be "removable". The user has
expressed interest in it.
- Make make_cleanup_restore_current_thread "lock" the current
inferior, so it isn't removed even if it is "removable".
We do something similar for threads -- That's the whole reason
for thread_info->refcount. (This is also Jan's suggestion.)
--
Pedro Alves
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: RFC: fix crash when inferior exits during "continue"
2012-02-14 14:19 ` Pedro Alves
@ 2012-02-15 22:24 ` Tom Tromey
2012-02-16 12:45 ` Pedro Alves
2012-02-20 2:41 ` [patch] testsuite: Fix inferior-died.exp racy FAILs [Re: RFC: fix crash when inferior exits during "continue"] Jan Kratochvil
0 siblings, 2 replies; 12+ messages in thread
From: Tom Tromey @ 2012-02-15 22:24 UTC (permalink / raw)
To: Pedro Alves; +Cc: Jan Kratochvil, gdb-patches
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> Yeah. We also don't randomly switch to another thread if the previous
Pedro> selected thread exits (and this is the reason we have "exited" threads).
Pedro> Otherwise, if the user is typing
Pedro> (gdb) some_command_that_applies_to_the_current_thread <enter>
Pedro> and the current thread disappears while the user is typing,
Pedro> the command ends up being applied to a random thread, which is
Pedro> not good.
This makes sense to me if the user entered a background command.
But why not switch if the last command was a foreground command?
Pedro> - Make make_cleanup_restore_current_thread "lock" the current
Pedro> inferior, so it isn't removed even if it is "removable".
Pedro> We do something similar for threads -- That's the whole reason
Pedro> for thread_info->refcount. (This is also Jan's suggestion.)
What do you think of the appended?
Tom
2012-02-15 Tom Tromey <tromey@redhat.com>
PR c++/13653:
* thread.c (struct current_thread_cleanup) <was_removable>: New
field.
(do_restore_current_thread_cleanup): Restore 'removable' field.
(restore_current_thread_cleanup_dtor): Likewise.
(make_cleanup_restore_current_thread): Initialize new field.
2012-02-15 Tom Tromey <tromey@redhat.com>
* gdb.base/inferior-died.c: New file.
* gdb.base/inferior-died.exp: New file.
diff --git a/gdb/testsuite/gdb.base/inferior-died.c b/gdb/testsuite/gdb.base/inferior-died.c
new file mode 100644
index 0000000..66227cf
--- /dev/null
+++ b/gdb/testsuite/gdb.base/inferior-died.c
@@ -0,0 +1,37 @@
+/* Test for fork-related gdb bug
+
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+void function(void)
+{
+ exit (0); /* Break here */
+}
+
+int main()
+{
+ pid_t child = fork ();
+
+ if (child == 0)
+ function ();
+ else
+ waitpid (child, NULL, 0);
+}
diff --git a/gdb/testsuite/gdb.base/inferior-died.exp b/gdb/testsuite/gdb.base/inferior-died.exp
new file mode 100644
index 0000000..458dd61
--- /dev/null
+++ b/gdb/testsuite/gdb.base/inferior-died.exp
@@ -0,0 +1,56 @@
+# Copyright 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if { [is_remote target] || ![isnative] } then {
+ unsupported "inferior-died.exp"
+ continue
+}
+
+# Until "set follow-fork-mode" and "catch fork" are implemented on
+# other targets...
+#
+if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-*-linux*"]} then {
+ unsupported "inferior-died.exp"
+ continue
+}
+
+if { ![support_displaced_stepping] } {
+ unsupported "inferior-died.exp"
+ return -1
+}
+
+set testfile "inferior-died"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c] } {
+ return -1
+}
+
+gdb_test_no_output "set detach-on-fork off"
+gdb_test_no_output "set target-async on"
+gdb_test_no_output "set non-stop on"
+
+if ![runto_main] {
+ return
+}
+
+set line [gdb_get_line_number "Break here"]
+gdb_breakpoint $srcfile:$line
+
+gdb_continue_to_breakpoint "breakpoint"
+
+gdb_test "inferior 2" "Switching to inferior 2.*"
+gdb_test "continue" "exited normally.*"
diff --git a/gdb/thread.c b/gdb/thread.c
index 9a29383..c7c9699 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1072,6 +1072,7 @@ struct current_thread_cleanup
int selected_frame_level;
int was_stopped;
int inf_id;
+ int was_removable;
};
static void
@@ -1095,6 +1096,8 @@ do_restore_current_thread_cleanup (void *arg)
set_current_inferior (find_inferior_id (old->inf_id));
}
+ current_inferior ()->removable = old->was_removable;
+
/* The running state of the originally selected thread may have
changed, so we have to recheck it here. */
if (!ptid_equal (inferior_ptid, null_ptid)
@@ -1112,10 +1115,14 @@ restore_current_thread_cleanup_dtor (void *arg)
{
struct current_thread_cleanup *old = arg;
struct thread_info *tp;
+ struct inferior *inf;
tp = find_thread_ptid (old->inferior_ptid);
if (tp)
tp->refcount--;
+ inf = find_inferior_id (old->inf_id);
+ if (inf != NULL)
+ inf->removable = old->was_removable;
xfree (old);
}
@@ -1129,6 +1136,7 @@ make_cleanup_restore_current_thread (void)
old = xmalloc (sizeof (struct current_thread_cleanup));
old->inferior_ptid = inferior_ptid;
old->inf_id = current_inferior ()->num;
+ old->was_removable = current_inferior ()->removable;
if (!ptid_equal (inferior_ptid, null_ptid))
{
@@ -1156,6 +1164,8 @@ make_cleanup_restore_current_thread (void)
tp->refcount++;
}
+ current_inferior ()->removable = 0;
+
return make_cleanup_dtor (do_restore_current_thread_cleanup, old,
restore_current_thread_cleanup_dtor);
}
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: RFC: fix crash when inferior exits during "continue"
2012-02-15 22:24 ` Tom Tromey
@ 2012-02-16 12:45 ` Pedro Alves
2012-02-16 14:42 ` Tom Tromey
2012-02-20 2:41 ` [patch] testsuite: Fix inferior-died.exp racy FAILs [Re: RFC: fix crash when inferior exits during "continue"] Jan Kratochvil
1 sibling, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2012-02-16 12:45 UTC (permalink / raw)
To: Tom Tromey; +Cc: Jan Kratochvil, gdb-patches
On 02/15/2012 08:13 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> Pedro> and the current thread disappears while the user is typing,
> Pedro> the command ends up being applied to a random thread, which is
> Pedro> not good.
>
> This makes sense to me if the user entered a background command.
> But why not switch if the last command was a foreground command?
Yes, agreed. The lame reason is that the original non-stop work didn't
care that much about the CLI (and there's no foreground in MI), and I
have an old TODO item for that, that I never got around to. :-P
> What do you think of the appended?
> diff --git a/gdb/testsuite/gdb.base/inferior-died.c b/gdb/testsuite/gdb.base/inferior-died.c
> new file mode 100644
> index 0000000..66227cf
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/inferior-died.c
> +#include <stdio.h>
Doesn't look necessary.
> static void
> @@ -1095,6 +1096,8 @@ do_restore_current_thread_cleanup (void *arg)
> set_current_inferior (find_inferior_id (old->inf_id));
> }
>
> + current_inferior ()->removable = old->was_removable;
This is unnecessary. restore_current_thread_cleanup_dtor
is called when either you run or discard the cleanup.
Otherwise looks good. Thanks.
--
Pedro Alves
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: RFC: fix crash when inferior exits during "continue"
2012-02-16 12:45 ` Pedro Alves
@ 2012-02-16 14:42 ` Tom Tromey
2012-02-16 15:24 ` Tom Tromey
0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2012-02-16 14:42 UTC (permalink / raw)
To: Pedro Alves; +Cc: Jan Kratochvil, gdb-patches
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Tom> This makes sense to me if the user entered a background command.
Tom> But why not switch if the last command was a foreground command?
Pedro> Yes, agreed. The lame reason is that the original non-stop work didn't
Pedro> care that much about the CLI (and there's no foreground in MI), and I
Pedro> have an old TODO item for that, that I never got around to. :-P
I'll file a bug.
>> +#include <stdio.h>
Pedro> Doesn't look necessary.
Oops, I missed this comment before check-in.
I'll fix it now.
>> static void
>> @@ -1095,6 +1096,8 @@ do_restore_current_thread_cleanup (void *arg)
>> set_current_inferior (find_inferior_id (old->inf_id));
>> }
>>
>> + current_inferior ()->removable = old->was_removable;
Pedro> This is unnecessary. restore_current_thread_cleanup_dtor
Pedro> is called when either you run or discard the cleanup.
I did manage to make this change before committing.
Tom
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: RFC: fix crash when inferior exits during "continue"
2012-02-16 14:42 ` Tom Tromey
@ 2012-02-16 15:24 ` Tom Tromey
0 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2012-02-16 15:24 UTC (permalink / raw)
To: Pedro Alves; +Cc: Jan Kratochvil, gdb-patches
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> Oops, I missed this comment before check-in.
Tom> I'll fix it now.
Patch appended. Tested on x86-64 Fedora 16.
Tom
2012-02-16 Tom Tromey <tromey@redhat.com>
* gdb.base/inferior-died.c: Don't include stdio.h.
Index: gdb.base/inferior-died.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/inferior-died.c,v
retrieving revision 1.1
diff -u -r1.1 inferior-died.c
--- gdb.base/inferior-died.c 16 Feb 2012 14:35:00 -0000 1.1
+++ gdb.base/inferior-died.c 16 Feb 2012 14:41:12 -0000
@@ -17,7 +17,6 @@
*/
#include <stdlib.h>
-#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [patch] testsuite: Fix inferior-died.exp racy FAILs [Re: RFC: fix crash when inferior exits during "continue"]
2012-02-15 22:24 ` Tom Tromey
2012-02-16 12:45 ` Pedro Alves
@ 2012-02-20 2:41 ` Jan Kratochvil
2012-02-20 21:05 ` [commit] " Jan Kratochvil
2012-02-20 21:24 ` Tom Tromey
1 sibling, 2 replies; 12+ messages in thread
From: Jan Kratochvil @ 2012-02-20 2:41 UTC (permalink / raw)
To: Tom Tromey; +Cc: Pedro Alves, gdb-patches
On Wed, 15 Feb 2012 21:13:25 +0100, Tom Tromey wrote:
> 2012-02-15 Tom Tromey <tromey@redhat.com>
>
> * gdb.base/inferior-died.c: New file.
> * gdb.base/inferior-died.exp: New file.
It has racy FAILs:
continue
Continuing.
-[Inferior 2 (process 17329) exited normally]
-(gdb) PASS: gdb.base/inferior-died.exp: continue
-testcase ./gdb.base/inferior-died.exp completed in 2 seconds
+[Inferior 2 (process 17248) exited normally]
+(gdb) [Inferior 1 (process 17243) exited with code 0140]
+FAIL: gdb.base/inferior-died.exp: continue (timeout)
+testcase ./gdb.base/inferior-died.exp completed in 11 seconds
I will check in this fix in some days.
Thanks,
Jan
gdb/testsuite/
2012-02-19 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix racy FAILs.
* gdb.base/inferior-died.c (main): Add return of 0.
* gdb.base/inferior-died.exp (continue): Fix expectation of
asynchronous events.
(p 1): New test.
--- a/gdb/testsuite/gdb.base/inferior-died.c
+++ b/gdb/testsuite/gdb.base/inferior-died.c
@@ -33,4 +33,5 @@ int main()
function ();
else
waitpid (child, NULL, 0);
+ return 0;
}
--- a/gdb/testsuite/gdb.base/inferior-died.exp
+++ b/gdb/testsuite/gdb.base/inferior-died.exp
@@ -53,4 +53,19 @@ gdb_breakpoint $srcfile:$line
gdb_continue_to_breakpoint "breakpoint"
gdb_test "inferior 2" "Switching to inferior 2.*"
-gdb_test "continue" "exited normally.*"
+
+# The inferior 1 exit may come unexpectedly in any moment.
+set test "continue"
+set seen 0
+gdb_test_multiple $test $test {
+ -re "($gdb_prompt |\\\[Inferior \[^\r\n\]* exited normally\\\])" {
+ incr seen
+ if {$seen < 3} {
+ exp_continue
+ }
+ pass $test
+ }
+}
+
+# Internal error may show up after all the messages above.
+gdb_test "p 1" " = 1"
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-02-20 21:05 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-07 19:14 RFC: fix crash when inferior exits during "continue" Tom Tromey
2012-02-10 14:41 ` Jan Kratochvil
2012-02-10 20:05 ` Tom Tromey
2012-02-14 13:44 ` Gary Benson
2012-02-14 14:19 ` Pedro Alves
2012-02-15 22:24 ` Tom Tromey
2012-02-16 12:45 ` Pedro Alves
2012-02-16 14:42 ` Tom Tromey
2012-02-16 15:24 ` Tom Tromey
2012-02-20 2:41 ` [patch] testsuite: Fix inferior-died.exp racy FAILs [Re: RFC: fix crash when inferior exits during "continue"] Jan Kratochvil
2012-02-20 21:05 ` [commit] " Jan Kratochvil
2012-02-20 21:24 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox