[RFC] Saving the latest errno from syscalls.

Jung-uk Kim jkim at FreeBSD.org
Fri Mar 12 18:32:28 UTC 2010


On Friday 12 March 2010 04:29 am, Kostik Belousov wrote:
> On Thu, Mar 11, 2010 at 06:15:07PM -0500, Jung-uk Kim wrote:
> > On Thursday 11 March 2010 04:55 pm, Marcel Moolenaar wrote:
> > > On Mar 11, 2010, at 1:24 PM, Jung-uk Kim wrote:
> > > > While I was debugging syscalls, I found a very useful field
> > > > in struct thread, td_errno.  It seems it was added for dtrace
> > > > but it is only populated on amd64 and i386.  Is the attached
> > > > patch acceptable for maintainers of other platforms?
> > >
> > > Isn't it better to do it in cpu_set_syscall_retval()?
> > > That way you catch all cases, plus you can save the
> > > translated error as well...
> >
> > I just took amd64/i386 as an example and I was not sure whether
> > it was meant to store translated error or not.  Does anyone with
> > DTrace internal knowledge answer the question?
>
> I do not know that much about DTrace, but it seems that setting
> td_errno in cpu_set_syscall_retval() is too late. Dtrace has a
> probe after the syscall return, and it is called right before
> cpu_set_syscall_retval() can be reasonably called. The probe only
> issued for syscall that goes into sysent.

Ah, I can see that now.  So, if/when we implement DTrace SYSCALL 
provider for other arches, this is the right place. :-)

Thanks!

Jung-uk Kim


More information about the freebsd-hackers mailing list