From nobody@FreeBSD.org  Mon Dec 14 10:24:16 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E57EF106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 14 Dec 2009 10:24:16 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id D40DB8FC1A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 14 Dec 2009 10:24:16 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nBEAOGb3032946
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 14 Dec 2009 10:24:16 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id nBEAOGOD032938;
	Mon, 14 Dec 2009 10:24:16 GMT
	(envelope-from nobody)
Message-Id: <200912141024.nBEAOGOD032938@www.freebsd.org>
Date: Mon, 14 Dec 2009 10:24:16 GMT
From: Andrei Lavreniyuk <andy.lavr@reactor-xg.kiev.ua>
To: freebsd-gnats-submit@FreeBSD.org
Subject: DTrace stops tracing because of struct thread
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         141452
>Category:       kern
>Synopsis:       [dtrace] DTrace stops tracing because of struct thread
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 14 10:30:00 UTC 2009
>Closed-Date:    Wed Jul 13 08:08:29 UTC 2011
>Last-Modified:  Wed Jul 13 08:08:29 UTC 2011
>Originator:     Andrei Lavreniyuk
>Release:        FreeBSD 8.0-STABLE
>Organization:
Technica-03, Inc.
>Environment:
FreeBSD datacenter.technica-03.local 8.0-STABLE FreeBSD 8.0-STABLE #0: Sat Dec 12 21:41:15 EET 2009     root@datacenter.technica-03.local:/usr/obj/usr/src/sys/SMP64  amd64
>Description:

DTrace support was enabled referring to http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/dtrace-enable.html

However, various DTraceToolkit applications stop tracing as follows.


# dtrace -l | wc -l
   28647           
# ./hotkernel      
Sampling... Hit Ctrl-C to end.
dtrace: invalid probe specifier 
        #pragma D option quiet  
        profile:::profile-1001hz
        /arg0/                  
        {                       
                @pc[arg0] = count();
        }                           
        dtrace:::END                
        {                           
                printa("%a %@d\n", @pc);
        }                               
: "/usr/lib/dtrace/psinfo.d", line 88: failed to resolve type kernel`struct thread * for identifier curthread: Unknown type name

FUNCTION                                                COUNT   PCNT
# ./procsystime -n ksh                                              
dtrace: invalid probe specifier                                     
 #pragma D option quiet                                             

 /*
  * Command line arguments
  */                      
 inline int OPT_elapsed  = 1;
 inline int OPT_cpu      = 0;
 inline int OPT_counts   = 0;
 inline int OPT_filter   = 1;
 inline int OPT_pid      = 0;
 inline int OPT_name     = 1;
 inline int OPT_totals   = 0;
 inline int OPT_command  = 0;
 inline int PID          = 0;
 inline string NAME      = "ksh";
 inline string COMMAND   = "";   

 dtrace:::BEGIN 
 {              
        self->start = 0;
        self->vstart = 0;
 }                       
 dtrace:::BEGIN          
 /! OPT_command/         
 {                       
        printf("Tracing... Hit Ctrl-C to end...\n");
 }                                                  

 /*
  * Set start timestamp and counts
  */                              
 syscall:::entry                  
 /(! OPT_filter) ||               
  (OPT_pid && pid == PID) ||      
  (OPT_name && execname == NAME) ||
  (OPT_command && pid == $target)/ 
 {                                 
        self->ok = 1;              
 }                                 
 syscall:::entry                   
 /self->ok/                        
 {                                 
        OPT_counts ? @Counts[probefunc] = count() : 1;
        (OPT_counts && OPT_totals) ? @Counts["TOTAL:"] = count() : 1;
        OPT_elapsed ? self->start = timestamp : 1;                   
        OPT_cpu ? self->vstart = vtimestamp : 1;                     
        self->ok = 0;                                                
 }                                                                   

 /*
  * Calculate time deltas
  */
 syscall:::return
 /self->start/
 {
        this->elapsed = timestamp - self->start;
        @Elapsed[probefunc] = sum(this->elapsed);
        OPT_totals ? @Elapsed["TOTAL:"] = sum(this->elapsed) : 1;
        self->start = 0;
 }
 syscall:::return
 /self->vstart/
 {
        this->cpu = vtimestamp - self->vstart;
        @CPU[probefunc] = sum(this->cpu);
        OPT_totals ? @CPU["TOTAL:"] = sum(this->cpu) : 1;
        self->vstart = 0;
 }

 /*
  * Elapsed time report
  */
 dtrace:::END
 /OPT_elapsed/
 {
        printf("\nElapsed Times for ");
        OPT_pid ? printf("PID %d,\n\n",PID) : 1;
        OPT_name ? printf("processes %s,\n\n",NAME) : 1;
        OPT_command ? printf("command %s,\n\n",COMMAND) : 1;
        (! OPT_filter) ? printf("all processes,\n\n") : 1;
        printf("%16s %18s\n","SYSCALL","TIME (ns)");
        printa("%16s %@18d\n",@Elapsed);
 }

 /*
  * CPU time report
  */
 dtrace:::END
 /OPT_cpu/
 {
        printf("\nCPU Times for ");
        OPT_pid ? printf("PID %d,\n\n",PID) : 1;
        OPT_name ? printf("processes %s,\n\n",NAME) : 1;
        OPT_command ? printf("command %s,\n\n",COMMAND) : 1;
        (! OPT_filter) ? printf("all processes,\n\n") : 1;
        printf("%16s %18s\n","SYSCALL","TIME (ns)");
        printa("%16s %@18d\n",@CPU);
 }

 /*
  * Syscall count report
  */
 dtrace:::END
 /OPT_counts/
 {
        printf("\nSyscall Counts for ");
        OPT_pid ? printf("PID %d,\n\n",PID) : 1;
        OPT_name ? printf("processes %s,\n\n",NAME) : 1;
        OPT_command ? printf("command %s,\n\n",COMMAND) : 1;
        (! OPT_filter) ? printf("all processes,\n\n") : 1;
        printf("%16s %18s\n","SYSCALL","COUNT");
        OPT_counts ? printa("%16s %@18d\n",@Counts) : 1;
 }
: "/usr/lib/dtrace/psinfo.d", line 88: failed to resolve type kernel`struct thread * for identifier curthread: Unknown type name


# cd Proc                                 
# ./dapptrace /bin/pwd                    
/root/DTraceToolkit/Proc                  
dtrace: invalid probe specifier           
 #pragma D option quiet                   

 /*
  * Command line arguments
  */                      
 inline int OPT_command   = 1;
 inline int OPT_liball    = 0;
 inline int OPT_indent    = 0;
 inline int OPT_printid   = 0;
 inline int OPT_relative  = 0;
 inline int OPT_elapsed   = 0;
 inline int OPT_cpu       = 0;
 inline int OPT_counts    = 0;
 inline int OPT_pid       = 0;
 inline int PID           = 0;
 inline string NAME       = "";

 dtrace:::BEGIN 
 {              
        /* print header */
        OPT_printid  ? printf("%-8s  ","PID/LWP") : 1;
        OPT_relative ? printf("%8s ","RELATIVE") : 1; 
        OPT_elapsed  ? printf("%7s ","ELAPSD") : 1;   
        OPT_cpu      ? printf("%6s ","CPU") : 1;      
        printf("CALL(args) \t\t = return\n");         

        /* indent depth */
        depth = 0;        
 }                        

 /*
  * Save syscall entry info
  */                       
 pid$target:a.out::entry   
 {                         
        /* set function depth */
        this->fdepth = ++fdepth[probefunc];
        depth += 2;                        

        /* set start details */
        self->start[probefunc,this->fdepth] = timestamp;
        self->vstart[probefunc,this->fdepth] = vtimestamp;

        /* count occurances */
        OPT_counts && OPT_liball ? @Counts[probemod,probefunc] = count() : 1;
        OPT_counts && ! OPT_liball ? @Counts[probefunc] = count() : 1;

        /* print optional fields */
        OPT_printid  ? printf("%5d/%d:  ",pid,tid) : 1;
        OPT_relative ? printf("%8d ",vtimestamp/1000) : 1;
        OPT_elapsed  ? printf("      . ") : 1;
        OPT_cpu      ? printf("     . ") : 1;
        OPT_indent   ? printf("%*s",depth,"") : 1;

        /* print main data */
        printf("-> ");
        OPT_liball ? printf("%s:",probemod) : 1;
        printf("%s(0x%X, 0x%X, 0x%X)\t\t\n",probefunc,arg0,arg1,arg2);

 }

 /*
  * Print return data
  */
 /* print 3 arg output - default */
 pid$target:a.out::return
 /self->start[probefunc,fdepth[probefunc]]/
 {
        /* fetch function depth */
        this->fdepth = fdepth[probefunc];

        /* calculate elapsed time */
        this->elapsed = timestamp - self->start[probefunc,this->fdepth];
        self->start[probefunc,this->fdepth] = 0;
        this->cpu = vtimestamp - self->vstart[probefunc,this->fdepth];
        self->vstart[probefunc,this->fdepth] = 0;

        /* print optional fields */
        OPT_printid  ? printf("%5d/%d:  ",pid,tid) : 1;
        OPT_relative ? printf("%8d ",vtimestamp/1000) : 1;
        OPT_elapsed  ? printf("%7d ",this->elapsed/1000) : 1;
        OPT_cpu      ? printf("%6d ",this->cpu/1000) : 1;
        OPT_indent   ? printf("%*s",depth,"") : 1;

        /* print main data */
        printf("<- ");
        OPT_liball ? printf("%s:",probemod) : 1;
        printf("%s = %d\n",probefunc,(int)arg0);
        depth -= 2;
        fdepth[probefunc]--;
 }

 /* reset indent depth */
 profile:::tick-1sec
 {
        /*
         * some probes generated by the pid provider have entries
         * but not returns. this is a klude to fix that problem. this
         * also explains fdepth[probefunc] rather than a single depth.
         */
        depth = 0;
 }

 /* print counts */
 dtrace:::END
 {
        OPT_counts ? printf("\n%-49s %16s\n","CALL","COUNT") : 1;
        OPT_counts && OPT_liball ? printa("%-16s %-32s %@16d\n",@Counts) : 1;
        OPT_counts && ! OPT_liball ? printa("%-49s %@16d\n",@Counts) : 1;
 }
: "/usr/lib/dtrace/psinfo.d", line 88: failed to resolve type kernel`struct thread * for identifier curthread: Unknown type name



>How-To-Repeat:
See http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/dtrace-enable.html
and run DTraceToolkit applications on FreeBSD 8.0-STABLE.
>Fix:


>Release-Note:
>Audit-Trail:

From: Adam Stylinski <kungfujesus06@gmail.com>
To: bug-followup@FreeBSD.org, andy.lavr@reactor-xg.kiev.ua
Cc:  
Subject: Re: kern/141452 [dtrace] Dtrace stops tracing because of struct
 thread
Date: Sun, 3 Apr 2011 16:39:36 -0400

 --PEIAKu/WMn1b1Hv9
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 As can be found in this thread, the simple workaround is to compile your kernel with debug symbols using DEBUG=-g in your kernconf:
 
 http://lists.freebsd.org/pipermail/freebsd-stable/2010-December/060406.html
 
 --PEIAKu/WMn1b1Hv9
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (FreeBSD)
 
 iQIcBAEBAgAGBQJNmNsHAAoJED6sRHE6TvmnuoUQAL2FZUZK7luPbp90lPBArq63
 JTnOFOlWXKX6Hd9VsLhn2ziZKa1w34SaqF//OHHeL9YrcV4u5belPOhfFXaG20xQ
 QspxoS5wUI8Zb6bq6zwCBwZZuRs5Ksh+UaHy9XnWj1Rj7bmGJaV2npqXKJ7PIRz0
 A/AxLQ6zgVdclXET8Lkz9fSmifSRgK/4wFEiiVkqgtmROBuN1y9vw8MJaw7G9kyp
 exOz0oF429Plsqfke84pWE5+a21RwSCWewN1nJ5976YlmKIpJiFikWBrHZw6cAJk
 tDt8MoobChb1aWn6hXnHzistkEV4mcPrHdgPL2c3KfQIEo1qPvhxEt9NQRiYA/NN
 Ye+JCnsXn9kz0yLX+emcqzZZ/dy1Zt6hYLOD7w2Etd+m6q245sGCCoMj0LfmQv1q
 4IXObNyA7IrlyveeHSS5qG6QmXcm+I4u5SIupcmcc9rlG8bxzTc5vTBzHupEeqVR
 YSrxaNymjoNeNIAsKGEyThPvyYmiLSTnenjhy6+NmCJqY4Xefu1iWrFaQ2WhuW0E
 L6uqXavSUyiyCTKDuGPJJniXKbpllR+jG/EjNlm9OwOXQjnaTRkb7s9LCaMfAeis
 U+D1ImHVXTzK90jwZCqzJAF2yPsOrFy9IQAhA9/i+Ot2B7HiMFTM8OpXNnJlaRso
 9bPfyiuRzBYxfhyzaAKS
 =WwIQ
 -----END PGP SIGNATURE-----
 
 --PEIAKu/WMn1b1Hv9--

From: Andrei Lavreniyuk <andy.lavr@gmail.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/141452: [dtrace] DTrace stops tracing because of struct thread
Date: Wed, 13 Jul 2011 09:50:30 +0300

 Hi!
 
 
 Please close PR. Thanks.
 
 
 ---
 Best regards, Andrei Lavreniyuk.
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Wed Jul 13 08:08:14 UTC 2011 
State-Changed-Why:  
Closed at submitter's request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141452 
>Unformatted:
