Print this page
12364 mdb trips assertion related to autowrap

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/common/mdb/mdb_print.c
          +++ new/usr/src/cmd/mdb/common/mdb/mdb_print.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26   26  /*
  27   27   * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  28      - * Copyright 2015 Joyent, Inc.
       28 + * Copyright 2020 Joyent, Inc.
  29   29   * Copyright (c) 2014 Nexenta Systems, Inc. All rights reserved.
  30   30   */
  31   31  
  32   32  #include <mdb/mdb_modapi.h>
  33   33  #include <mdb/mdb_target.h>
  34   34  #include <mdb/mdb_argvec.h>
  35   35  #include <mdb/mdb_string.h>
  36   36  #include <mdb/mdb_stdlib.h>
  37   37  #include <mdb/mdb_err.h>
  38   38  #include <mdb/mdb_debug.h>
↓ open down ↓ 885 lines elided ↑ open up ↑
 924  924                  /* sign-extend value, and print as a signed decimal */
 925  925                  value = ((int64_t)value << sshift) >> sshift;
 926  926                  format = "%#lld";
 927  927          }
 928  928          mdb_printf(format, value);
 929  929  
 930  930          return (0);
 931  931  }
 932  932  
 933  933  /*
      934 + * We want to print an escaped char as e.g. '\0'. We don't use mdb_fmt_print()
      935 + * as it won't get auto-wrap right here (although even now, we don't include any
      936 + * trailing comma).
      937 + */
      938 +static int
      939 +print_char_val(mdb_tgt_addr_t addr, printarg_t *pap)
      940 +{
      941 +        char cval;
      942 +        char *s;
      943 +
      944 +        if (mdb_tgt_aread(pap->pa_tgt, pap->pa_as, &cval, 1, addr) != 1)
      945 +                return (1);
      946 +
      947 +        if (mdb.m_flags & MDB_FL_ADB)
      948 +                s = strchr2adb(&cval, 1);
      949 +        else
      950 +                s = strchr2esc(&cval, 1);
      951 +
      952 +        mdb_printf("'%s'", s);
      953 +        strfree(s);
      954 +        return (0);
      955 +}
      956 +
      957 +/*
 934  958   * Print out a character or integer value.  We use some simple heuristics,
 935  959   * described below, to determine the appropriate radix to use for output.
 936  960   */
 937  961  static int
 938  962  print_int_val(const char *type, ctf_encoding_t *ep, ulong_t off,
 939  963      printarg_t *pap)
 940  964  {
 941  965          static const char *const sformat[] = { "%#d", "%#d", "%#d", "%#lld" };
 942  966          static const char *const uformat[] = { "%#u", "%#u", "%#u", "%#llu" };
 943  967          static const char *const xformat[] = { "%#x", "%#x", "%#x", "%#llx" };
↓ open down ↓ 20 lines elided ↑ open up ↑
 964  988          }
 965  989  
 966  990          /*
 967  991           * If the size is not a power-of-two number of bytes in the range 1-8
 968  992           * then we assume it is a bitfield and print it as such.
 969  993           */
 970  994          size = ep->cte_bits / NBBY;
 971  995          if (size > 8 || (ep->cte_bits % NBBY) != 0 || (size & (size - 1)) != 0)
 972  996                  return (print_bitfield(off, pap, ep));
 973  997  
 974      -        if (IS_CHAR(*ep)) {
 975      -                mdb_printf("'");
 976      -                if (mdb_fmt_print(pap->pa_tgt, pap->pa_as,
 977      -                    addr, 1, 'C') == addr)
 978      -                        return (1);
 979      -                mdb_printf("'");
 980      -                return (0);
 981      -        }
      998 +        if (IS_CHAR(*ep))
      999 +                return (print_char_val(addr, pap));
 982 1000  
 983 1001          if (mdb_tgt_aread(pap->pa_tgt, pap->pa_as, &u.i8, size, addr) != size) {
 984 1002                  mdb_warn("failed to read %lu bytes at %llx",
 985 1003                      (ulong_t)size, addr);
 986 1004                  return (1);
 987 1005          }
 988 1006  
 989 1007          /*
 990 1008           * We pretty-print some integer based types.  time_t values are
 991 1009           * printed as a calendar date and time, and IPv4 addresses as human
↓ open down ↓ 2194 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX