Clear the single-step flag for signal handlers. This fixes bogus trace
traps on the first instruction of signal handlers. In trap.c:syscall(), fake a trace trap if the single-step flag was set on entry to the kernel, not if it will be set on exit from the kernel. This fixes bogus trace traps after the last instruction of signal handlers. gdb-4.18 (the version in FreeBSD) still has problems with the program in the PR. These seem to be due to bugs in gdb and not in FreeBSD, and are fixed in gdb-5.1 (the distribution version). PR: 33262 Tested by: k Macy <kip_macy@yahoo.com> MFC after: 1 day
This commit is contained in:
parent
52f1d68ff8
commit
846ac2266b
@ -401,7 +401,7 @@ osendsig(catcher, sig, mask, code)
|
||||
(vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
|
||||
|
||||
/* See sendsig() for comments. */
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_T | PSL_VIF | PSL_VIP);
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
|
||||
}
|
||||
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
@ -417,6 +417,7 @@ osendsig(catcher, sig, mask, code)
|
||||
|
||||
regs->tf_esp = (int)fp;
|
||||
regs->tf_eip = PS_STRINGS - szosigcode;
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
@ -546,17 +547,13 @@ sendsig(catcher, sig, mask, code)
|
||||
(vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
|
||||
|
||||
/*
|
||||
* We should never have PSL_T set when returning from vm86
|
||||
* mode. It may be set here if we deliver a signal before
|
||||
* getting to vm86 mode, so turn it off.
|
||||
*
|
||||
* Clear PSL_NT to inhibit T_TSSFLT faults on return from
|
||||
* syscalls made by the signal handler. This just avoids
|
||||
* wasting time for our lazy fixup of such faults. PSL_NT
|
||||
* does nothing in vm86 mode, but vm86 programs can set it
|
||||
* almost legitimately in probes for old cpu types.
|
||||
*/
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_T | PSL_VIF | PSL_VIP);
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
|
||||
}
|
||||
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
@ -572,6 +569,7 @@ sendsig(catcher, sig, mask, code)
|
||||
|
||||
regs->tf_esp = (int)sfp;
|
||||
regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
|
@ -933,6 +933,7 @@ syscall(frame)
|
||||
struct sysent *callp;
|
||||
struct thread *td = curthread;
|
||||
struct proc *p = td->td_proc;
|
||||
register_t orig_tf_eflags;
|
||||
u_int sticks;
|
||||
int error;
|
||||
int narg;
|
||||
@ -958,6 +959,7 @@ syscall(frame)
|
||||
PROC_UNLOCK(p);
|
||||
params = (caddr_t)frame.tf_esp + sizeof(int);
|
||||
code = frame.tf_eax;
|
||||
orig_tf_eflags = frame.tf_eflags;
|
||||
|
||||
if (p->p_sysent->sv_prepsyscall) {
|
||||
/*
|
||||
@ -1065,7 +1067,7 @@ syscall(frame)
|
||||
/*
|
||||
* Traced syscall.
|
||||
*/
|
||||
if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) {
|
||||
if ((orig_tf_eflags & PSL_T) && !(orig_tf_eflags & PSL_VM)) {
|
||||
frame.tf_eflags &= ~PSL_T;
|
||||
trapsignal(p, SIGTRAP, 0);
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ osendsig(catcher, sig, mask, code)
|
||||
(vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
|
||||
|
||||
/* See sendsig() for comments. */
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_T | PSL_VIF | PSL_VIP);
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
|
||||
}
|
||||
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
@ -417,6 +417,7 @@ osendsig(catcher, sig, mask, code)
|
||||
|
||||
regs->tf_esp = (int)fp;
|
||||
regs->tf_eip = PS_STRINGS - szosigcode;
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
@ -546,17 +547,13 @@ sendsig(catcher, sig, mask, code)
|
||||
(vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
|
||||
|
||||
/*
|
||||
* We should never have PSL_T set when returning from vm86
|
||||
* mode. It may be set here if we deliver a signal before
|
||||
* getting to vm86 mode, so turn it off.
|
||||
*
|
||||
* Clear PSL_NT to inhibit T_TSSFLT faults on return from
|
||||
* syscalls made by the signal handler. This just avoids
|
||||
* wasting time for our lazy fixup of such faults. PSL_NT
|
||||
* does nothing in vm86 mode, but vm86 programs can set it
|
||||
* almost legitimately in probes for old cpu types.
|
||||
*/
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_T | PSL_VIF | PSL_VIP);
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
|
||||
}
|
||||
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
@ -572,6 +569,7 @@ sendsig(catcher, sig, mask, code)
|
||||
|
||||
regs->tf_esp = (int)sfp;
|
||||
regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
|
@ -933,6 +933,7 @@ syscall(frame)
|
||||
struct sysent *callp;
|
||||
struct thread *td = curthread;
|
||||
struct proc *p = td->td_proc;
|
||||
register_t orig_tf_eflags;
|
||||
u_int sticks;
|
||||
int error;
|
||||
int narg;
|
||||
@ -958,6 +959,7 @@ syscall(frame)
|
||||
PROC_UNLOCK(p);
|
||||
params = (caddr_t)frame.tf_esp + sizeof(int);
|
||||
code = frame.tf_eax;
|
||||
orig_tf_eflags = frame.tf_eflags;
|
||||
|
||||
if (p->p_sysent->sv_prepsyscall) {
|
||||
/*
|
||||
@ -1065,7 +1067,7 @@ syscall(frame)
|
||||
/*
|
||||
* Traced syscall.
|
||||
*/
|
||||
if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) {
|
||||
if ((orig_tf_eflags & PSL_T) && !(orig_tf_eflags & PSL_VM)) {
|
||||
frame.tf_eflags &= ~PSL_T;
|
||||
trapsignal(p, SIGTRAP, 0);
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
regs->tf_esp = (int)fp;
|
||||
regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode) +
|
||||
linux_sznonrtsigcode;
|
||||
regs->tf_eflags &= ~PSL_VM;
|
||||
regs->tf_eflags &= ~(PSL_T | PSL_VM);
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
@ -519,7 +519,7 @@ linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
*/
|
||||
regs->tf_esp = (int)fp;
|
||||
regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
|
||||
regs->tf_eflags &= ~PSL_VM;
|
||||
regs->tf_eflags &= ~(PSL_T | PSL_VM);
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
|
@ -492,6 +492,7 @@ svr4_sendsig(catcher, sig, mask, code)
|
||||
#else
|
||||
tf->tf_esp = (int)fp;
|
||||
tf->tf_eip = (int)(((char *)PS_STRINGS) - *(p->p_sysent->sv_szsigcode));
|
||||
tf->tf_eflags &= ~PSL_T;
|
||||
tf->tf_cs = _ucodesel;
|
||||
tf->tf_ds = _udatasel;
|
||||
tf->tf_es = _udatasel;
|
||||
|
@ -414,7 +414,7 @@ osendsig(catcher, sig, mask, code)
|
||||
(vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
|
||||
|
||||
/* See sendsig() for comments. */
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_T | PSL_VIF | PSL_VIP);
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
|
||||
}
|
||||
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
@ -430,6 +430,7 @@ osendsig(catcher, sig, mask, code)
|
||||
|
||||
regs->tf_esp = (int)fp;
|
||||
regs->tf_eip = PS_STRINGS - szosigcode;
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
@ -558,17 +559,13 @@ sendsig(catcher, sig, mask, code)
|
||||
(vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
|
||||
|
||||
/*
|
||||
* We should never have PSL_T set when returning from vm86
|
||||
* mode. It may be set here if we deliver a signal before
|
||||
* getting to vm86 mode, so turn it off.
|
||||
*
|
||||
* Clear PSL_NT to inhibit T_TSSFLT faults on return from
|
||||
* syscalls made by the signal handler. This just avoids
|
||||
* wasting time for our lazy fixup of such faults. PSL_NT
|
||||
* does nothing in vm86 mode, but vm86 programs can set it
|
||||
* almost legitimately in probes for old cpu types.
|
||||
*/
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_T | PSL_VIF | PSL_VIP);
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
|
||||
}
|
||||
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
@ -584,6 +581,7 @@ sendsig(catcher, sig, mask, code)
|
||||
|
||||
regs->tf_esp = (int)sfp;
|
||||
regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
|
@ -414,7 +414,7 @@ osendsig(catcher, sig, mask, code)
|
||||
(vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
|
||||
|
||||
/* See sendsig() for comments. */
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_T | PSL_VIF | PSL_VIP);
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
|
||||
}
|
||||
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
@ -430,6 +430,7 @@ osendsig(catcher, sig, mask, code)
|
||||
|
||||
regs->tf_esp = (int)fp;
|
||||
regs->tf_eip = PS_STRINGS - szosigcode;
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
@ -558,17 +559,13 @@ sendsig(catcher, sig, mask, code)
|
||||
(vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
|
||||
|
||||
/*
|
||||
* We should never have PSL_T set when returning from vm86
|
||||
* mode. It may be set here if we deliver a signal before
|
||||
* getting to vm86 mode, so turn it off.
|
||||
*
|
||||
* Clear PSL_NT to inhibit T_TSSFLT faults on return from
|
||||
* syscalls made by the signal handler. This just avoids
|
||||
* wasting time for our lazy fixup of such faults. PSL_NT
|
||||
* does nothing in vm86 mode, but vm86 programs can set it
|
||||
* almost legitimately in probes for old cpu types.
|
||||
*/
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_T | PSL_VIF | PSL_VIP);
|
||||
tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
|
||||
}
|
||||
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
@ -584,6 +581,7 @@ sendsig(catcher, sig, mask, code)
|
||||
|
||||
regs->tf_esp = (int)sfp;
|
||||
regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
|
Loading…
Reference in New Issue
Block a user