Move the sigfilter hook to a more adequate location, and rename it to better
fit what it does.
The softsignal feature is used in Darwin to trace processes. When the
traced process gets a signal, this raises an exception. The debugger will
receive the exception message, use ptrace with PT_THUPDATE to pass the
signal to the child or discard it, and then it will send a reply to the
exception message, to resume the child.
With the hook at the beginnng of kpsignal2, we are in the context of the
signal sender, which can be the kill(1) command, for instance. We cannot
afford to sleep until the debugger tells us if the signal should be
delivered or not.
Therefore, the hook to generate the Mach exception must be in the traced
process context. That was we can sleep awaiting for the debugger opinion
about the signal, this is not a problem. The hook is hence located into
issignal, at the place where normally SIGCHILD is sent to the debugger,
whereas the traced process is stopped. If the hook returns 0, we bypass
thoses operations, the Mach exception mecanism will take care of notifying
the debugger (through a Mach exception), and stop the faulting thread.
2003-12-25 01:53:59 +03:00
|
|
|
/* $NetBSD: darwin_signal.h,v 1.12 2003/12/24 22:53:59 manu Exp $ */
|
2002-11-26 01:25:12 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Emmanuel Dreyfus
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-02-03 23:46:55 +03:00
|
|
|
#ifndef _DARWIN_SIGNAL_H_
|
|
|
|
#define _DARWIN_SIGNAL_H_
|
2002-11-26 01:25:12 +03:00
|
|
|
|
|
|
|
#define DARWIN_SA_USERTRAMP 0x0100
|
2002-11-29 16:17:22 +03:00
|
|
|
#define DARWIN_SA_ALLBITS 0x017f
|
2002-11-26 01:25:12 +03:00
|
|
|
|
2002-11-27 02:54:09 +03:00
|
|
|
union darwin_sigval {
|
|
|
|
int sigval_int;
|
|
|
|
void *sigval_ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct darwin___siginfo {
|
2002-11-27 19:44:01 +03:00
|
|
|
int darwin_si_signo;
|
|
|
|
int darwin_si_errno;
|
|
|
|
int darwin_si_code;
|
|
|
|
int darwin_si_pid;
|
|
|
|
unsigned int darwin_si_uid;
|
|
|
|
int darwin_si_status;
|
|
|
|
void *darwin_si_addr;
|
|
|
|
union darwin_sigval darwin_si_value;
|
|
|
|
long darwin_si_band;
|
2002-11-27 02:54:09 +03:00
|
|
|
int pad[7];
|
|
|
|
} darwin_siginfo_t;
|
|
|
|
|
|
|
|
struct darwin_ucontext {
|
|
|
|
int uc_onstack;
|
|
|
|
sigset13_t uc_sigmask;
|
|
|
|
stack_t uc_stack;
|
|
|
|
struct darwin_ucontext *uc_link;
|
|
|
|
size_t uc_mcsize;
|
|
|
|
struct darwin_mcontext *uc_mcontext;
|
|
|
|
};
|
2002-11-26 01:25:12 +03:00
|
|
|
|
2002-11-27 02:54:09 +03:00
|
|
|
struct darwin___sigaction {
|
2002-11-26 01:25:12 +03:00
|
|
|
union {
|
|
|
|
void (*__sa_handler)(int);
|
|
|
|
void (*__sa_sigaction)(int, struct darwin___siginfo *, void *);
|
2002-11-27 19:44:01 +03:00
|
|
|
} darwin_sa_handler;
|
|
|
|
void (*darwin_sa_tramp)(void *, int, int, darwin_siginfo_t *, void *);
|
|
|
|
sigset13_t darwin_sa_mask;
|
|
|
|
int darwin_sa_flags;
|
2002-11-26 01:25:12 +03:00
|
|
|
};
|
|
|
|
|
2003-09-26 02:00:02 +04:00
|
|
|
void darwin_sendsig(const ksiginfo_t *, const sigset_t *);
|
First work on Mach exceptions. Things that can turn into signals on UNIX
may turn into exceptions on Mach: a small message sent by the kernel to
the task that requested the exception.
On Darwin, when an exception is sent, no signal can be delivered.
TODO: more exceptions: arithmetic, bad instructions, emulation, s
software, and syscalls (plain and Mach). There is also RPC alert, but
I have no idea about what it is.
While we are there, remove some user ktrace in notification code, and add
a NODEF qualifier in mach_services.master: it will be used for notifications
and exceptions, where the kernel is always client and never server: we
don't want the message to be displayed as "unimplemented xxx" in kdump (thus
UNIMPL is not good), but we don't want to generate the server prototype
(therefore, STD is not good either). NODEF will declare it normally in the
name tables without creating the prototype.
2003-11-17 04:52:14 +03:00
|
|
|
void darwin_trapsignal(struct lwp *, const struct ksiginfo *);
|
Move the sigfilter hook to a more adequate location, and rename it to better
fit what it does.
The softsignal feature is used in Darwin to trace processes. When the
traced process gets a signal, this raises an exception. The debugger will
receive the exception message, use ptrace with PT_THUPDATE to pass the
signal to the child or discard it, and then it will send a reply to the
exception message, to resume the child.
With the hook at the beginnng of kpsignal2, we are in the context of the
signal sender, which can be the kill(1) command, for instance. We cannot
afford to sleep until the debugger tells us if the signal should be
delivered or not.
Therefore, the hook to generate the Mach exception must be in the traced
process context. That was we can sleep awaiting for the debugger opinion
about the signal, this is not a problem. The hook is hence located into
issignal, at the place where normally SIGCHILD is sent to the debugger,
whereas the traced process is stopped. If the hook returns 0, we bypass
thoses operations, the Mach exception mecanism will take care of notifying
the debugger (through a Mach exception), and stop the faulting thread.
2003-12-25 01:53:59 +03:00
|
|
|
int darwin_tracesig(struct lwp *, int);
|
2003-12-16 16:38:25 +03:00
|
|
|
void native_to_darwin_siginfo(const struct ksiginfo *, struct darwin___siginfo *);
|
2002-11-26 01:25:12 +03:00
|
|
|
|
2003-02-03 23:46:55 +03:00
|
|
|
#endif /* _DARWIN_SIGNAL_H_ */
|
2002-11-26 01:25:12 +03:00
|
|
|
|