From owner-freebsd-dtrace@FreeBSD.ORG Mon Oct 21 02:29:07 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 ESMTP id 7DC8E750 for ; Mon, 21 Oct 2013 02:29:07 +0000 (UTC) (envelope-from adam.leventhal@delphix.com) Received: from mail-ob0-x229.google.com (mail-ob0-x229.google.com [IPv6:2607:f8b0:4003:c01::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 458CD21ED for ; Mon, 21 Oct 2013 02:29:07 +0000 (UTC) Received: by mail-ob0-f169.google.com with SMTP id wp4so5266274obc.0 for ; Sun, 20 Oct 2013 19:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delphix.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=jf8kENLxhmO3Bb34PIagdtB77TsZOQYUGAF7e9cjxNw=; b=ceXoC7uxmw18YK2KRz+x0LlkZYShdSHnZzouT12sWUkCWZCt1Iq6ye34ihnuW+oqOy CwzRD9xTdLMBUHSpYs5479DSKgOKX2diRURMSCxJn4dixLb2WP9KBkniWNmKtEGscaUT IqwYhUtbNZbG42zxnY20bCsWm0rKvOwma58ak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=jf8kENLxhmO3Bb34PIagdtB77TsZOQYUGAF7e9cjxNw=; b=GdBSMd1gnJmycENemcZiG3E5wIEbhVJ6wkNz2inLP7BkWGlqNLTzOoiE3wTh/J2b6v IA1knYPzdOkgquiMBcgSx9sYmrzK289tZf0PMeN9N4gKVqaGOoMCxfK4KK/TvYJjh0+D dwrNlec07zS2a2Z2pBZJVS458MG5zddDrE7e1elvjOASegyCnNlAbZmQi1MB/MwM7uCr oAIyhyMTd8+9QD+JBq4tsg7+aWMCom9d9JANh2LwDfDHSJq4wXF5VFY9ojxj56VEnUKZ is2MAKjZrf8LtIDv5QA1aSVltMOKu7c5yHwoNcLiYo6Vz89fXJdhFkCg0jwef6ZYbpg/ 2yqA== X-Gm-Message-State: ALoCoQldoaf9OTlTl/9ZML0DKMP0WRrzd47KUrpLMMxx4k+ohW9LFVizu5IQBUQz7R8CBykw3Vsi MIME-Version: 1.0 X-Received: by 10.60.96.169 with SMTP id dt9mr5226066oeb.27.1382322546280; Sun, 20 Oct 2013 19:29:06 -0700 (PDT) Received: by 10.76.92.67 with HTTP; Sun, 20 Oct 2013 19:29:06 -0700 (PDT) In-Reply-To: <20131020235216.GA13816@charmander> References: <6A174747-D855-481D-A191-67A2805BC9AE@freebsd.org> <20131020235216.GA13816@charmander> Date: Sun, 20 Oct 2013 21:29:06 -0500 Message-ID: Subject: Re: Integration DTrace problems From: Adam Leventhal To: Mark Johnston Content-Type: text/plain; charset=ISO-8859-1 Cc: Veniamin Gvozdikov , freebsd-dtrace@freebsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.14 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: Mon, 21 Oct 2013 02:29:07 -0000 Hey Mark, I'd go so far as to suggest you remove the #ifdef sun stuff and just have your new logic replace what was there. As the original author of that code (I think), it is more kludgy than clever in retrospect -- as so many things are... Thanks. Adam On Sun, Oct 20, 2013 at 6:52 PM, Mark Johnston wrote: > On Wed, Oct 09, 2013 at 01:54:14AM +0400, Veniamin Gvozdikov wrote: >> Hello, >> >> I have problems with integration DTrace: >> >> * Wildcard bug >> * USDT at runtime works only with probes with arguments less than 5 > > The patch below should partly address this issue (which exists for the > pid provider too). On amd64, the first six arguments are taken out of the > trap frame with (roughly) the following line: > > val = regs->r_rdi[argno] > > where 0 <= argno <= 5 is the argument index. This works when the six > argument registers correspond to consecutive of struct reg, which is not > the case on FreeBSD. This bug only comes up when argno == 5 though, > since the first _five_ arguments are passed directly to dtrace_probe() by > the fasttrap trap handler. > > Arguments of index > 5 come from the stack and may still be incorrect > with this patch. I'm not yet sure what the problem is - if the arguments > are (4-byte) ints, some of the values are wrong, but when I change the > types to long, the values are correct (up to arg9 at least). > >> * USDT depended by base src because need dtrace.h although It exists on OSX and Oracle Linux >> * Bug with providers position in D file with multi link dtrace objects >> * Bug with not used probes when all providers unavailable if doesn't use in code >> * Inconvenient toolchains (need to see DTrace on OSX) >> >> For more details go to link http://zlonet.ru/page/dtrace-integration-features/ . >> >> >> Any idea? > > diff --git a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c > index 65991af..8afc45a 100644 > --- a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c > +++ b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c > @@ -271,8 +271,26 @@ fasttrap_anarg(struct reg *rp, int function_entry, int argno) > * In 64-bit mode, the first six arguments are stored in > * registers. > */ > - if (argno < 6) > + if (argno < 6) { > +#if !defined(sun) > + switch (argno) { > + case 0: > + return (rp->r_rdi); > + case 1: > + return (rp->r_rsi); > + case 2: > + return (rp->r_rdx); > + case 3: > + return (rp->r_rcx); > + case 4: > + return (rp->r_r8); > + case 5: > + return (rp->r_r9); > + } > +#else > return ((&rp->r_rdi)[argno]); > +#endif > + } > > stack = (uintptr_t *)rp->r_rsp; > DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT); > diff --git a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c > index 34d6f33..b82b77f 100644 > --- a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c > +++ b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c > @@ -367,7 +367,31 @@ dtrace_getarg(int arg, int aframes) > sizeof (uintptr_t)); > > if (arg <= inreg) { > +#if !defined(sun) > + switch (arg) { > + case 0: > + stack = (uintptr_t *)&rp->r_rdi; > + break; > + case 1: > + stack = (uintptr_t *)&rp->r_rsi; > + break; > + case 2: > + stack = (uintptr_t *)&rp->r_rdx; > + break; > + case 3: > + stack = (uintptr_t *)&rp->r_rcx; > + break; > + case 4: > + stack = (uintptr_t *)&rp->r_r8; > + break; > + case 5: > + stack = (uintptr_t *)&rp->r_r9; > + break; > + } > + arg = 0; > +#else > stack = (uintptr_t *)&rp->r_rdi; > +#endif > } else { > stack = (uintptr_t *)(rp->r_rsp); > arg -= inreg; > _______________________________________________ > 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" -- Adam Leventhal CTO, Delphix http://blog.delphix.com/ahl