• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisão14897d65b5a279684289bf6b99136de60c31f1c0 (tree)
Hora2018-06-15 01:47:03
AutorPedro Alves <palves@redh...>
CommiterPedro Alves

Mensagem de Log

Avoid gdb.base/fork-running-state.exp lingering processes

Currently, the gdb.base/fork-running-state.exp testcase leaves a few
processes lingering until a 3 minutes alarm kills them:

pedro 28308 1 0 13:55 ? 00:00:00 /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.base/fork-running-state/fork-running-state
pedro 28340 1 0 13:55 ? 00:00:00 /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.base/fork-running-state/fork-running-state
pedro 28372 1 0 13:55 ? 00:00:00 /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.base/fork-running-state/fork-running-state
pedro 28400 1 0 13:55 ? 00:00:00 /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.base/fork-running-state/fork-running-state
pedro 28431 1 0 13:55 ? 00:00:00 /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.base/fork-running-state/fork-running-state
pedro 28463 1 0 13:55 ? 00:00:00 /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.base/fork-running-state/fork-running-state

Those processes used to kill themselves, but that was changed by
commit f50d8a2eaea0 ("Fix gdb.base/fork-running-state.exp race").

This commit restores the self-killing, but only in the cases gdb won't
try killing the processes, thus avoiding the old race.

(The restored code in fork_parent isn't exactly the same as it was.
In this version, we're exiting immediately when 'wait' returns
success, while in the old version we'd loop again and end up in the
perror call. The output from that perror call is not expected by the
"kill inferior" tests, and would result in a test FAIL.)

gdb/testsuite/ChangeLog:
2018-06-14 Pedro Alves <palves@redhat.com>

* gdb.base/fork-running-state.c: Include <errno.h>.
(exit_if_relative_exits): New.
(fork_child): If 'exit_if_relative_exits' is true, exit if the parent
exits.
(fork_parent): If 'exit_if_relative_exits' is true, exit if the
child exits.

Mudança Sumário

Diff

--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
1+2018-06-14 Pedro Alves <palves@redhat.com>
2+
3+ * gdb.base/fork-running-state.c: Include <errno.h>.
4+ (exit_if_relative_exits): New.
5+ (fork_child): If 'exit_if_relative_exits' is true, exit if the parent
6+ exits.
7+ (fork_parent): If 'exit_if_relative_exits' is true, exit if the
8+ child exits.
9+
110 2018-06-14 Tom de Vries <tdevries@suse.de>
211
312 PR cli/22573
--- a/gdb/testsuite/gdb.base/fork-running-state.c
+++ b/gdb/testsuite/gdb.base/fork-running-state.c
@@ -19,9 +19,15 @@
1919 #include <stdio.h>
2020 #include <sys/types.h>
2121 #include <sys/wait.h>
22+#include <errno.h>
2223
2324 int save_parent;
2425
26+/* Variable set by GDB. If true, then a fork child (or parent) exits
27+ if its parent (or child) exits. Otherwise the process waits
28+ forever until either GDB or the alarm kills it. */
29+volatile int exit_if_relative_exits = 0;
30+
2531 /* The fork child. Just runs forever. */
2632
2733 static int
@@ -31,7 +37,20 @@ fork_child (void)
3137 alarm (180);
3238
3339 while (1)
34- pause ();
40+ {
41+ if (exit_if_relative_exits)
42+ {
43+ sleep (1);
44+
45+ /* Exit if GDB kills the parent. */
46+ if (getppid () != save_parent)
47+ break;
48+ if (kill (getppid (), 0) != 0)
49+ break;
50+ }
51+ else
52+ pause ();
53+ }
3554
3655 return 0;
3756 }
@@ -45,7 +64,23 @@ fork_parent (void)
4564 alarm (180);
4665
4766 while (1)
48- pause ();
67+ {
68+ if (exit_if_relative_exits)
69+ {
70+ int res = wait (NULL);
71+ if (res == -1 && errno == EINTR)
72+ continue;
73+ else if (res == -1)
74+ {
75+ perror ("wait");
76+ return 1;
77+ }
78+ else
79+ return 0;
80+ }
81+ else
82+ pause ();
83+ }
4984
5085 return 0;
5186 }
--- a/gdb/testsuite/gdb.base/fork-running-state.exp
+++ b/gdb/testsuite/gdb.base/fork-running-state.exp
@@ -70,6 +70,13 @@ proc do_test { detach_on_fork follow_fork non_stop schedule_multiple } {
7070 gdb_test_no_output "set schedule-multiple $schedule_multiple"
7171 }
7272
73+ # If we're detaching from the parent (or child), then tell it to
74+ # exit itself when its child (or parent) exits. If we stay
75+ # attached, we take care of killing it.
76+ if {$detach_on_fork == "on"} {
77+ gdb_test "print exit_if_relative_exits = 1" " = 1"
78+ }
79+
7380 set test "continue &"
7481 gdb_test_multiple $test $test {
7582 -re "$gdb_prompt " {