From owner-freebsd-dtrace@FreeBSD.ORG Tue Nov 12 04:06:13 2013 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C6A06C67 for ; Tue, 12 Nov 2013 04:06:13 +0000 (UTC) Received: from nm5-vm4.bullet.mail.sg3.yahoo.com (nm5-vm4.bullet.mail.sg3.yahoo.com [106.10.148.147]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A704F3CBB for ; Tue, 12 Nov 2013 04:06:12 +0000 (UTC) Received: from [106.10.166.127] by nm5.bullet.mail.sg3.yahoo.com with NNFMP; 12 Nov 2013 04:03:06 -0000 Received: from [106.10.151.122] by tm16.bullet.mail.sg3.yahoo.com with NNFMP; 12 Nov 2013 04:03:06 -0000 Received: from [127.0.0.1] by omp1004.mail.sg3.yahoo.com with NNFMP; 12 Nov 2013 04:03:06 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 787207.29901.bm@omp1004.mail.sg3.yahoo.com Received: (qmail 51618 invoked by uid 60001); 12 Nov 2013 04:03:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.in; s=s1024; t=1384228986; bh=uauuqYEG4VhCz+MOnEAEaoX6McAI1sNOiAgT3rUVmzw=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:To:MIME-Version:Content-Type; b=SPoTFVODbUBYKPWLqZFsTk0AaM4tC/XHnLvAResGqDp9dSXlBtK66CUr1SJUy+Bry0341j+BklncsRfbip4lVuUPbiE0Uci8iCaSRElKoGxkbhAa4KNzDbhGrjBvgp5Pp1jg6KuHKBaNXV+Zx31dN13TTdaGK1q/C2tz7ofzhoI= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:To:MIME-Version:Content-Type; b=iWsSp9+uSJTfFsAO2Bk3hNVu2DJcbZ9l3nNm3nVp9x/2RE19Nu+ujJVMz6kK6y8SVFAUYzW/mPrsUi4eXvwege+K/ycnvhJ+Z8UgrCHKAM5C3mb3AL6y0cVtPvDWpDhS9g68W4ojUJ/d6WoCKiJ5AjJg5hUpnPs2AZNrFafGr+A=; X-YMail-OSG: wM8hN5UVM1kK7xfM5mAPuOXbmYSGR4rsdkV6Ht3vuFYnSHH IaGtsSF6QFV3cqtMrWacXFE1PP9ssZJQRcL32cyS4_aTvEgKaBKEE2RKTFL2 Wo.SMAB6nGu8JraGqcga90uoHCOpkGPJUaYuIhP5yXfZQIyB4MYcLa9BsuVP mDyT8EON2h587o9rDObIj2WkAs0NMkRV_syVLFjhLL4xtSGMUvrRUC9YkEFY Lyz6UC8kvMcSL.wxO1krJ7acLDG9j53VOJxrGlvBv.Ks6HAoOAIq1oZ6V6tV zyNGl6fd3KyvHKiE1sFooUx9_4HKkOkZTj143fbc5hXnqvJDtguYIJw8.ao7 MnJ1i2YsuzL8o_3f_mbX4DOS.xRKc5_7LuhGwzItwqZ482YllVEf8.RDK.ds UEKSR7OwGC4sbddny3rpgZLlYBEsgqwUmrMrfwlE5sqkNFi05NIXYj0IA3hz 4Bis97igu2YKydM_AUx8UoO8nGI1KGljqWJJsHv90ubmlJbxJQToVkRCBvqP pJ9NIC2mCnnxxjJB.OeevQwP2fqCXVv1h8Xl.DoJmyz8zgg_jl8NR_Z.uD5x HcXQomXvekfQnwi0DzVRRfPLxz7FS2YV30c6Fj6c- Received: from [217.165.101.109] by web192604.mail.sg3.yahoo.com via HTTP; Tue, 12 Nov 2013 12:03:06 SGT X-Rocket-MIMEInfo: 002.001, SGVsbG8sIAoKSSBoYWQgYmVlbiBkb2luZyBzb21lIHdvcmsgb24gdGhlIHBpZCBwcm92aWRlciBpbiBEdHJhY2UuSSBoYXZlIG1hZGUgYSBmZXcgbW9kaWZpY2F0aW9uCsKgc28gdGhhdCBpdCB3aWxsIGxpc3QgYWxsIHRoZSBmdW5jdGlvbnMgdXNlZCBpbiB0aGUgcHJvZ3JhbSBhcyBzZWVuIGluIFNvbGFyaXMgb3IgTWFjT1NYLgrCoFByZXNlbnRseSBpbiBGcmVlQlNELCB5b3UgaGF2ZSB0byBuYW1lIGVhY2ggZnVuY3Rpb25zIHlvdSBoYXZlIHRvIHByb2JlIGluIHRoZSBwcm9ncmFtLiBGb3IKwqBleGFtcGwBMAEBAQE- X-Mailer: YahooMailWebService/0.8.163.597 Message-ID: <1384228985.51085.YahooMailNeo@web192604.mail.sg3.yahoo.com> Date: Tue, 12 Nov 2013 12:03:05 +0800 (SGT) From: Prashanth Kumar To: "freebsd-dtrace@freebsd.org" MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.16 X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list Reply-To: Prashanth Kumar List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2013 04:06:13 -0000 Hello, =0A=0AI had been doing some work on the pid provider in Dtrace.I hav= e made a few modification=0A=A0so that it will list all the functions used = in the program as seen in Solaris or MacOSX.=0A=A0Presently in FreeBSD, you= have to name each functions you have to probe in the program. For=0A=A0exa= mple "dtrace -n 'pid$target:program::entry' -c ./program" will list all the= functions called=0A=A0in the program.This modification was made in libproc= library(proc_sym.c).=0A=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Also while cre= ating probe points for return probe type, any function with more than one r= eturn=0A=A0path will fail.This is because "fasttrap_probe_spec_t" type vari= able is not fully copied into the=0A=A0kernel in fasttrap_ioctl() function.= I have modified in line with Solaris code where the copying=A0 is=0A=A0done= manually by Dtrace, rather than the kernel.(fasttap.c, fasttrap.h)=0A=A0Al= so in "fasttrap_pid_probe()" (fasttrap_isa.c) for the case of "FASTTRAP_T_P= USHL_EBP", the ebp register=0A=A0has to be copied to the stack not esp.=0A= =A0=A0=A0=A0=A0=A0=A0 I had attached the patch files for review.=0A=0A=A0On= e other issue i noticed is that if the program being traced uses Thread Loc= al Storage than=0A=A0for the case of entry probe, it will hang in ___tls_ge= t_addr function in ld-elf.so.=0A=A0If you use scanf or fscanf in your progr= am you can notice this behaviour. This i believe is due to=0A=A0Dtrace usin= g gs segment register to point to the scratch space, and TLS also loading t= he thread variable=0A=A0from gs register.=0A=0A=A0if you change the followi= ng code in fasttrap_isa.c=0A=A0=0A=A0#ifdef __i386__=0A=A0=A0=A0=A0= =A0=A0=A0=A0 addr =3D USD_GETBASE(&curthread->td_pcb->pcb_gsd);=0A=A0#else= =0A=A0=A0=A0=A0=A0=A0=A0=A0 addr =3D curthread->td_pcb->pcb_gsbase;=0A=A0#e= ndif=0A=A0=A0=A0=A0=A0=A0=A0=A0 addr +=3D sizeof (void *);=A0 =A0=0A=A0=0A=0A=A0to=0A=0A=A0=0A=A0#ifdef __i386__=0A=A0=A0=A0=A0=A0=A0=A0= =A0 addr =3D USD_GETBASE(&curthread->td_pcb->pcb_gsd);=0A=A0#else=0A=A0=A0= =A0=A0=A0=A0=A0=A0 addr =3D curthread->td_pcb->pcb_gsbase;=0A=A0#endif=0A= =A0=A0=A0=A0=A0=A0=A0=A0 addr +=3D sizeof (void *) * 3;=A0 =A0=0A=A0= =0A=0A=A0the Dtrace will not hang. I am not sure what is happening here and= =0A=A0whether this is the correct solution.=0A=A0This changes were made in = FreeBSD 9.2-386-RELEASE. I applied the above patches on=0A=A0FreeBSD 10-BET= A (with some manual work) and it was still working. From owner-freebsd-dtrace@FreeBSD.ORG Tue Nov 12 04:18:13 2013 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B2CC5D4C for ; Tue, 12 Nov 2013 04:18:13 +0000 (UTC) Received: from mail-ie0-x231.google.com (mail-ie0-x231.google.com [IPv6:2607:f8b0:4001:c03::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 845853D3F for ; Tue, 12 Nov 2013 04:18:13 +0000 (UTC) Received: by mail-ie0-f177.google.com with SMTP id qd12so947086ieb.22 for ; Mon, 11 Nov 2013 20:18:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=K9/zTXZiKhtFrdh1zM1tEgAsiuDWS01LH5rLiNeeKoE=; b=bvy9BLdr4YGADQVKruRDCfVcjhn5za24raEja10ijhO/P2SqvL3k2pzsxpxU6jWo7C aBc9qOsMYJ3Vyuq1/BvyOAPhLW42Nw72WnS+CsOlasGNfw6FMPQTDmOZQGJuQL1zOk9A AEmvRWG2wIupOoRqN9fDmgvEP8IKTOmsWuVpdD3ob+vn0o7qrjJYEYJrrr4oEJGs3xsl 3m/sW9vUFpovroZdHyoTAaM1a8mtivbikGjOTuVOeWG32V5vJCXsSTJ/TIV3s4Rqs+Hc tex3lqAUpzT1Z4t2lu48qksZyjXl6FsqeyHWxfoNWcpZHclkJk7qEnUxl4OQtm0OfqFd gZiQ== X-Received: by 10.50.82.41 with SMTP id f9mr14755179igy.26.1384229893024; Mon, 11 Nov 2013 20:18:13 -0800 (PST) Received: from raichu (24-212-218-13.cable.teksavvy.com. [24.212.218.13]) by mx.google.com with ESMTPSA id f5sm22528908igc.4.2013.11.11.20.18.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 11 Nov 2013 20:18:10 -0800 (PST) Sender: Mark Johnston Date: Mon, 11 Nov 2013 23:18:05 -0500 From: Mark Johnston To: Prashanth Kumar Subject: Re: your mail Message-ID: <20131112041805.GA76413@raichu> References: <1384228985.51085.YahooMailNeo@web192604.mail.sg3.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1384228985.51085.YahooMailNeo@web192604.mail.sg3.yahoo.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "freebsd-dtrace@freebsd.org" X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2013 04:18:13 -0000 On Tue, Nov 12, 2013 at 12:03:05PM +0800, Prashanth Kumar wrote: > Hello, > > I had been doing some work on the pid provider in Dtrace. Hi Prashanth, I've been going through your patches and committing them as time permits. > I have made a few modification >  so that it will list all the functions used in the program as seen in Solaris or MacOSX. >  Presently in FreeBSD, you have to name each functions you have to probe in the program. For >  example "dtrace -n 'pid$target:program::entry' -c ./program" will list all the functions called >  in the program.This modification was made in libproc library(proc_sym.c). This has been fixed: http://svnweb.freebsd.org/base?view=revision&revision=257300 http://svnweb.freebsd.org/base?view=revision&revision=258000 > >             Also while creating probe points for return probe type, any function with more than one return >  path will fail.This is because "fasttrap_probe_spec_t" type variable is not fully copied into the >  kernel in fasttrap_ioctl() function.I have modified in line with Solaris code where the copying  is >  done manually by Dtrace, rather than the kernel.(fasttap.c, fasttrap.h) I'm working on this one. >  Also in "fasttrap_pid_probe()" (fasttrap_isa.c) for the case of "FASTTRAP_T_PUSHL_EBP", the ebp register >  has to be copied to the stack not esp. >         I had attached the patch files for review. This has been fixed: http://svnweb.freebsd.org/base?view=revision&revision=257679 http://svnweb.freebsd.org/base?view=revision&revision=257143 > >  One other issue i noticed is that if the program being traced uses Thread Local Storage than >  for the case of entry probe, it will hang in ___tls_get_addr function in ld-elf.so. >  If you use scanf or fscanf in your program you can notice this behaviour. This i believe is due to >  Dtrace using gs segment register to point to the scratch space, and TLS also loading the thread variable >  from gs register. I haven't been able to reproduce this one yet. If you can send me a program and D script that does the trick, that'd be very helpful. > >  if you change the following code in fasttrap_isa.c >   >  #ifdef __i386__ >          addr = USD_GETBASE(&curthread->td_pcb->pcb_gsd); >  #else >          addr = curthread->td_pcb->pcb_gsbase; >  #endif >          addr += sizeof (void *);    >   > >  to > >   >  #ifdef __i386__ >          addr = USD_GETBASE(&curthread->td_pcb->pcb_gsd); >  #else >          addr = curthread->td_pcb->pcb_gsbase; >  #endif >          addr += sizeof (void *) * 3;    >   > >  the Dtrace will not hang. I am not sure what is happening here and >  whether this is the correct solution. Neither am I. :) >  This changes were made in FreeBSD 9.2-386-RELEASE. I applied the above patches on >  FreeBSD 10-BETA (with some manual work) and it was still working. > _______________________________________________ > freebsd-dtrace@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace > To unsubscribe, send any mail to "freebsd-dtrace-unsubscribe@freebsd.org"