> > --- David Xu <davidxu_at_freebsd.org> wrote: > > > I found following code in sys/i386/i386/machdep.c: > > function exec_setregs: > > > > bzero((char *)regs, sizeof(struct trapframe)); > > regs->tf_eip = entry; > > regs->tf_esp = stack; > > regs->tf_eflags = PSL_USER | (regs->tf_eflags & PSL_T); > > > > the regs is cleared to zero, why do we bother to test it > > again ? regs->tf_eflags & PSL_T is useless code. > > > > AMD64 also has this, I also found it in releng_4, why ? > > FYI, it's first incarnation was in v1.87 [1] (1994-11-06): > > ! 864: ? ? ? ?bzero(regs, sizeof(struct > trapframe)); > ! 865: ? ? ? ?regs[tEIP] = entry; > ! 866: ? ? ? ?regs[tESP] = stack; > ! 867: ? ? ? ?regs[tEFLAGS] = PSL_USERSET | > (regs[tEFLAGS] & PSL_T); > ! 868: ? ? ? ?regs[tSS] = _udatasel; > ! 869: ? ? ? ?regs[tDS] = _udatasel; > ! 870: ? ? ? ?regs[tES] = _udatasel; > ! 871: ? ? ? ?regs[tCS] = _ucodesel; > > Same issue, it seems. Hmmm. That would make it my bug. :-/ My only excuse is that things were pretty crazy back then - this would have happened when John Dyson and I were working on the x86 port of 4.4-lite which became FreeBSD 2.0. We did the port in 10 days. :-) My best explaination is that the bzero got added after the tEFLAGS stuff - probably to solve some other issue, and the test of PSL_T (actually should be called TF bit to match Intel literature, which stands for "trap flag") a few lines lower was overlooked. The bit enables debug traps after every instruction in order to facilitate instruction single stepping. It's not clear to me if instruction single stepping should be preserved after an exec. I'd defer to Bruce Evans on this since he's the expert on debuggers. -DG David G. Lawrence President Download Technologies, Inc. - http://www.downloadtech.com - (866) 399 8500 TeraSolutions, Inc. - http://www.terasolutions.com - (888) 346 7175 The FreeBSD Project - http://www.freebsd.org Pave the road of life with opportunities.Received on Mon Sep 27 2004 - 04:04:38 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:14 UTC