From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 22 18:20:13 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49599106567F; Tue, 22 Mar 2011 18:20:13 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 8CD5C8FC17; Tue, 22 Mar 2011 18:20:12 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p2MIK7cS095807 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Mar 2011 20:20:07 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p2MIK7Is019795; Tue, 22 Mar 2011 20:20:07 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p2MIK7nL019794; Tue, 22 Mar 2011 20:20:07 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 22 Mar 2011 20:20:07 +0200 From: Kostik Belousov To: Xingxing Pan Message-ID: <20110322182007.GV78089@deviant.kiev.zoral.com.ua> References: <20110319174115.GA33282@dchagin.static.corbina.ru> <20110320071847.GA10579@dchagin.static.corbina.ru> <20110320181911.GA79862@dchagin.static.corbina.ru> <20110321173204.GA7575@dchagin.static.corbina.ru> <20110321200025.GP78089@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="k5TNUgu2IV3nirhI" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org, Chagin Dmitry Subject: Re: GSoC'11: DWARF2 call frame information X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2011 18:20:13 -0000 --k5TNUgu2IV3nirhI Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 22, 2011 at 11:39:58PM +0800, Xingxing Pan wrote: > 2011/3/22 Kostik Belousov : > > On Mon, Mar 21, 2011 at 08:32:04PM +0300, Chagin Dmitry wrote: > >> On Mon, Mar 21, 2011 at 05:36:13PM +0800, Xingxing Pan wrote: > >> > 2011/3/21 Chagin Dmitry : > >> > >> powerfull script. > >> > >> > >> > >> Xingxing Pan > >> > > > >> > > hmm, which script? I think enough amd64, i386 and amd64/ia32. > >> > > > >> > > I suggest to write a example before continuing the conversation > >> > > about the GSoC. For example (bcopy || bzero) && cpu_switch. > >> > > Is it ok for you? > >> > > > >> > > -- > >> > > Have fun! > >> > > chd > >> > > > >> > > >> > Hi Chargin, > >> > > >> > Thank you for your reply. > >> > The followings shows how I try to add DWARF for bcopy. > >> > > >> > --- ../8.2.0/sys/i386/include/asm.h =9A =9A 2011-03-21 14:35:56.1119= 73722 +0800 > >> > +++ asm.h =9A =9A =9A 2011-03-21 15:25:31.564636162 +0800 > >> > @@ -71,7 +71,7 @@ > >> > > >> > =9A#define _ENTRY(x) =9A =9A =9A_START_ENTRY; \ > >> > =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A .globl CNAME(x); .ty= pe CNAME(x),@function; CNAME(x): > >> > -#define =9A =9A =9A =9AEND(x) =9A =9A =9A =9A =9A.size x, . - x > >> > +#define =9A =9A =9A =9AEND(x) =9A =9A =9A =9A =9A.cfi_endproc; .siz= e x, . - x > >> > > >> > =9A#ifdef PROF > >> > =9A#define =9A =9A =9A =9AALTENTRY(x) =9A =9A _ENTRY(x); \ > >> > @@ -80,9 +80,10 @@ > >> > =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A popl %ebp; \ > >> > =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A jmp 9f > >> > =9A#define =9A =9A =9A =9AENTRY(x) =9A =9A =9A =9A_ENTRY(x); \ > >> > - =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A pushl %ebp; movl %esp,= %ebp; \ > >> > + =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A .cfi_startproc; \ > >> > + =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A pushl %ebp; .cfi_adjus= t_cfa_offset 4; movl > >> > %esp,%ebp; .cfi_def_cfa_register %ebp; \ > >> > =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A call PIC_PLT(HIDENAM= E(mcount)); \ > >> > - =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A popl %ebp; \ > >> > + =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A popl %ebp; .cfi_def_cf= a %esp, 4; \ > >> > > >> > --- bcopy.S =9A =9A 2011-03-21 15:51:26.804203809 +0800 > >> > +++ ../8.2.0/lib/libc/i386/string/bcopy.S =9A =9A =9A 2011-03-21 > >> > 14:28:15.023069890 +0800 > >> > @@ -51,9 +51,7 @@ ENTRY(bcopy) > >> > =9A#endif > >> > =9A#endif > >> > =9A =9A =9A =9A pushl =9A %esi > >> > - =9A =9A =9A .cfi_adjust_cfa_offset 4; > >> > =9A =9A =9A =9A pushl =9A %edi > >> > - =9A =9A =9A .cfi_adjust_cfa_offset 4; > >> > =9A#if defined(MEMCOPY) || defined(MEMMOVE) > >> > =9A =9A =9A =9A movl =9A =9A12(%esp),%edi > >> > =9A =9A =9A =9A movl =9A =9A16(%esp),%esi > >> > @@ -77,9 +75,7 @@ ENTRY(bcopy) > >> > =9A =9A =9A =9A rep > >> > =9A =9A =9A =9A movsb > >> > =9A =9A =9A =9A popl =9A =9A%edi > >> > - =9A =9A =9A .cfi_adjust_cfa_offset -4; > >> > =9A =9A =9A =9A popl =9A =9A%esi > >> > - =9A =9A =9A .cfi_adjust_cfa_offset -4; > >> > =9A =9A =9A =9A ret > >> > =9A1: > >> > =9A =9A =9A =9A addl =9A =9A%ecx,%edi =9A =9A =9A /* copy backwards.= */ > >> > @@ -98,9 +94,7 @@ ENTRY(bcopy) > >> > =9A =9A =9A =9A rep > >> > =9A =9A =9A =9A movsl > >> > =9A =9A =9A =9A popl =9A =9A%edi > >> > - =9A =9A =9A .cfi_adjust_cfa_offset -4; > >> > =9A =9A =9A =9A popl =9A =9A%esi > >> > - =9A =9A =9A .cfi_adjust_cfa_offset -4; > >> > =9A =9A =9A =9A cld > >> > =9A =9A =9A =9A ret > >> > =9A#ifdef MEMCOPY > >> > > >> > But I don't know how to add DWARF for cpu_switch, because I have no > >> > idea about the circumstance when we need to backtrace through this > >> > function. Suppose there's a cpu switch like this, > >> > threadA->kernel->threadB. Then should the expected backtrace has the > >> > following result? > >> > > >> > threadB's stack > >> > kernel's stack > >> > threadA's stack > >> > >> > >> hmm, ok. good, avoid cpu_switch. > >> First of all, please, read style(9) man page. > >> In the second, evaluate the proposed plan (discussed with kib@): > >> > >> 1) Annotate libc, msun, rtld, libthr (you) > > 1a) Develop and implement a testing plan to verify the implementation. > > 1b) consider doing full register tracking for assembler code. > > > >> 2) vdso (I'm) > >> 3) Annotate signal trampolines (you, after vdso) > >> > >> And i'm going to understand what I need to do to start GSoC for you. > >> Thanks! > >> > >> > >> -- > >> Have fun! > >> chd > > > > > > >=20 > Hi Kostik, >=20 > I think the basic testing method can be using GDB to set breakpoint in > functions and observing the backtrace result. GDB uses Expect. I can > learn something from GDB's testsuite. Sounds good. >=20 > AFAIK, CFA and return address are enough for unwinding. Dose full > register tracking > means to emit DWARF for all the registers's saving and restoring in > the life time of the function? Not only save and restore, but also for move around. I am mostly about the syscall entry sequence on amd64, see the description of the `syscall' instruction and handling of %rcx in libc sources. Rarely used routines could be left aside. --k5TNUgu2IV3nirhI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEUEARECAAYFAk2I6FYACgkQC3+MBN1Mb4j60wCfdq9vKzB/bauW++Wd3pPckSh+ H9cAl1RGmx0k3/v3U3/DtlBBaOwkrW8= =YxhI -----END PGP SIGNATURE----- --k5TNUgu2IV3nirhI--