components/gdb/patches/gdb.fork-child.c.patch
changeset 243 34b34302cac9
child 1511 4d3b0b480760
equal deleted inserted replaced
242:8dc587754833 243:34b34302cac9
       
     1 --- gdb-6.8.orig/gdb/fork-child.c	Tue Jan 29 13:11:24 2008
       
     2 +++ gdb-6.8-64/gdb/fork-child.c	Fri Sep  3 15:08:51 2010
       
     3 @@ -40,6 +40,16 @@
       
     4  
       
     5  extern char **environ;
       
     6  
       
     7 +/* On Solaris, the SHELL may be a hard link to /usr/lib/isaexec.
       
     8 +   If so, there will be one more exec trap to skip while starting
       
     9 +   the inferior.  */
       
    10 +
       
    11 +#include <fcntl.h>
       
    12 +#include <sys/types.h>
       
    13 +#include <sys/stat.h>
       
    14 +
       
    15 +static int isaexec_shell;
       
    16 +
       
    17  /* Break up SCRATCH into an argument vector suitable for passing to
       
    18     execvp and store it in ARGV.  E.g., on "run a b c d" this routine
       
    19     would get as input the string "a b c d", and as output it would
       
    20 @@ -136,6 +146,8 @@
       
    21    static char **argv;
       
    22    const char *inferior_io_terminal = get_inferior_io_terminal ();
       
    23  
       
    24 +  isaexec_shell = 0;  /* Solaris only */
       
    25 +
       
    26    /* If no exec file handed to us, get it from the exec-file command
       
    27       -- with a good, common error message if none is specified.  */
       
    28    exec_file = exec_file_arg;
       
    29 @@ -148,6 +160,9 @@
       
    30    shell_file = shell_file_arg;
       
    31    if (STARTUP_WITH_SHELL)
       
    32      {
       
    33 +      /* Solaris only, is the shell a hard link to isaexec?  */
       
    34 +      struct stat buf1, buf2;
       
    35 +
       
    36        /* Figure out what shell to start up the user program under.  */
       
    37        if (shell_file == NULL)
       
    38  	shell_file = getenv ("SHELL");
       
    39 @@ -154,6 +169,25 @@
       
    40        if (shell_file == NULL)
       
    41  	shell_file = default_shell_file;
       
    42        shell = 1;
       
    43 +
       
    44 +      /* Solaris only, is the shell a hard link to isaexec?
       
    45 +	 If either stat call fails or the user's shell is
       
    46 +	 not linked to isaexec, proceed with gdb's normal
       
    47 +	 behavior, i.e. do not skip an extra exec.
       
    48 +
       
    49 +	 Assume that two files are the same if their inode
       
    50 +	 numbers, device numbers, and number of links match.
       
    51 +	 Is it possible to get a false positive if the shell
       
    52 +	 and isaexec are located on different file systems?  */
       
    53 +      if (
       
    54 +	stat ("/usr/lib/isaexec", &buf1) == 0 &&
       
    55 +	stat (shell_file, &buf2) == 0 &&
       
    56 +	buf1.st_ino == buf2.st_ino &&
       
    57 +	buf1.st_dev == buf2.st_dev &&
       
    58 +	buf1.st_nlink == buf2.st_nlink
       
    59 +      ) {
       
    60 +	isaexec_shell = 1;
       
    61 +      }
       
    62      }
       
    63  
       
    64    /* Multiplying the length of exec_file by 4 is to account for the
       
    65 @@ -395,6 +429,9 @@
       
    66    int pending_execs = ntraps;
       
    67    int terminal_initted = 0;
       
    68  
       
    69 +  /* Solaris only, increment ntraps if shell is isaexec'ed.  */
       
    70 +  pending_execs += isaexec_shell;
       
    71 +
       
    72    /* The process was started by the fork that created it, but it will
       
    73       have stopped one instruction after execing the shell.  Here we
       
    74       must get it up to actual execution of the real program.  */