Print this page
11584 ::xcall would be useful
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/i86pc/modules/unix/unix.c
          +++ new/usr/src/cmd/mdb/i86pc/modules/unix/unix.c
↓ open down ↓ 794 lines elided ↑ open up ↑
 795  795   * but for amusement, the reader is directed to the comment that explains
 796  796   * the rationale for this particular value on x86.  Spoiler:  the value is
 797  797   * selected to accommodate 60 MHz Pentiums!  (And a confession:  if the voice
 798  798   * in that comment sounds too familiar, it's because your author also wrote
 799  799   * that code -- some fifteen years prior to this writing in 2011...)
 800  800   */
 801  801  #define NSEC_SHIFT 5
 802  802  
 803  803  /*ARGSUSED*/
 804  804  static int
 805      -scalehrtime_cmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
      805 +scalehrtime_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 806  806  {
 807  807          uint32_t nsec_scale;
 808  808          hrtime_t tsc = addr, hrt, tsc_last, base, mult = 1;
 809  809          unsigned int *tscp = (unsigned int *)&tsc;
 810  810          uintptr_t scalehrtimef;
 811  811          uint64_t scale;
 812  812          GElf_Sym sym;
 813  813          int expected = !(flags & DCMD_ADDRSPEC);
 814  814          uint_t absolute = FALSE, relative = FALSE;
 815  815  
↓ open down ↓ 81 lines elided ↑ open up ↑
 897  897  }
 898  898  
 899  899  /*
 900  900   * The x86 feature set is implemented as a bitmap array. That bitmap array is
 901  901   * stored across a number of uchars based on the BT_SIZEOFMAP(NUM_X86_FEATURES)
 902  902   * macro. We have the names for each of these features in unix's text segment
 903  903   * so we do not have to duplicate them and instead just look them up.
 904  904   */
 905  905  /*ARGSUSED*/
 906  906  static int
 907      -x86_featureset_cmd(uintptr_t addr, uint_t flags, int argc,
      907 +x86_featureset_dcmd(uintptr_t addr, uint_t flags, int argc,
 908  908      const mdb_arg_t *argv)
 909  909  {
 910  910          void *fset;
 911  911          GElf_Sym sym;
 912  912          uintptr_t nptr;
 913  913          char name[128];
 914  914          int ii;
 915  915  
 916  916          size_t sz = sizeof (uchar_t) * BT_SIZEOFMAP(NUM_X86_FEATURES);
 917  917  
↓ open down ↓ 110 lines elided ↑ open up ↑
1028 1028  
1029 1029          mdb_printf("%%cr4 = 0x%lx <%b>\n", cr4, cr4, cr4_flag_bits);
1030 1030  
1031 1031          mdb_printf("%%gdtr.base = 0x%lx, %%gdtr.limit = 0x%hx\n",
1032 1032              gdtr.dtr_base, gdtr.dtr_limit);
1033 1033  
1034 1034          return (DCMD_OK);
1035 1035  }
1036 1036  #endif
1037 1037  
     1038 +extern void xcall_help(void);
     1039 +extern int xcall_dcmd(uintptr_t, uint_t, int, const mdb_arg_t *);
     1040 +
1038 1041  static const mdb_dcmd_t dcmds[] = {
1039 1042          { "gate_desc", ":", "dump a gate descriptor", gate_desc },
1040 1043          { "idt", ":[-v]", "dump an IDT", idt },
1041 1044          { "ttrace", "[-x] [-t kthread]", "dump trap trace buffers", ttrace },
1042 1045          { "vatopfn", ":[-a as]", "translate address to physical page",
1043 1046              va2pfn_dcmd },
1044 1047          { "report_maps", ":[-m]",
1045 1048              "Given PFN, report mappings / page table usage",
1046 1049              report_maps_dcmd, report_maps_help },
1047 1050          { "htables", "", "Given hat_t *, lists all its htable_t * values",
↓ open down ↓ 3 lines elided ↑ open up ↑
1051 1054          { "ptmap", ":", "Given a cr3 value, dump all mappings",
1052 1055              ptmap_dcmd, ptmap_help },
1053 1056          { "pte", ":[-l N]", "print human readable page table entry",
1054 1057              pte_dcmd },
1055 1058          { "pfntomfn", ":", "convert physical page to hypervisor machine page",
1056 1059              pfntomfn_dcmd },
1057 1060          { "mfntopfn", ":", "convert hypervisor machine page to physical page",
1058 1061              mfntopfn_dcmd },
1059 1062          { "memseg_list", ":", "show memseg list", memseg_list },
1060 1063          { "scalehrtime", ":[-a|-r]", "scale an unscaled high-res time",
1061      -            scalehrtime_cmd, scalehrtime_help },
     1064 +            scalehrtime_dcmd, scalehrtime_help },
1062 1065          { "x86_featureset", NULL, "dump the x86_featureset vector",
1063      -                x86_featureset_cmd },
     1066 +                x86_featureset_dcmd },
     1067 +        { "xcall", ":", "print CPU cross-call state", xcall_dcmd, xcall_help },
1064 1068  #ifdef _KMDB
1065 1069          { "sysregs", NULL, "dump system registers", sysregs_dcmd },
1066 1070  #endif
1067 1071          { NULL }
1068 1072  };
1069 1073  
1070 1074  static const mdb_walker_t walkers[] = {
1071 1075          { "ttrace", "walks trap trace buffers in reverse chronological order",
1072 1076                  ttrace_walk_init, ttrace_walk_step, ttrace_walk_fini },
1073 1077          { "mutex_owner", "walks the owner of a mutex",
↓ open down ↓ 19 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX