Print this page
OS-1723 DTrace should speak JSON
Reviewed by: Bryan Cantrill <bmc@joyent.com>


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.

  25  */
  26 
  27 #include <sys/dtrace.h>
  28 
  29 #define INTFUNC(x)                      \
  30         BEGIN                           \
  31         /*DSTYLED*/                     \
  32         {                               \
  33                 subr++;                 \
  34                 @[(long)x] = sum(1);    \
  35         /*DSTYLED*/                     \
  36         }
  37 
  38 #define STRFUNC(x)                      \
  39         BEGIN                           \
  40         /*DSTYLED*/                     \
  41         {                               \
  42                 subr++;                 \
  43                 @str[x] = sum(1);       \
  44         /*DSTYLED*/                     \


  82 STRFUNC(cleanpath("/var/crash/systemtap"))
  83 STRFUNC(strchr("The SystemTap, The.", 't'))
  84 STRFUNC(strrchr("The SystemTap, The.", 't'))
  85 STRFUNC(strstr("The SystemTap, The.", "The"))
  86 STRFUNC(strtok("The SystemTap, The.", "T"))
  87 STRFUNC(substr("The SystemTap, The.", 0))
  88 INTFUNC(index("The SystemTap, The.", "The"))
  89 INTFUNC(rindex("The SystemTap, The.", "The"))
  90 INTFUNC(htons(0x1234))
  91 INTFUNC(htonl(0x12345678))
  92 INTFUNC(htonll(0x1234567890abcdefL))
  93 INTFUNC(ntohs(0x1234))
  94 INTFUNC(ntohl(0x12345678))
  95 INTFUNC(ntohll(0x1234567890abcdefL))
  96 STRFUNC(inet_ntoa((ipaddr_t *)alloca(sizeof (ipaddr_t))))
  97 STRFUNC(inet_ntoa6((in6_addr_t *)alloca(sizeof (in6_addr_t))))
  98 STRFUNC(inet_ntop(AF_INET, (void *)alloca(sizeof (ipaddr_t))))
  99 STRFUNC(toupper("foo"))
 100 STRFUNC(tolower("BAR"))
 101 INTFUNC(getf(0))


 102 
 103 BEGIN
 104 /subr == DIF_SUBR_MAX + 1/
 105 {
 106         exit(0);
 107 }
 108 
 109 BEGIN
 110 {
 111         printf("found %d subroutines, expected %d\n", subr, DIF_SUBR_MAX + 1);
 112         exit(1);
 113 }


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright (c) 2012, Joyent, Inc.  All rights reserved.
  26  */
  27 
  28 #include <sys/dtrace.h>
  29 
  30 #define INTFUNC(x)                      \
  31         BEGIN                           \
  32         /*DSTYLED*/                     \
  33         {                               \
  34                 subr++;                 \
  35                 @[(long)x] = sum(1);    \
  36         /*DSTYLED*/                     \
  37         }
  38 
  39 #define STRFUNC(x)                      \
  40         BEGIN                           \
  41         /*DSTYLED*/                     \
  42         {                               \
  43                 subr++;                 \
  44                 @str[x] = sum(1);       \
  45         /*DSTYLED*/                     \


  83 STRFUNC(cleanpath("/var/crash/systemtap"))
  84 STRFUNC(strchr("The SystemTap, The.", 't'))
  85 STRFUNC(strrchr("The SystemTap, The.", 't'))
  86 STRFUNC(strstr("The SystemTap, The.", "The"))
  87 STRFUNC(strtok("The SystemTap, The.", "T"))
  88 STRFUNC(substr("The SystemTap, The.", 0))
  89 INTFUNC(index("The SystemTap, The.", "The"))
  90 INTFUNC(rindex("The SystemTap, The.", "The"))
  91 INTFUNC(htons(0x1234))
  92 INTFUNC(htonl(0x12345678))
  93 INTFUNC(htonll(0x1234567890abcdefL))
  94 INTFUNC(ntohs(0x1234))
  95 INTFUNC(ntohl(0x12345678))
  96 INTFUNC(ntohll(0x1234567890abcdefL))
  97 STRFUNC(inet_ntoa((ipaddr_t *)alloca(sizeof (ipaddr_t))))
  98 STRFUNC(inet_ntoa6((in6_addr_t *)alloca(sizeof (in6_addr_t))))
  99 STRFUNC(inet_ntop(AF_INET, (void *)alloca(sizeof (ipaddr_t))))
 100 STRFUNC(toupper("foo"))
 101 STRFUNC(tolower("BAR"))
 102 INTFUNC(getf(0))
 103 INTFUNC(strtoll("0x12EE5D5", 16))
 104 STRFUNC(json("{\"systemtap\": false}", "systemtap"))
 105 
 106 BEGIN
 107 /subr == DIF_SUBR_MAX + 1/
 108 {
 109         exit(0);
 110 }
 111 
 112 BEGIN
 113 {
 114         printf("found %d subroutines, expected %d\n", subr, DIF_SUBR_MAX + 1);
 115         exit(1);
 116 }