aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2002-08-29 18:50:25 +0000
committerDaniel Jacobowitz <drow@false.org>2002-08-29 18:50:25 +0000
commita9fa9f7daf3fdb5a1cc0149156ac8d497893cf0f (patch)
treea7aca92dbeec50d8e44abc5bc83432371681279b /gdb
parente551c2572e97cf7ab0a431f5a1f25207d9a4d179 (diff)
downloadgdb-a9fa9f7daf3fdb5a1cc0149156ac8d497893cf0f.zip
gdb-a9fa9f7daf3fdb5a1cc0149156ac8d497893cf0f.tar.gz
gdb-a9fa9f7daf3fdb5a1cc0149156ac8d497893cf0f.tar.bz2
* linux-low.c (linux_create_inferior): Call setpgid. Return
the new PID. (unstopped_p, linux_signal_pid): Remove. (linux_target_ops): Remove linux_signal_pid. * remote-utils.c (putpkt, input_interrupt): Use signal_pid global instead of target method. * target.h (struct target_ops): Remove signal_pid. Update comment for create_inferior. * server.c (signal_pid): New variable. (create_inferior): Set signal_pid. Block SIGTTOU and SIGTTIN in gdbserver. Set the child to be the foreground process group. (attach_inferior): Set signal_pid.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/gdbserver/ChangeLog15
-rw-r--r--gdb/gdbserver/linux-low.c33
-rw-r--r--gdb/gdbserver/remote-utils.c6
-rw-r--r--gdb/gdbserver/server.c29
-rw-r--r--gdb/gdbserver/target.h7
5 files changed, 49 insertions, 41 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index c5365cf..e7ab609 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,18 @@
+2002-08-29 Daniel Jacobowitz <drow@mvista.com>
+
+ * linux-low.c (linux_create_inferior): Call setpgid. Return
+ the new PID.
+ (unstopped_p, linux_signal_pid): Remove.
+ (linux_target_ops): Remove linux_signal_pid.
+ * remote-utils.c (putpkt, input_interrupt): Use signal_pid
+ global instead of target method.
+ * target.h (struct target_ops): Remove signal_pid. Update comment
+ for create_inferior.
+ * server.c (signal_pid): New variable.
+ (create_inferior): Set signal_pid. Block SIGTTOU and SIGTTIN in
+ gdbserver. Set the child to be the foreground process group.
+ (attach_inferior): Set signal_pid.
+
2002-08-23 Daniel Jacobowitz <drow@mvista.com>
* ChangeLog: New file, with entries from gdb/ChangeLog after GDB 5.2.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 7048daf..7644f9e 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -149,6 +149,8 @@ linux_create_inferior (char *program, char **allargs)
signal (SIGRTMIN + 1, SIG_DFL);
+ setpgid (0, 0);
+
execv (program, allargs);
fprintf (stderr, "Cannot exec %s: %s.\n", program,
@@ -160,7 +162,7 @@ linux_create_inferior (char *program, char **allargs)
new_process = add_process (pid);
add_thread (pid, new_process);
- return 0;
+ return pid;
}
/* Attach to an inferior process. */
@@ -1228,34 +1230,6 @@ linux_look_up_symbols (void)
#endif
}
-/* Return 1 if this process is not stopped. */
-static int
-unstopped_p (struct inferior_list_entry *entry, void *dummy)
-{
- struct process_info *process = (struct process_info *) entry;
-
- if (process->stopped)
- return 0;
-
- return 1;
-}
-
-static int
-linux_signal_pid ()
-{
- struct inferior_list_entry *process;
-
- process = find_inferior (&all_processes, unstopped_p, NULL);
-
- if (process == NULL)
- {
- warning ("no unstopped process");
- return inferior_pid;
- }
-
- return pid_of ((struct process_info *) process);
-}
-
static struct target_ops linux_target_ops = {
linux_create_inferior,
@@ -1269,7 +1243,6 @@ static struct target_ops linux_target_ops = {
linux_read_memory,
linux_write_memory,
linux_look_up_symbols,
- linux_signal_pid,
};
static void
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index c610c4c..d569937 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -46,6 +46,8 @@ static int remote_desc;
extern int using_threads;
extern int debug_threads;
+extern int signal_pid;
+
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
@@ -324,7 +326,7 @@ putpkt (char *buf)
/* Check for an input interrupt while we're here. */
if (buf3[0] == '\003')
- kill ((*the_target->signal_pid) (), SIGINT);
+ kill (signal_pid, SIGINT);
}
while (buf3[0] != '+');
@@ -361,7 +363,7 @@ input_interrupt (int unused)
return;
}
- kill ((*the_target->signal_pid) (), SIGINT);
+ kill (signal_pid, SIGINT);
}
}
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index b674ed0..d0963ba 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -21,6 +21,10 @@
#include "server.h"
+#include <unistd.h>
+#include <signal.h>
+#include <sys/wait.h>
+
int cont_thread;
int general_thread;
int step_thread;
@@ -31,14 +35,27 @@ int server_waiting;
jmp_buf toplevel;
+/* The PID of the originally created or attached inferior. Used to
+ send signals to the process when GDB sends us an asynchronous interrupt
+ (user hitting Control-C in the client), and to wait for the child to exit
+ when no longer debugging it. */
+
+int signal_pid;
+
static unsigned char
start_inferior (char *argv[], char *statusptr)
{
- /* FIXME Check error? Or turn to void. */
- create_inferior (argv[0], argv);
+ signal (SIGTTOU, SIG_DFL);
+ signal (SIGTTIN, SIG_DFL);
+
+ signal_pid = create_inferior (argv[0], argv);
fprintf (stderr, "Process %s created; pid = %d\n", argv[0],
- all_threads.head->id);
+ signal_pid);
+
+ signal (SIGTTOU, SIG_IGN);
+ signal (SIGTTIN, SIG_IGN);
+ tcsetpgrp (fileno (stderr), signal_pid);
/* Wait till we are at 1st instruction in program, return signal number. */
return mywait (statusptr, 0);
@@ -49,9 +66,15 @@ attach_inferior (int pid, char *statusptr, unsigned char *sigptr)
{
/* myattach should return -1 if attaching is unsupported,
0 if it succeeded, and call error() otherwise. */
+
if (myattach (pid) != 0)
return -1;
+ /* FIXME - It may be that we should get the SIGNAL_PID from the
+ attach function, so that it can be the main thread instead of
+ whichever we were told to attach to. */
+ signal_pid = pid;
+
*sigptr = mywait (statusptr, 0);
return 0;
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index c6aeee6..e554c0a 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -32,7 +32,7 @@ struct target_ops
ARGS is a standard NULL-terminated array of arguments,
to be passed to the inferior as ``argv''.
- Returns 0 on success, -1 on failure. Registers the new
+ Returns the new PID on success, -1 on failure. Registers the new
process with the process list. */
int (*create_inferior) (char *program, char **args);
@@ -104,11 +104,6 @@ struct target_ops
symbols. */
void (*look_up_symbols) (void);
-
- /* Return the PID we should send a signal to. Used for asynchronous
- interrupts (user hitting Control-C). */
-
- int (*signal_pid) (void);
};
extern struct target_ops *the_target;