From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 22 15:39:59 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 E9D9D106566B; Tue, 22 Mar 2011 15:39:59 +0000 (UTC) (envelope-from forandom@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 863388FC12; Tue, 22 Mar 2011 15:39:59 +0000 (UTC) Received: by qwc9 with SMTP id 9so5753627qwc.13 for ; Tue, 22 Mar 2011 08:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=xXAnJvdc05KciaxVmcjrGY47JHxI+xLz0G1fnvWWov4=; b=S4YEF6VHUzvKlUaHVlugDZQ3P/7rZCXjO076mv43rd7808bZ+Znxz4xCXZ7EKJnqA6 f2CdXp7bQpfnl8zQh0tIOrzHVgnG6q6tnd5/ia81PT2oJFZquWmc6i8bsw9AbS2sjH/C gTseJTtooFllD7rDBMnRkMhgHnIHudolanfp8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=emXk0l2Op6n1OHS37TvA15poRx0hheUR8NJ9W6TbpoWzLCpWwlXlBkTXcq0EWdVBZ9 3YpXtC0HRgaQfYroySmhBrm8FkAR+STM8Cri9bTEbCJ+xAhZnfC/fnzXrSw6NY9DFLIa iRBIdlbAl7UCWWF/B9Fz71yhI7v8hTttvni9c= MIME-Version: 1.0 Received: by 10.229.142.139 with SMTP id q11mr4832284qcu.163.1300808398351; Tue, 22 Mar 2011 08:39:58 -0700 (PDT) Sender: forandom@gmail.com Received: by 10.229.222.148 with HTTP; Tue, 22 Mar 2011 08:39:58 -0700 (PDT) In-Reply-To: <20110321200025.GP78089@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> Date: Tue, 22 Mar 2011 23:39:58 +0800 X-Google-Sender-Auth: 7keWT0jHR_P82EzzO38RrlejHIw Message-ID: From: Xingxing Pan To: Kostik Belousov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 15:40:00 -0000 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 =A0 =A0 2011-03-21 14:35:56.111973= 722 +0800 >> > +++ asm.h =A0 =A0 =A0 2011-03-21 15:25:31.564636162 +0800 >> > @@ -71,7 +71,7 @@ >> > >> > =A0#define _ENTRY(x) =A0 =A0 =A0_START_ENTRY; \ >> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .globl CNAME(x); .type= CNAME(x),@function; CNAME(x): >> > -#define =A0 =A0 =A0 =A0END(x) =A0 =A0 =A0 =A0 =A0.size x, . - x >> > +#define =A0 =A0 =A0 =A0END(x) =A0 =A0 =A0 =A0 =A0.cfi_endproc; .size = x, . - x >> > >> > =A0#ifdef PROF >> > =A0#define =A0 =A0 =A0 =A0ALTENTRY(x) =A0 =A0 _ENTRY(x); \ >> > @@ -80,9 +80,10 @@ >> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 popl %ebp; \ >> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 jmp 9f >> > =A0#define =A0 =A0 =A0 =A0ENTRY(x) =A0 =A0 =A0 =A0_ENTRY(x); \ >> > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pushl %ebp; movl %esp,%e= bp; \ >> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .cfi_startproc; \ >> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pushl %ebp; .cfi_adjust_= cfa_offset 4; movl >> > %esp,%ebp; .cfi_def_cfa_register %ebp; \ >> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 call PIC_PLT(HIDENAME(= mcount)); \ >> > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 popl %ebp; \ >> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 popl %ebp; .cfi_def_cfa = %esp, 4; \ >> > >> > --- bcopy.S =A0 =A0 2011-03-21 15:51:26.804203809 +0800 >> > +++ ../8.2.0/lib/libc/i386/string/bcopy.S =A0 =A0 =A0 2011-03-21 >> > 14:28:15.023069890 +0800 >> > @@ -51,9 +51,7 @@ ENTRY(bcopy) >> > =A0#endif >> > =A0#endif >> > =A0 =A0 =A0 =A0 pushl =A0 %esi >> > - =A0 =A0 =A0 .cfi_adjust_cfa_offset 4; >> > =A0 =A0 =A0 =A0 pushl =A0 %edi >> > - =A0 =A0 =A0 .cfi_adjust_cfa_offset 4; >> > =A0#if defined(MEMCOPY) || defined(MEMMOVE) >> > =A0 =A0 =A0 =A0 movl =A0 =A012(%esp),%edi >> > =A0 =A0 =A0 =A0 movl =A0 =A016(%esp),%esi >> > @@ -77,9 +75,7 @@ ENTRY(bcopy) >> > =A0 =A0 =A0 =A0 rep >> > =A0 =A0 =A0 =A0 movsb >> > =A0 =A0 =A0 =A0 popl =A0 =A0%edi >> > - =A0 =A0 =A0 .cfi_adjust_cfa_offset -4; >> > =A0 =A0 =A0 =A0 popl =A0 =A0%esi >> > - =A0 =A0 =A0 .cfi_adjust_cfa_offset -4; >> > =A0 =A0 =A0 =A0 ret >> > =A01: >> > =A0 =A0 =A0 =A0 addl =A0 =A0%ecx,%edi =A0 =A0 =A0 /* copy backwards. *= / >> > @@ -98,9 +94,7 @@ ENTRY(bcopy) >> > =A0 =A0 =A0 =A0 rep >> > =A0 =A0 =A0 =A0 movsl >> > =A0 =A0 =A0 =A0 popl =A0 =A0%edi >> > - =A0 =A0 =A0 .cfi_adjust_cfa_offset -4; >> > =A0 =A0 =A0 =A0 popl =A0 =A0%esi >> > - =A0 =A0 =A0 .cfi_adjust_cfa_offset -4; >> > =A0 =A0 =A0 =A0 cld >> > =A0 =A0 =A0 =A0 ret >> > =A0#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 > > > Hi Kostik, 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. 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? Thanks. Xingxing Pan