* mmap.cc (mlock): Add standard syscall return value debugging output.
(munlock): Ditto. (posix_madvise): Ditto. * signal.cc: Remove obsolete sigcatchers stuff throughout. (sigaction_worker): Add function name parameter and use it to show standard syscall return value debugging output. Also add fault protection. (sigaction): Accommodate extra argument to sigaction_worker. (siginterrupt): Ditto. * syscalls.cc (read): Remove obsolete sigcatchers stuff. (readv): Ditto.
This commit is contained in:
parent
6455755743
commit
69864e48cb
@ -1,3 +1,18 @@
|
|||||||
|
2011-12-03 Christopher Faylor <me.cygwin2011@cgf.cx>
|
||||||
|
|
||||||
|
* mmap.cc (mlock): Add standard syscall return value debugging output.
|
||||||
|
(munlock): Ditto.
|
||||||
|
(posix_madvise): Ditto.
|
||||||
|
|
||||||
|
* signal.cc: Remove obsolete sigcatchers stuff throughout.
|
||||||
|
(sigaction_worker): Add function name parameter and use it to show
|
||||||
|
standard syscall return value debugging output. Also add fault
|
||||||
|
protection.
|
||||||
|
(sigaction): Accommodate extra argument to sigaction_worker.
|
||||||
|
(siginterrupt): Ditto.
|
||||||
|
* syscalls.cc (read): Remove obsolete sigcatchers stuff.
|
||||||
|
(readv): Ditto.
|
||||||
|
|
||||||
2011-12-03 Corinna Vinschen <vinschen@redhat.com>
|
2011-12-03 Corinna Vinschen <vinschen@redhat.com>
|
||||||
|
|
||||||
* mmap.cc (mlock): Drop requesting SE_LOCK_MEMORY_PRIVILEGE. Drop
|
* mmap.cc (mlock): Drop requesting SE_LOCK_MEMORY_PRIVILEGE. Drop
|
||||||
|
@ -1394,6 +1394,7 @@ mlock (const void *addr, size_t len)
|
|||||||
}
|
}
|
||||||
while (status == STATUS_WORKING_SET_QUOTA);
|
while (status == STATUS_WORKING_SET_QUOTA);
|
||||||
|
|
||||||
|
syscall_printf ("%R = mlock(%p, %u)", ret, addr, len);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1413,28 +1414,37 @@ munlock (const void *addr, size_t len)
|
|||||||
else
|
else
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
syscall_printf ("%R = munlock(%p, %u)", ret, addr, len);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
posix_madvise (void *addr, size_t len, int advice)
|
posix_madvise (void *addr, size_t len, int advice)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
/* Check parameters. */
|
/* Check parameters. */
|
||||||
if (advice < POSIX_MADV_NORMAL || advice > POSIX_MADV_DONTNEED
|
if (advice < POSIX_MADV_NORMAL || advice > POSIX_MADV_DONTNEED
|
||||||
|| !len)
|
|| !len)
|
||||||
return EINVAL;
|
ret = EINVAL;
|
||||||
|
else
|
||||||
/* Check requested memory area. */
|
|
||||||
MEMORY_BASIC_INFORMATION m;
|
|
||||||
char *p = (char *) addr;
|
|
||||||
char *endp = p + len;
|
|
||||||
while (p < endp)
|
|
||||||
{
|
{
|
||||||
if (!VirtualQuery (p, &m, sizeof m) || m.State == MEM_FREE)
|
/* Check requested memory area. */
|
||||||
return ENOMEM;
|
MEMORY_BASIC_INFORMATION m;
|
||||||
p = (char *) m.BaseAddress + m.RegionSize;
|
char *p = (char *) addr;
|
||||||
|
char *endp = p + len;
|
||||||
|
while (p < endp)
|
||||||
|
{
|
||||||
|
if (!VirtualQuery (p, &m, sizeof m) || m.State == MEM_FREE)
|
||||||
|
{
|
||||||
|
ret = ENOMEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p = (char *) m.BaseAddress + m.RegionSize;
|
||||||
|
}
|
||||||
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syscall_printf ("%d = posix_madvise(%p, %u, %d)", ret, addr, len, advice);
|
||||||
/* Eventually do nothing. */
|
/* Eventually do nothing. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -23,32 +23,13 @@ details. */
|
|||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
|
||||||
int sigcatchers; /* FIXME: Not thread safe. */
|
|
||||||
|
|
||||||
#define _SA_NORESTART 0x8000
|
#define _SA_NORESTART 0x8000
|
||||||
|
|
||||||
static int sigaction_worker (int, const struct sigaction *, struct sigaction *, bool)
|
static int sigaction_worker (int, const struct sigaction *, struct sigaction *, bool, const char *)
|
||||||
__attribute__ ((regparm (3)));
|
__attribute__ ((regparm (3)));
|
||||||
|
|
||||||
#define sigtrapped(func) ((func) != SIG_IGN && (func) != SIG_DFL)
|
#define sigtrapped(func) ((func) != SIG_IGN && (func) != SIG_DFL)
|
||||||
|
|
||||||
static inline void
|
|
||||||
set_sigcatchers (void (*oldsig) (int), void (*cursig) (int))
|
|
||||||
{
|
|
||||||
#ifdef DEBUGGING
|
|
||||||
int last_sigcatchers = sigcatchers;
|
|
||||||
#endif
|
|
||||||
if (!sigtrapped (oldsig) && sigtrapped (cursig))
|
|
||||||
sigcatchers++;
|
|
||||||
else if (sigtrapped (oldsig) && !sigtrapped (cursig))
|
|
||||||
sigcatchers--;
|
|
||||||
#ifdef DEBUGGING
|
|
||||||
if (last_sigcatchers != sigcatchers)
|
|
||||||
sigproc_printf ("last %d, old %d, cur %p, cur %p", last_sigcatchers,
|
|
||||||
sigcatchers, oldsig, cursig);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" _sig_func_ptr
|
extern "C" _sig_func_ptr
|
||||||
signal (int sig, _sig_func_ptr func)
|
signal (int sig, _sig_func_ptr func)
|
||||||
{
|
{
|
||||||
@ -74,8 +55,6 @@ signal (int sig, _sig_func_ptr func)
|
|||||||
gs.sa_handler = func;
|
gs.sa_handler = func;
|
||||||
gs.sa_flags &= ~SA_SIGINFO;
|
gs.sa_flags &= ~SA_SIGINFO;
|
||||||
|
|
||||||
set_sigcatchers (prev, func);
|
|
||||||
|
|
||||||
syscall_printf ("%p = signal (%d, %p)", prev, sig, func);
|
syscall_printf ("%p = signal (%d, %p)", prev, sig, func);
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
@ -407,63 +386,68 @@ abort (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sigaction_worker (int sig, const struct sigaction *newact, struct sigaction *oldact, bool isinternal)
|
sigaction_worker (int sig, const struct sigaction *newact,
|
||||||
|
struct sigaction *oldact, bool isinternal, const char *fnname)
|
||||||
{
|
{
|
||||||
sig_dispatch_pending ();
|
int res = -1;
|
||||||
/* check that sig is in right range */
|
myfault efault;
|
||||||
if (sig < 0 || sig >= NSIG)
|
if (!efault.faulted (EFAULT))
|
||||||
{
|
{
|
||||||
set_errno (EINVAL);
|
sig_dispatch_pending ();
|
||||||
sigproc_printf ("signal %d, newact %p, oldact %p", sig, newact, oldact);
|
/* check that sig is in right range */
|
||||||
syscall_printf ("SIG_ERR = sigaction signal %d out of range", sig);
|
if (sig < 0 || sig >= NSIG)
|
||||||
return -1;
|
set_errno (EINVAL);
|
||||||
}
|
else
|
||||||
|
|
||||||
struct sigaction oa = global_sigs[sig];
|
|
||||||
|
|
||||||
if (!newact)
|
|
||||||
sigproc_printf ("signal %d, newact %p, oa %p", sig, newact, oa, oa.sa_handler);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sigproc_printf ("signal %d, newact %p (handler %p), oa %p", sig, newact, newact->sa_handler, oa, oa.sa_handler);
|
|
||||||
if (sig == SIGKILL || sig == SIGSTOP)
|
|
||||||
{
|
{
|
||||||
set_errno (EINVAL);
|
struct sigaction oa = global_sigs[sig];
|
||||||
return -1;
|
|
||||||
}
|
if (!newact)
|
||||||
struct sigaction na = *newact;
|
sigproc_printf ("signal %d, newact %p, oa %p", sig, newact, oa, oa.sa_handler);
|
||||||
struct sigaction& gs = global_sigs[sig];
|
else
|
||||||
if (!isinternal)
|
{
|
||||||
na.sa_flags &= ~_SA_INTERNAL_MASK;
|
sigproc_printf ("signal %d, newact %p (handler %p), oa %p", sig, newact, newact->sa_handler, oa, oa.sa_handler);
|
||||||
gs = na;
|
if (sig == SIGKILL || sig == SIGSTOP)
|
||||||
if (!(gs.sa_flags & SA_NODEFER))
|
{
|
||||||
gs.sa_mask |= SIGTOMASK(sig);
|
set_errno (EINVAL);
|
||||||
if (gs.sa_handler == SIG_IGN)
|
goto out;
|
||||||
sig_clear (sig);
|
}
|
||||||
if (gs.sa_handler == SIG_DFL && sig == SIGCHLD)
|
struct sigaction na = *newact;
|
||||||
sig_clear (sig);
|
struct sigaction& gs = global_sigs[sig];
|
||||||
set_sigcatchers (oa.sa_handler, gs.sa_handler);
|
if (!isinternal)
|
||||||
if (sig == SIGCHLD)
|
na.sa_flags &= ~_SA_INTERNAL_MASK;
|
||||||
{
|
gs = na;
|
||||||
myself->process_state &= ~PID_NOCLDSTOP;
|
if (!(gs.sa_flags & SA_NODEFER))
|
||||||
if (gs.sa_flags & SA_NOCLDSTOP)
|
gs.sa_mask |= SIGTOMASK(sig);
|
||||||
myself->process_state |= PID_NOCLDSTOP;
|
if (gs.sa_handler == SIG_IGN)
|
||||||
|
sig_clear (sig);
|
||||||
|
if (gs.sa_handler == SIG_DFL && sig == SIGCHLD)
|
||||||
|
sig_clear (sig);
|
||||||
|
if (sig == SIGCHLD)
|
||||||
|
{
|
||||||
|
myself->process_state &= ~PID_NOCLDSTOP;
|
||||||
|
if (gs.sa_flags & SA_NOCLDSTOP)
|
||||||
|
myself->process_state |= PID_NOCLDSTOP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldact)
|
||||||
|
{
|
||||||
|
*oldact = oa;
|
||||||
|
oa.sa_flags &= ~_SA_INTERNAL_MASK;
|
||||||
|
}
|
||||||
|
res = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldact)
|
out:
|
||||||
{
|
syscall_printf ("%R = %s(%d, %p, %p)", res, fnname, sig, newact, oldact);
|
||||||
*oldact = oa;
|
return res;
|
||||||
oa.sa_flags &= ~_SA_INTERNAL_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
sigaction (int sig, const struct sigaction *newact, struct sigaction *oldact)
|
sigaction (int sig, const struct sigaction *newact, struct sigaction *oldact)
|
||||||
{
|
{
|
||||||
return sigaction_worker (sig, newact, oldact, false);
|
return sigaction_worker (sig, newact, oldact, false, "sigaction");
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
@ -560,7 +544,7 @@ siginterrupt (int sig, int flag)
|
|||||||
act.sa_flags &= ~_SA_NORESTART;
|
act.sa_flags &= ~_SA_NORESTART;
|
||||||
act.sa_flags |= SA_RESTART;
|
act.sa_flags |= SA_RESTART;
|
||||||
}
|
}
|
||||||
return sigaction_worker (sig, &act, NULL, true);
|
return sigaction_worker (sig, &act, NULL, true, "siginterrupt");
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
|
@ -1066,10 +1066,8 @@ read (int fd, void *ptr, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Could block, so let user know we at least got here. */
|
/* Could block, so let user know we at least got here. */
|
||||||
extern int sigcatchers;
|
syscall_printf ("read (%d, %p, %d) %sblocking",
|
||||||
syscall_printf ("read (%d, %p, %d) %sblocking, sigcatchers %d",
|
fd, ptr, len, cfd->is_nonblocking () ? "non" : "");
|
||||||
fd, ptr, len, cfd->is_nonblocking () ? "non" : "",
|
|
||||||
sigcatchers);
|
|
||||||
|
|
||||||
cfd->read (ptr, res = len);
|
cfd->read (ptr, res = len);
|
||||||
|
|
||||||
@ -1110,10 +1108,8 @@ readv (int fd, const struct iovec *const iov, const int iovcnt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Could block, so let user know we at least got here. */
|
/* Could block, so let user know we at least got here. */
|
||||||
extern int sigcatchers;
|
syscall_printf ("readv (%d, %p, %d) %sblocking",
|
||||||
syscall_printf ("readv (%d, %p, %d) %sblocking, sigcatchers %d",
|
fd, iov, iovcnt, cfd->is_nonblocking () ? "non" : "");
|
||||||
fd, iov, iovcnt, cfd->is_nonblocking () ? "non" : "",
|
|
||||||
sigcatchers);
|
|
||||||
|
|
||||||
res = cfd->readv (iov, iovcnt, tot);
|
res = cfd->readv (iov, iovcnt, tot);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user