From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 21 09:36:14 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 800FC106564A; Mon, 21 Mar 2011 09:36:14 +0000 (UTC) (envelope-from forandom@gmail.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id 25D098FC1A; Mon, 21 Mar 2011 09:36:13 +0000 (UTC) Received: by qyk35 with SMTP id 35so2081900qyk.13 for ; Mon, 21 Mar 2011 02:36:13 -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; bh=FKrllTslEjH7j/3zZDH33YhQ3YdaG2DBLkuHwf3sfnM=; b=mBayA3bA1ahLzEoPloGP0Z+v1LUhGmawJaGo7/jHLSRvggMFyB6UgOsxX2swwqYX4+ 9zqnz+oxbvB4lso1x6TNVVtfuoBRK5Vbw4Dga976+65P99v0opIZUL0d1omBUVGdU/Nz VG046W1UR749JH7ikXNjpis8dXob/7zRNcAQ4= 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; b=dpwQ15ZOG99mmoMelXp8lVD1h6ahsBQaql+SWaELacqkZKspw9H7at82gNUXjgpYeB pbx9LVBIO3RmvxTFjXRBkI6LbckjgAamhzTQbLvU0ieTfQFITrbQP31nrHREUIFYDL1S lNXFMZ8ziCPZ8pryczkaxXhtvZoy91b54vzZI= MIME-Version: 1.0 Received: by 10.229.142.139 with SMTP id q11mr2924353qcu.163.1300700173226; Mon, 21 Mar 2011 02:36:13 -0700 (PDT) Sender: forandom@gmail.com Received: by 10.229.222.148 with HTTP; Mon, 21 Mar 2011 02:36:13 -0700 (PDT) In-Reply-To: <20110320181911.GA79862@dchagin.static.corbina.ru> References: <20110319174115.GA33282@dchagin.static.corbina.ru> <20110320071847.GA10579@dchagin.static.corbina.ru> <20110320181911.GA79862@dchagin.static.corbina.ru> Date: Mon, 21 Mar 2011 17:36:13 +0800 X-Google-Sender-Auth: J9-CRkjtQIZBHkDB625e8ssLhR8 Message-ID: From: Xingxing Pan To: Chagin Dmitry Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-hackers@freebsd.org 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: Mon, 21 Mar 2011 09:36:14 -0000 2011/3/21 Chagin Dmitry : > On Sun, Mar 20, 2011 at 11:24:21PM +0800, Xingxing Pan wrote: >> >> >> > >> > hm, you should add the .cfi directive in each .S file by hand: >> > http://www.logix.cz/michal/devel/gas-cfi/ >> > >> > -- >> > Have fun! >> > chd >> > >> >> Thanks for your reply. I think I have got the idea. >> For the object files generated by the toolchain, there's no need to worry about >> DWARF call frame information if the DWARF is supported by the toolchain.But >> the assembly written by hand is an exception. >> Different architecture has different assembly. That means I have to add DWARF >> for all these architectures currently supported by FreeBSD. Maybe I need a >> 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 2011-03-21 14:35:56.111973722 +0800 +++ asm.h 2011-03-21 15:25:31.564636162 +0800 @@ -71,7 +71,7 @@ #define _ENTRY(x) _START_ENTRY; \ .globl CNAME(x); .type CNAME(x),@function; CNAME(x): -#define END(x) .size x, . - x +#define END(x) .cfi_endproc; .size x, . - x #ifdef PROF #define ALTENTRY(x) _ENTRY(x); \ @@ -80,9 +80,10 @@ popl %ebp; \ jmp 9f #define ENTRY(x) _ENTRY(x); \ - pushl %ebp; movl %esp,%ebp; \ + .cfi_startproc; \ + pushl %ebp; .cfi_adjust_cfa_offset 4; movl %esp,%ebp; .cfi_def_cfa_register %ebp; \ call PIC_PLT(HIDENAME(mcount)); \ - popl %ebp; \ + popl %ebp; .cfi_def_cfa %esp, 4; \ --- bcopy.S 2011-03-21 15:51:26.804203809 +0800 +++ ../8.2.0/lib/libc/i386/string/bcopy.S 2011-03-21 14:28:15.023069890 +0800 @@ -51,9 +51,7 @@ ENTRY(bcopy) #endif #endif pushl %esi - .cfi_adjust_cfa_offset 4; pushl %edi - .cfi_adjust_cfa_offset 4; #if defined(MEMCOPY) || defined(MEMMOVE) movl 12(%esp),%edi movl 16(%esp),%esi @@ -77,9 +75,7 @@ ENTRY(bcopy) rep movsb popl %edi - .cfi_adjust_cfa_offset -4; popl %esi - .cfi_adjust_cfa_offset -4; ret 1: addl %ecx,%edi /* copy backwards. */ @@ -98,9 +94,7 @@ ENTRY(bcopy) rep movsl popl %edi - .cfi_adjust_cfa_offset -4; popl %esi - .cfi_adjust_cfa_offset -4; cld ret #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