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]

[PATCH] foll-vfork.exp: Avoid test crash when run with the wrong cwd.


Running the test's executable with a CWD other than testsuite/ makes
the test do bad things after vfork, like doing a normal return exit:

$ ./testsuite/gdb.base/foll-vfork
I'm the child!
I'm the proud parent of child #13317!
I'm the child!
^CSegmentation fault

The child ends up exiting because the test passes a relative path to
exec, which fails.  I have more than once lost a few minutes due to
this, by doing something like:

 $./gdb ./testsuite/gdb.base/foll-vfork

and wondering if my patch to gdb was the cause of the inferior
crashing.

With the patch below, such invocation now ends up in:

$ ./testsuite/gdb.base/foll-vfork
I'm the child!
exec failed: No such file or directory
I'm the proud parent of child #12171!

Tested on AMD64 Fedora 17, and applied.

2012-11-05  Pedro Alves  <palves@redhat.com>

	* gdb.base/foll-vfork.c (main): Call perror and _exit if execlp()
	fails.
---
 gdb/testsuite/gdb.base/foll-vfork.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdb/testsuite/gdb.base/foll-vfork.c b/gdb/testsuite/gdb.base/foll-vfork.c
index 3bb37ad..85c5493 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.c
+++ b/gdb/testsuite/gdb.base/foll-vfork.c
@@ -30,6 +30,8 @@ main ()
   if (pid == 0) {
     printf ("I'm the child!\n");
     execlp ("gdb.base/vforked-prog", "gdb.base/vforked-prog", (char *)0);
+    perror ("exec failed");
+    _exit (1);
   }
   else {
     printf ("I'm the proud parent of child #%d!\n", pid);


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