Print this page
4469 DTrace helper tracing should be dynamic


   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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2013 by Delphix. All rights reserved.

  25  */
  26 
  27 /*
  28  * explicitly define DTRACE_ERRDEBUG to pull in definition of dtrace_errhash_t
  29  * explicitly define _STDARG_H to avoid stdarg.h/varargs.h u/k defn conflict
  30  */
  31 #define DTRACE_ERRDEBUG
  32 #define _STDARG_H
  33 
  34 #include <mdb/mdb_param.h>
  35 #include <mdb/mdb_modapi.h>
  36 #include <mdb/mdb_ks.h>
  37 #include <sys/dtrace_impl.h>
  38 #include <sys/vmem_impl.h>
  39 #include <sys/ddi_impldefs.h>
  40 #include <sys/sysmacros.h>
  41 #include <sys/kobj.h>
  42 #include <dtrace.h>
  43 #include <alloca.h>
  44 #include <ctype.h>


1256                 mdb_warn("failed to read error msg at %p", addr);
1257                 return (DCMD_ERR);
1258         }
1259 
1260         mdb_printf("%8d %s", err.dter_count, msg);
1261 
1262         /*
1263          * Some error messages include a newline -- only print the newline
1264          * if the message doesn't have one.
1265          */
1266         if (msg[strlen(msg) - 1] != '\n')
1267                 mdb_printf("\n");
1268 
1269         return (DCMD_OK);
1270 }
1271 
1272 int
1273 dtrace_helptrace_init(mdb_walk_state_t *wsp)
1274 {
1275         uint32_t next;
1276         int enabled;
1277 
1278         if (wsp->walk_addr != NULL) {
1279                 mdb_warn("dtrace_helptrace only supports global walks\n");
1280                 return (WALK_ERR);
1281         }
1282 
1283         if (mdb_readvar(&enabled, "dtrace_helptrace_enabled") == -1) {
1284                 mdb_warn("couldn't read 'dtrace_helptrace_enabled'");
1285                 return (WALK_ERR);
1286         }
1287 
1288         if (!enabled) {
1289                 mdb_warn("helper tracing is not enabled\n");
1290                 return (WALK_ERR);
1291         }
1292 
1293         if (mdb_readvar(&next, "dtrace_helptrace_next") == -1) {
1294                 mdb_warn("couldn't read 'dtrace_helptrace_next'");
1295                 return (WALK_ERR);
1296         }
1297 
1298         wsp->walk_addr = next;
1299 
1300         return (WALK_NEXT);
1301 }
1302 
1303 int
1304 dtrace_helptrace_step(mdb_walk_state_t *wsp)
1305 {
1306         uint32_t next, size, nlocals, bufsize;
1307         uintptr_t buffer, addr;
1308         dtrace_helptrace_t *ht;




   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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2013 by Delphix. All rights reserved.
  25  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  26  */
  27 
  28 /*
  29  * explicitly define DTRACE_ERRDEBUG to pull in definition of dtrace_errhash_t
  30  * explicitly define _STDARG_H to avoid stdarg.h/varargs.h u/k defn conflict
  31  */
  32 #define DTRACE_ERRDEBUG
  33 #define _STDARG_H
  34 
  35 #include <mdb/mdb_param.h>
  36 #include <mdb/mdb_modapi.h>
  37 #include <mdb/mdb_ks.h>
  38 #include <sys/dtrace_impl.h>
  39 #include <sys/vmem_impl.h>
  40 #include <sys/ddi_impldefs.h>
  41 #include <sys/sysmacros.h>
  42 #include <sys/kobj.h>
  43 #include <dtrace.h>
  44 #include <alloca.h>
  45 #include <ctype.h>


1257                 mdb_warn("failed to read error msg at %p", addr);
1258                 return (DCMD_ERR);
1259         }
1260 
1261         mdb_printf("%8d %s", err.dter_count, msg);
1262 
1263         /*
1264          * Some error messages include a newline -- only print the newline
1265          * if the message doesn't have one.
1266          */
1267         if (msg[strlen(msg) - 1] != '\n')
1268                 mdb_printf("\n");
1269 
1270         return (DCMD_OK);
1271 }
1272 
1273 int
1274 dtrace_helptrace_init(mdb_walk_state_t *wsp)
1275 {
1276         uint32_t next;
1277         uintptr_t buffer;
1278 
1279         if (wsp->walk_addr != NULL) {
1280                 mdb_warn("dtrace_helptrace only supports global walks\n");
1281                 return (WALK_ERR);
1282         }
1283 
1284         if (mdb_readvar(&buffer, "dtrace_helptrace_buffer") == -1) {
1285                 mdb_warn("couldn't read 'dtrace_helptrace_buffer'");
1286                 return (WALK_ERR);
1287         }
1288 
1289         if (buffer == NULL) {
1290                 mdb_warn("helper tracing is not enabled\n");
1291                 return (WALK_ERR);
1292         }
1293 
1294         if (mdb_readvar(&next, "dtrace_helptrace_next") == -1) {
1295                 mdb_warn("couldn't read 'dtrace_helptrace_next'");
1296                 return (WALK_ERR);
1297         }
1298 
1299         wsp->walk_addr = next;
1300 
1301         return (WALK_NEXT);
1302 }
1303 
1304 int
1305 dtrace_helptrace_step(mdb_walk_state_t *wsp)
1306 {
1307         uint32_t next, size, nlocals, bufsize;
1308         uintptr_t buffer, addr;
1309         dtrace_helptrace_t *ht;