diff options
author | Stu Grossman <grossman@cygnus> | 1992-09-25 22:23:54 +0000 |
---|---|---|
committer | Stu Grossman <grossman@cygnus> | 1992-09-25 22:23:54 +0000 |
commit | b869d3f47fa723f7371f8ec9b62a45ff84bf68d2 (patch) | |
tree | a2047cc724aedc6b52606f760dca5ed43697fc3c /gdb | |
parent | 13ff13438b17902dde9bbc6e73a0b234769a9bd7 (diff) | |
download | gdb-b869d3f47fa723f7371f8ec9b62a45ff84bf68d2.zip gdb-b869d3f47fa723f7371f8ec9b62a45ff84bf68d2.tar.gz gdb-b869d3f47fa723f7371f8ec9b62a45ff84bf68d2.tar.bz2 |
* remote.c (remote_wait): Make regs be char to avoid picayune
ANSI compiler warnings.
* energize.h: Move all external struct decls to inside of
__STDC__, add prototype for energize_shell_wait().
* energize.c (getpty): Clean up, make us really get a controlling
terminal.
* (energize_initialize): Disable SIGIO prior to setting up for
I/O interrupts. Move setsid(), et. al. to getpty().
* (energize_shell_wait): New routine to wait for things started
via the shell command, uses wait() instead of /dev/proc.
* Also, add prototype for execute_command_1().
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/energize.c | 102 | ||||
-rw-r--r-- | gdb/energize.h | 18 |
3 files changed, 86 insertions, 49 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5d38aa0..f6518b9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,18 @@ +Fri Sep 25 15:13:44 1992 Stu Grossman (grossman at cygnus.com) + + * remote.c (remote_wait): Make regs be char to avoid picayune + ANSI compiler warnings. + + * energize.h: Move all external struct decls to inside of + __STDC__, add prototype for energize_shell_wait(). + * energize.c (getpty): Clean up, make us really get a controlling + terminal. + * (energize_initialize): Disable SIGIO prior to setting up for + I/O interrupts. Move setsid(), et. al. to getpty(). + * (energize_shell_wait): New routine to wait for things started + via the shell command, uses wait() instead of /dev/proc. + * Also, add prototype for execute_command_1(). + Fri Sep 25 12:09:33 1992 K. Richard Pixley (rich@sendai.cygnus.com) * inftarg.c (child_create_inferior, child_attach, diff --git a/gdb/energize.c b/gdb/energize.c index 17c7cbc..9180eeb 100644 --- a/gdb/energize.c +++ b/gdb/energize.c @@ -44,6 +44,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/errno.h> #include <termios.h> #include <string.h> +#ifdef NCR486 +#include <sys/stropts.h> +#endif /* Non-zero means that we're doing the energize interface. */ int energize = 0; @@ -87,6 +90,8 @@ static int command_line_length = 0; #define KERNEL_EVENT 1 #define PTY_EVENT 2 +static void execute_command_1(); + /* This routine redirects the output of fputs_filtered to the kernel so that the user can see what's going on in his debugger window. */ @@ -884,69 +889,57 @@ getpty() struct stat statbuf; struct termios termios; - if (stat("/dev/ptmx",&statbuf)) error ("getpty: can't locate master\n"); + mfd = open("/dev/ptmx", O_RDWR); /* get the master */ + if (mfd < 0) + error ("getpty: can't locate master\n"); - /* Number of pseudo-terms is tuneable(16 - 255). System default is 16. */ - for (i = 0; i < MAX_PTM_TRY; i++) - { - mfd = open("/dev/ptmx", O_RDWR); /* get the master */ + if (grantpt(mfd) < 0) /* get a slave */ + error ("getpty: can't acquire slave"); - if (mfd < 0) - continue; + unlockpt(mfd); - if (grantpt(mfd) < 0) /* get a slave */ - for (j = 0; j < MAX_GRANTPT_TRY; j++) - if (grantpt(mfd) == 0 ) - { - close(mfd); - continue; - } + slavename = ptsname(mfd); /* get the slave device name */ + if (!slavename) + error ("getpty: can't get a pts\n"); - if (unlockpt(mfd) < 0) - { /* unlock the slave so he can be opened */ - close(mfd); - continue; - } + /* Drop controlling tty, become pgrp master */ - slavename = ptsname(mfd); /* get the slave device name */ - if (slavename) - break; /* Success! */ + if (setpgid(0, getppid()) == -1) + perror("setpgid() failed: "); - close(mfd); - continue; - } + if (setsid() == -1) + perror("setsid() failed: "); sfd = open(slavename, O_RDWR); - if (sfd < 0) { close(mfd); error ("getpty: can't open slave\n"); } - if (slavename==NULL && i >= MAX_PTM_TRY) - error ("getpty: can't get a pts\n"); + + if (ioctl(sfd, I_PUSH, "ptem")) perror ("getpty: ioctl I_PUSH fails"); + if (ioctl(sfd, I_PUSH, "ldterm")) perror ("getpty: ioctl I_PUSH fails"); /* setup mty for non-blocking I/O. */ - if ((n = fcntl(mfd, F_GETFL)) < 0) + n = fcntl(mfd, F_GETFL); + if (n < 0) perror ("getpty: fcntl F_GETFL failed"); - else if (fcntl(mfd, F_SETFL, n|O_NDELAY) <0) - perror("getpty:fcntl F_SETFL fails"); + + if (fcntl(mfd, F_SETFL, n|O_NDELAY) <0) + perror("getpty: fcntl F_SETFL failed"); /* set up for async i/o - V.4 will send SIGPOLL when data available */ if (ioctl (mfd, I_SETSIG, S_INPUT|S_RDNORM) < 0) perror ("getpty: ioctl I_SETSIG failed"); - /* fcntl(mfd, F_SETOWN,getpid()); SVR4 does not support this */ - - if (ioctl(sfd, I_PUSH, "ptem")) perror ("getpty: ioctl I_PUSH fails"); - if (ioctl(sfd, I_PUSH, "ldterm")) perror ("getpty: ioctl I_PUSH fails"); - - if (tcgetattr(sfd, &termios)) perror("getpty: tcgetattr fails"); + if (tcgetattr(sfd, &termios)) + perror("getpty: tcgetattr fails"); termios.c_oflag &= ~OPOST; /* no post-processing */ - if (tcsetattr(sfd, TCSANOW, &termios)) perror("getpty: tcsetattr fails"); + if (tcsetattr(sfd, TCSANOW, &termios)) + perror("getpty: tcsetattr fails"); inferior_pty=mfd; inferior_tty=sfd; @@ -1472,6 +1465,8 @@ energize_initialize(energize_id, execarg) /* Setup for I/O interrupts when appropriate. */ + signal(SIGIO, SIG_IGN); + #ifdef NCR486 if (ioctl (kerfd, I_SETSIG, S_INPUT|S_RDNORM) < 0) perror ("getpty: ioctl I_SETSIG failed"); @@ -1544,10 +1539,6 @@ energize_initialize(energize_id, execarg) /* Tell the rest of the world that Energize is now set up. */ energize = 1; - /* Drop controlling tty, become pgrp master */ - - setsid(); - getpty(); /* Setup the pty */ /* Attach all GDB I/O to the pty */ @@ -1624,6 +1615,7 @@ energize_wait(status) int *status; { int pid; + struct sigaction action; static sigset_t nullsigmask = {0}; if (!energize) @@ -1652,6 +1644,32 @@ energize_wait(status) return pid; } +int +energize_shell_wait(status) + int *status; +{ + int pid; + struct sigaction action; + static sigset_t nullsigmask = {0}; + + if (!energize) + return wait(status); + +#ifdef NCR486 + action.sa_handler = iosig; + action.sa_mask = nullsigmask; + action.sa_flags = SA_RESTART; + sigaction(SIGIO, &action, NULL); +#else + signal(SIGIO, iosig); +#endif + + pid = wait(status); + + signal(SIGIO, SIG_IGN); + return pid; +} + static void null_routine(arg) int arg; diff --git a/gdb/energize.h b/gdb/energize.h index 97ea388..8a39bf6 100644 --- a/gdb/energize.h +++ b/gdb/energize.h @@ -20,6 +20,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #if !defined (ENERGIZE_H) #define ENERGIZE_H 1 +#ifdef __STDC__ +struct cmd_list_element; +struct symbol; +struct type; +struct objfile; +struct breakpoint; +#endif /* __STDC__ */ + /* Non-zero means that we're doing the energize interface. */ extern int energize; @@ -32,14 +40,15 @@ extern void energize_new_process PARAMS ((void)); /* Low level wait routine for wait_for_inferior */ extern int energize_wait PARAMS ((int *)); +/* Wait routine for processes spawned by the shell command */ +extern int energize_shell_wait PARAMS ((int *statusp)); + /* Initialize */ extern void energize_initialize PARAMS ((char *, char *)); /* Main loop for energize protocol driver */ extern void energize_main_loop PARAMS ((void)); -struct cmd_list_element; - /* Command hook for energize */ extern void energize_call_command PARAMS ((struct cmd_list_element *, char *, int)); @@ -47,9 +56,6 @@ extern void energize_call_command PARAMS ((struct cmd_list_element *, /* Read commands for the command command, and others */ extern char *energize_command_line_input PARAMS ((char *, int)); -struct symbol; -struct type; - extern void energize_start_variable_annotation PARAMS ((char *, struct symbol *, struct type *, @@ -60,7 +66,6 @@ extern void energize_end_variable_annotation PARAMS ((void)); extern void energize_annotate_function PARAMS ((char *, int, int)); -struct objfile; extern void energize_symbol_file PARAMS ((struct objfile *)); /*extern void energize_query PARAMS ((char *, ...));*/ @@ -70,7 +75,6 @@ extern void energize_acknowledge_query PARAMS ((char *)); extern void energize_fputs PARAMS ((const char *)); -struct breakpoint; extern void energize_condition_breakpoint PARAMS ((struct breakpoint *)); extern void energize_commands_breakpoint PARAMS ((struct breakpoint *)); |