components/gdb/patches/gdb.fork-child.c.patch
author Stefan Teleman <stefan.teleman@oracle.com>
Wed, 16 Oct 2013 06:53:51 -0700
changeset 1511 4d3b0b480760
parent 243 34b34302cac9
permissions -rw-r--r--
17086418 upgrade gdb to 7.6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1511
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
     1
--- gdb-7.6/gdb/fork-child.c	2012-12-31 22:32:42.000000000 -0800
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
     2
+++ gdb-7.6/gdb/fork-child.c	2013-07-10 23:30:02.327235300 -0700
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
     3
@@ -35,13 +35,19 @@
243
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
     4
 
1511
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
     5
 #include <signal.h>
243
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
     6
 
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
     7
+#include <fcntl.h>
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
     8
+#include <sys/types.h>
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
     9
+#include <sys/stat.h>
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    10
+
1511
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    11
 /* This just gets used as a default if we can't find SHELL.  */
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    12
-#define SHELL_FILE "/bin/sh"
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    13
+#define SHELL_FILE "/bin/bash"
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    14
 
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    15
 extern char **environ;
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    16
 
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    17
 static char *exec_wrapper;
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    18
 
243
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    19
+static int isaexec_shell;
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    20
+
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    21
 /* Break up SCRATCH into an argument vector suitable for passing to
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    22
    execvp and store it in ARGV.  E.g., on "run a b c d" this routine
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    23
    would get as input the string "a b c d", and as output it would
1511
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    24
@@ -142,6 +148,7 @@
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    25
   struct inferior *inf;
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    26
   int i;
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    27
   int save_errno;
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    28
+  isaexec_shell = 0;
243
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    29
 
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    30
   /* If no exec file handed to us, get it from the exec-file command
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    31
      -- with a good, common error message if none is specified.  */
1511
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    32
@@ -155,12 +162,20 @@
243
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    33
   shell_file = shell_file_arg;
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    34
   if (STARTUP_WITH_SHELL)
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    35
     {
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    36
+      struct stat buf1, buf2;
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    37
       /* Figure out what shell to start up the user program under.  */
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    38
       if (shell_file == NULL)
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    39
 	shell_file = getenv ("SHELL");
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    40
       if (shell_file == NULL)
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    41
 	shell_file = default_shell_file;
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    42
       shell = 1;
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    43
+
1511
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    44
+      if (stat ("/usr/lib/isaexec", &buf1) == 0 &&
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    45
+          stat (shell_file, &buf2) == 0 &&
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    46
+          buf1.st_ino == buf2.st_ino &&
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    47
+          buf1.st_dev == buf2.st_dev &&
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    48
+          buf1.st_nlink == buf2.st_nlink)
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    49
+        isaexec_shell = 1;
243
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    50
     }
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    51
 
1511
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    52
   if (!shell)
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    53
@@ -416,6 +431,8 @@
243
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    54
   int terminal_initted = 0;
1511
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    55
   ptid_t resume_ptid;
243
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    56
 
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    57
+  pending_execs += isaexec_shell;
34b34302cac9 7039303 Move gdb 6.8 from SFW to Userland.
George Vasick <george.vasick@oracle.com>
parents:
diff changeset
    58
+
1511
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    59
   if (target_supports_multi_process ())
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    60
     resume_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
4d3b0b480760 17086418 upgrade gdb to 7.6
Stefan Teleman <stefan.teleman@oracle.com>
parents: 243
diff changeset
    61
   else