Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 08 Feb 2003 23:29:51 -0500
From:      northern snowfall <dbailey27@ameritech.net>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        Auge Mike <tobe_better@hotmail.com>, freebsd-questions@FreeBSD.ORG
Subject:   Re: printf ... !
Message-ID:  <3E45D93F.1010308@ameritech.net>
References:  <F41iJxkoU8oxlIUZNAj00005f89@hotmail.com> <20030208070437.GB2356@gothmog.gr>

next in thread | previous in thread | raw e-mail | index | archive | help
>
>
>This is the definition of the write(2) system call.  You should also
>check the implementation of printf(3) at the libc sources.  Look at
>/usr/src/lib/libc/stdio/printf.c for more details about the way
>printf() works in userlevel programs.
>
Right on. I think, however, that Auge is looking for a trace, not jsut 
the printf
source. More or less we bust out of printf() in libc to:
    vfprintf    /usr/src/lib/libc/stdio/vfprintf.c
    __sprint    /usr/src/lib/libc/stdio/vfprintf.c
    __sfvwrite    /usr/src/lib/libc/stdio/fvwrite.c
    _swrite    /usr/src/lib/libc/stdio/stdio.c
This is where you make a direct call to the file stream's write 
function. In printf's
case this is __swrite.
    __swrite    /usr/src/lib/libc/stdio/stdio.c
Simply, __swrite() calls _write (which equates to write()). Write is a 
simple syscall
trampoline that manifests int 0x80. This, of course, calls the kernel, 
which dumps
the thread into SYS_write. Skipping the interrupt code we can drop into 
SYS_write:
    write    /sys/kern/sys_generic.c
You should be able to trace the code from here.
Don

"nosotros tenemos mas influencia con sus hijos que tu tienes... pero los 
queremos.."

>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E45D93F.1010308>