aboutsummaryrefslogtreecommitdiff
path: root/gdb/procfs.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1992-04-01 03:09:02 +0000
committerFred Fish <fnf@specifix.com>1992-04-01 03:09:02 +0000
commit6b80138803cbc1a623bf0df050cf2bfd23df5baa (patch)
treed15b0eb1e707e896685eaf172809887024a5ec6c /gdb/procfs.c
parent3bec9cddbeab16be981194c0d59f58bcbc6337ec (diff)
downloadgdb-6b80138803cbc1a623bf0df050cf2bfd23df5baa.zip
gdb-6b80138803cbc1a623bf0df050cf2bfd23df5baa.tar.gz
gdb-6b80138803cbc1a623bf0df050cf2bfd23df5baa.tar.bz2
Changes in procfs.c to fix bug with inferior's siginfo struct getting
needlessly stomped. Changes in elfread.c and solib.c to fix DWARF processing, broken by other recent changes.
Diffstat (limited to 'gdb/procfs.c')
-rw-r--r--gdb/procfs.c92
1 files changed, 75 insertions, 17 deletions
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 04fed86..dc5ae10 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -81,6 +81,9 @@ static struct procinfo pi; /* Inferior's process information */
/* Prototypes for local functions */
+static void
+set_proc_siginfo PARAMS ((struct procinfo *, int));
+
static int
proc_address_to_fd PARAMS ((CORE_ADDR, int));
@@ -759,15 +762,7 @@ detach (signal)
{
if (signal)
{
- struct siginfo siginfo;
- siginfo.si_signo = signal;
- siginfo.si_code = 0;
- siginfo.si_errno = 0;
- if (ioctl (pi.fd, PIOCSSIG, &siginfo) < 0)
- {
- print_sys_errmsg (pi.pathname, errno);
- printf ("PIOCSSIG failed.\n");
- }
+ set_proc_siginfo (&pi, signal);
}
if (ioctl (pi.fd, PIOCSEXIT, &pi.exitset) < 0)
{
@@ -979,6 +974,76 @@ proc_wait (statloc)
/*
+LOCAL FUNCTION
+
+ set_proc_siginfo - set a process's current signal info
+
+SYNOPSIS
+
+ void set_proc_siginfo (struct procinfo *pip, int signo);
+
+DESCRIPTION
+
+ Given a pointer to a process info struct in PIP and a signal number
+ in SIGNO, set the process's current signal and its associated signal
+ information. The signal will be delivered to the process immediately
+ after execution is resumed, even if it is being held. In addition,
+ this particular delivery will not cause another PR_SIGNALLED stop
+ even if the signal is being traced.
+
+ If we are not delivering the same signal that the prstatus siginfo
+ struct contains information about, then synthesize a siginfo struct
+ to match the signal we are doing to deliver, make it of the type
+ "generated by a user process", and send this synthesized copy. When
+ used to set the inferior's signal state, this will be required if we
+ are not currently stopped because of a traced signal, or if we decide
+ to continue with a different signal.
+
+ Note that when continuing the inferior from a stop due to receipt
+ of a traced signal, we either have set PRCSIG to clear the existing
+ signal, or we have to call this function to do a PIOCSSIG with either
+ the existing siginfo struct from pr_info, or one we have synthesized
+ appropriately for the signal we want to deliver. Otherwise if the
+ signal is still being traced, the inferior will immediately stop
+ again.
+
+ See siginfo(5) for more details.
+*/
+
+static void
+set_proc_siginfo (pip, signo)
+ struct procinfo *pip;
+ int signo;
+{
+ struct siginfo newsiginfo;
+ struct siginfo *sip;
+
+ if (pip -> valid)
+ {
+ if (signo == pip -> prstatus.pr_info.si_signo)
+ {
+ sip = &pip -> prstatus.pr_info;
+ }
+ else
+ {
+ (void) memset ((char *) &newsiginfo, 0, sizeof (newsiginfo));
+ sip = &newsiginfo;
+ sip -> si_signo = signo;
+ sip -> si_code = 0;
+ sip -> si_errno = 0;
+ sip -> si_pid = getpid ();
+ sip -> si_uid = getuid ();
+ }
+ if (ioctl (pip -> fd, PIOCSSIG, sip) < 0)
+ {
+ print_sys_errmsg (pip -> pathname, errno);
+ warning ("PIOCSSIG failed");
+ }
+ }
+}
+
+/*
+
GLOBAL FUNCTION
child_resume -- resume execution of the inferior process
@@ -1012,14 +1077,7 @@ child_resume (step, signal)
pi.prrun.pr_vaddr = (caddr_t) *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];
if (signal)
{
- if (signal != pi.prstatus.pr_cursig)
- {
- struct siginfo siginfo;
- siginfo.si_signo = signal;
- siginfo.si_code = 0;
- siginfo.si_errno = 0;
- (void) ioctl (pi.fd, PIOCSSIG, &siginfo);
- }
+ set_proc_siginfo (&pi, signal);
}
else
{