This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Fix for gdb.server/non-existing-program.exp test case


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7313bced5b695b71a707c82b6817763046e21bb1

commit 7313bced5b695b71a707c82b6817763046e21bb1
Author: Carl E. Love <carll@oc4738070240.ibm.com>
Date:   Tue Sep 13 09:41:54 2016 -0700

    Fix for gdb.server/non-existing-program.exp test case
    
    The test checks to make sure GDB exits cleanly if there is
    no valid target binary.  Currently, ppc and S390 fail on this
    test.  The function target_post_create_inferior () calls
    linux_post_create_inferior () which calls the architecture
    specific functions s390_arch_setup () and ppc_arch_setup ()
    which make ptrace calls	to access the architecture specific
    registers.  These ptrace calls fail because the	process	does
    not exist causing GDB to exit on error.
    
    This patch checks to see if the initial ptrace (PTRACE_TRACEME, ...)
    call returned a status of TARGET_WAITKIND_EXITED indicating the
    target has already exited.  If the target has exited, then the
    target_post_create_inferior () is not called since there is no
    inferior to be setup.  The test	to see if the initial ptrace
    call succeeded is done after the ptrace (PTRACE_TRACEME, ...)
    call and the wait for the inferior process to stop, assuming
    it exists, has occurred.
    
    The patch has been tested on X86 64-bit, ppc64 and s390.  If
    fixes the test failures	on ppc64 and s390.  The	test does not
    fail on	X86 64-bit.  The patch does not	introduce any additional
    regression failures on any of these three platforms.
    
    gdbserver/ChangeLog
    
    2016-09-06  Carl Love  <cel@us.ibm.com>
    
    	* server.c (start_inferior):  Do not call
    	function target_post_create_inferior () if the
    	inferior process has already exited.

Diff:
---
 gdb/gdbserver/ChangeLog | 6 ++++++
 gdb/gdbserver/server.c  | 8 ++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 5e9e4cb..4b9bc7e 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,9 @@
+2016-09-06  Carl Love  <cel@us.ibm.com>
+
+	* server.c (start_inferior):  Do not call
+	function target_post_create_inferior () if the
+	inferior process has already exited.
+
 2016-09-05  Pedro Alves  <palves@redhat.com>
 
 	* Makefile.in (COMPILER, COMPILER_CFLAGS): Remove.
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 9c06443..96e3a18 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -285,11 +285,15 @@ start_inferior (char **argv)
      (assuming success).  */
   last_ptid = mywait (pid_to_ptid (signal_pid), &last_status, 0, 0);
 
-  target_post_create_inferior ();
-
+  /* The last_status.kind was set by the call to ptrace(PTRACE_TRACEME, ...).
+     At this point, the target process, if it exits, is stopped.  Do not call
+     the function target_post_create_inferior if the process has already
+     exited, as the target implementation of the routine may rely on the
+     process being live. */
   if (last_status.kind != TARGET_WAITKIND_EXITED
       && last_status.kind != TARGET_WAITKIND_SIGNALLED)
     {
+      target_post_create_inferior ();
       current_thread->last_resume_kind = resume_stop;
       current_thread->last_status = last_status;
     }


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