From owner-freebsd-questions Sat Feb 8 20:30:38 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 85AFE37B405 for ; Sat, 8 Feb 2003 20:30:33 -0800 (PST) Received: from mailhost.det2.ameritech.net (mailhost1-sfldmi.sfldmi.ameritech.net [206.141.193.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id CAD7D43F75 for ; Sat, 8 Feb 2003 20:30:32 -0800 (PST) (envelope-from dbailey27@ameritech.net) Received: from ameritech.net ([67.38.16.140]) by mailhost.det2.ameritech.net (InterMail vM.4.01.02.17 201-229-119) with ESMTP id <20030209043011.FHPR26543.mailhost.det2.ameritech.net@ameritech.net>; Sat, 8 Feb 2003 23:30:11 -0500 Message-ID: <3E45D93F.1010308@ameritech.net> Date: Sat, 08 Feb 2003 23:29:51 -0500 From: northern snowfall User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:0.9.4.1) Gecko/20020518 Netscape6/6.2.3 X-Accept-Language: en-us MIME-Version: 1.0 To: Giorgos Keramidas Cc: Auge Mike , freebsd-questions@FreeBSD.ORG Subject: Re: printf ... ! References: <20030208070437.GB2356@gothmog.gr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > >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