Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Nov 2013 12:03:05 +0800 (SGT)
From:      Prashanth Kumar <pra_udupi@yahoo.co.in>
To:        "freebsd-dtrace@freebsd.org" <freebsd-dtrace@freebsd.org>
Message-ID:  <1384228985.51085.YahooMailNeo@web192604.mail.sg3.yahoo.com>

next in thread | raw e-mail | index | archive | help
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<code>=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</co=
de>=0A=0A=A0to=0A=0A=A0<code>=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</code>=
=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: <owner-freebsd-dtrace@FreeBSD.ORG>
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 <freebsd-dtrace@freebsd.org>; 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 <freebsd-dtrace@freebsd.org>; Tue, 12 Nov 2013 04:18:13 +0000 (UTC)
Received: by mail-ie0-f177.google.com with SMTP id qd12so947086ieb.22
 for <freebsd-dtrace@freebsd.org>; 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 <multiple recipients>
 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
 Mon, 11 Nov 2013 20:18:10 -0800 (PST)
Sender: Mark Johnston <markjdb@gmail.com>
Date: Mon, 11 Nov 2013 23:18:05 -0500
From: Mark Johnston <markj@freebsd.org>
To: Prashanth Kumar <pra_udupi@yahoo.co.in>
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" <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."
 <freebsd-dtrace.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-dtrace>, 
 <mailto:freebsd-dtrace-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-dtrace/>;
List-Post: <mailto:freebsd-dtrace@freebsd.org>
List-Help: <mailto:freebsd-dtrace-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace>,
 <mailto:freebsd-dtrace-request@freebsd.org?subject=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
>  <code>
>  #ifdef __i386__
>          addr = USD_GETBASE(&curthread->td_pcb->pcb_gsd);
>  #else
>          addr = curthread->td_pcb->pcb_gsbase;
>  #endif
>          addr += sizeof (void *);   
>  </code>
> 
>  to
> 
>  <code>
>  #ifdef __i386__
>          addr = USD_GETBASE(&curthread->td_pcb->pcb_gsd);
>  #else
>          addr = curthread->td_pcb->pcb_gsbase;
>  #endif
>          addr += sizeof (void *) * 3;   
>  </code>
> 
>  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"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1384228985.51085.YahooMailNeo>