Print this page
4823 don't open-code NSEC2MSEC and MSEC2NSEC


   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #pragma ident   "%Z%%M% %I%     %E% SMI"
  28 
  29 #include <mdb/mdb_modapi.h>
  30 #include <mdb/mdb_ctf.h>
  31 
  32 #include <configd.h>
  33 
  34 mdb_ctf_id_t request_enum;
  35 mdb_ctf_id_t response_enum;
  36 mdb_ctf_id_t ptr_type_enum;
  37 mdb_ctf_id_t thread_state_enum;
  38 
  39 hrtime_t max_time_seen;
  40 
  41 static void
  42 enum_lookup(char *out, size_t size, mdb_ctf_id_t id, int val,
  43     const char *prefix, const char *prefix2)
  44 {
  45         const char *cp;
  46         size_t len = strlen(prefix);
  47         size_t len2 = strlen(prefix2);
  48 


 241         }
 242 
 243         enum_lookup(requstr, sizeof (requstr), request_enum, cur.rl_request,
 244             "REP_PROTOCOL_", "");
 245 
 246         if (cur.rl_end != 0) {
 247                 enum_lookup(respstr, sizeof (respstr), response_enum,
 248                     cur.rl_response, "REP_PROTOCOL_", "FAIL_");
 249 
 250                 dur = cur.rl_end - cur.rl_start;
 251                 dursec = dur / NANOSEC;
 252                 durnsec = dur % NANOSEC;
 253 
 254                 if (dursec <= 9)
 255                         mdb_snprintf(durstr, sizeof (durstr),
 256                             "%lld.%06lld",
 257                             dursec, durnsec / (NANOSEC / MICROSEC));
 258                 else if (dursec <= 9999)
 259                         mdb_snprintf(durstr, sizeof (durstr),
 260                             "%lld.%03lld",
 261                             dursec, durnsec / (NANOSEC / MILLISEC));
 262                 else
 263                         mdb_snprintf(durstr, sizeof (durstr),
 264                             "%lld", dursec);
 265         } else {
 266                 (void) strcpy(durstr, "-");
 267                 (void) strcpy(respstr, "-");
 268         }
 269 
 270         if (max_time_seen != 0 && max_time_seen >= cur.rl_start) {
 271                 dur = max_time_seen - cur.rl_start;
 272                 dursec = dur / NANOSEC;
 273                 durnsec = dur % NANOSEC;
 274 
 275                 if (dursec <= 99ULL)
 276                         mdb_snprintf(stampstr, sizeof (stampstr),
 277                             "-%lld.%09lld", dursec, durnsec);
 278                 else if (dursec <= 99999ULL)
 279                         mdb_snprintf(stampstr, sizeof (stampstr),
 280                             "-%lld.%06lld",
 281                             dursec, durnsec / (NANOSEC / MICROSEC));
 282                 else if (dursec <= 99999999ULL)
 283                         mdb_snprintf(stampstr, sizeof (stampstr),
 284                             "-%lld.%03lld",
 285                             dursec, durnsec / (NANOSEC / MILLISEC));
 286                 else
 287                         mdb_snprintf(stampstr, sizeof (stampstr),
 288                             "-%lld", dursec);
 289         } else {
 290                 (void) strcpy(stampstr, "-");
 291         }
 292 
 293         mdb_printf("%0?x %4d T%13s %9s %-22s %-17s\n",
 294             addr, cur.rl_tid, stampstr, durstr, requstr, respstr);
 295 
 296         if (opt_v) {
 297                 mdb_printf("\tclient: %?p (%d)\tptrs: %d\tstamp: %llx\n",
 298                     cur.rl_client, cur.rl_clientid, cur.rl_num_ptrs,
 299                     cur.rl_start);
 300                 for (idx = 0; idx < MIN(MAX_PTRS, cur.rl_num_ptrs); idx++) {
 301                         enum_lookup(typestr, sizeof (typestr), ptr_type_enum,
 302                             cur.rl_ptrs[idx].rlp_type, "RC_PTR_TYPE_", "");
 303                         mdb_printf("\t\t%-7s %5d %?p %?p\n", typestr,
 304                             cur.rl_ptrs[idx].rlp_id, cur.rl_ptrs[idx].rlp_ptr,
 305                             cur.rl_ptrs[idx].rlp_data);




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


  27 #include <mdb/mdb_modapi.h>
  28 #include <mdb/mdb_ctf.h>
  29 
  30 #include <configd.h>
  31 
  32 mdb_ctf_id_t request_enum;
  33 mdb_ctf_id_t response_enum;
  34 mdb_ctf_id_t ptr_type_enum;
  35 mdb_ctf_id_t thread_state_enum;
  36 
  37 hrtime_t max_time_seen;
  38 
  39 static void
  40 enum_lookup(char *out, size_t size, mdb_ctf_id_t id, int val,
  41     const char *prefix, const char *prefix2)
  42 {
  43         const char *cp;
  44         size_t len = strlen(prefix);
  45         size_t len2 = strlen(prefix2);
  46 


 239         }
 240 
 241         enum_lookup(requstr, sizeof (requstr), request_enum, cur.rl_request,
 242             "REP_PROTOCOL_", "");
 243 
 244         if (cur.rl_end != 0) {
 245                 enum_lookup(respstr, sizeof (respstr), response_enum,
 246                     cur.rl_response, "REP_PROTOCOL_", "FAIL_");
 247 
 248                 dur = cur.rl_end - cur.rl_start;
 249                 dursec = dur / NANOSEC;
 250                 durnsec = dur % NANOSEC;
 251 
 252                 if (dursec <= 9)
 253                         mdb_snprintf(durstr, sizeof (durstr),
 254                             "%lld.%06lld",
 255                             dursec, durnsec / (NANOSEC / MICROSEC));
 256                 else if (dursec <= 9999)
 257                         mdb_snprintf(durstr, sizeof (durstr),
 258                             "%lld.%03lld",
 259                             dursec, NSEC2MSEC(durnsec));
 260                 else
 261                         mdb_snprintf(durstr, sizeof (durstr),
 262                             "%lld", dursec);
 263         } else {
 264                 (void) strcpy(durstr, "-");
 265                 (void) strcpy(respstr, "-");
 266         }
 267 
 268         if (max_time_seen != 0 && max_time_seen >= cur.rl_start) {
 269                 dur = max_time_seen - cur.rl_start;
 270                 dursec = dur / NANOSEC;
 271                 durnsec = dur % NANOSEC;
 272 
 273                 if (dursec <= 99ULL)
 274                         mdb_snprintf(stampstr, sizeof (stampstr),
 275                             "-%lld.%09lld", dursec, durnsec);
 276                 else if (dursec <= 99999ULL)
 277                         mdb_snprintf(stampstr, sizeof (stampstr),
 278                             "-%lld.%06lld",
 279                             dursec, durnsec / (NANOSEC / MICROSEC));
 280                 else if (dursec <= 99999999ULL)
 281                         mdb_snprintf(stampstr, sizeof (stampstr),
 282                             "-%lld.%03lld",
 283                             dursec, NSEC2MSEC(durnsec));
 284                 else
 285                         mdb_snprintf(stampstr, sizeof (stampstr),
 286                             "-%lld", dursec);
 287         } else {
 288                 (void) strcpy(stampstr, "-");
 289         }
 290 
 291         mdb_printf("%0?x %4d T%13s %9s %-22s %-17s\n",
 292             addr, cur.rl_tid, stampstr, durstr, requstr, respstr);
 293 
 294         if (opt_v) {
 295                 mdb_printf("\tclient: %?p (%d)\tptrs: %d\tstamp: %llx\n",
 296                     cur.rl_client, cur.rl_clientid, cur.rl_num_ptrs,
 297                     cur.rl_start);
 298                 for (idx = 0; idx < MIN(MAX_PTRS, cur.rl_num_ptrs); idx++) {
 299                         enum_lookup(typestr, sizeof (typestr), ptr_type_enum,
 300                             cur.rl_ptrs[idx].rlp_type, "RC_PTR_TYPE_", "");
 301                         mdb_printf("\t\t%-7s %5d %?p %?p\n", typestr,
 302                             cur.rl_ptrs[idx].rlp_id, cur.rl_ptrs[idx].rlp_ptr,
 303                             cur.rl_ptrs[idx].rlp_data);