Print this page
9210 remove KMDB branch debugging support
9211 ::crregs could do with cr2/cr3 support
9209 ::ttrace should be able to filter by thread
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>

*** 18,28 **** * * CDDL HEADER END */ /* * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. ! * Copyright 2015 Joyent, Inc. */ #include <mdb/mdb_modapi.h> #include <mdb/mdb_ctf.h> #include <sys/cpuvar.h> --- 18,28 ---- * * CDDL HEADER END */ /* * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. ! * Copyright 2018 Joyent, Inc. */ #include <mdb/mdb_modapi.h> #include <mdb/mdb_ctf.h> #include <sys/cpuvar.h>
*** 407,416 **** --- 407,417 ---- }; typedef struct ttrace_dcmd { processorid_t ttd_cpu; uint_t ttd_extended; + uintptr_t ttd_kthread; trap_trace_ctl_t ttd_ttc[NCPU]; } ttrace_dcmd_t; #if defined(__amd64)
*** 476,485 **** --- 477,490 ---- } if (dcmd->ttd_cpu != -1 && cpu != dcmd->ttd_cpu) return (WALK_NEXT); + if (dcmd->ttd_kthread != 0 && + dcmd->ttd_kthread != rec->ttr_curthread) + return (WALK_NEXT); + mdb_printf("%3d %15llx ", cpu, rec->ttr_stamp); for (i = 0; ttrace_hdlr[i].t_hdlr != NULL; i++) { if (rec->ttr_marker != ttrace_hdlr[i].t_marker) continue;
*** 535,545 **** "non-TRAPTRACE kernel?\n"); return (DCMD_ERR); } if (mdb_getopts(argc, argv, ! 'x', MDB_OPT_SETBITS, TRUE, &dcmd.ttd_extended, NULL) != argc) return (DCMD_USAGE); if (DCMD_HDRSPEC(flags)) { mdb_printf("%3s %15s %4s %2s %-*s%s\n", "CPU", "TIMESTAMP", "TYPE", "Vec", TT_HDLR_WIDTH, "HANDLER", --- 540,551 ---- "non-TRAPTRACE kernel?\n"); return (DCMD_ERR); } if (mdb_getopts(argc, argv, ! 'x', MDB_OPT_SETBITS, TRUE, &dcmd.ttd_extended, ! 't', MDB_OPT_UINTPTR, &dcmd.ttd_kthread, NULL) != argc) return (DCMD_USAGE); if (DCMD_HDRSPEC(flags)) { mdb_printf("%3s %15s %4s %2s %-*s%s\n", "CPU", "TIMESTAMP", "TYPE", "Vec", TT_HDLR_WIDTH, "HANDLER",
*** 884,894 **** #ifdef _KMDB /* ARGSUSED */ static int crregs_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { ! ulong_t cr0, cr4; static const mdb_bitmask_t cr0_flag_bits[] = { { "PE", CR0_PE, CR0_PE }, { "MP", CR0_MP, CR0_MP }, { "EM", CR0_EM, CR0_EM }, { "TS", CR0_TS, CR0_TS }, --- 890,900 ---- #ifdef _KMDB /* ARGSUSED */ static int crregs_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { ! ulong_t cr0, cr2, cr3, cr4; static const mdb_bitmask_t cr0_flag_bits[] = { { "PE", CR0_PE, CR0_PE }, { "MP", CR0_MP, CR0_MP }, { "EM", CR0_EM, CR0_EM }, { "TS", CR0_TS, CR0_TS },
*** 900,909 **** --- 906,921 ---- { "CD", CR0_CD, CR0_CD }, { "PG", CR0_PG, CR0_PG }, { NULL, 0, 0 } }; + static const mdb_bitmask_t cr3_flag_bits[] = { + { "PCD", CR3_PCD, CR3_PCD }, + { "PWT", CR3_PWT, CR3_PWT }, + { NULL, 0, 0, } + }; + static const mdb_bitmask_t cr4_flag_bits[] = { { "VME", CR4_VME, CR4_VME }, { "PVI", CR4_PVI, CR4_PVI }, { "TSD", CR4_TSD, CR4_TSD }, { "DE", CR4_DE, CR4_DE },
*** 914,941 **** { "PCE", CR4_PCE, CR4_PCE }, { "OSFXSR", CR4_OSFXSR, CR4_OSFXSR }, { "OSXMMEXCPT", CR4_OSXMMEXCPT, CR4_OSXMMEXCPT }, { "VMXE", CR4_VMXE, CR4_VMXE }, { "SMXE", CR4_SMXE, CR4_SMXE }, { "OSXSAVE", CR4_OSXSAVE, CR4_OSXSAVE }, { "SMEP", CR4_SMEP, CR4_SMEP }, { "SMAP", CR4_SMAP, CR4_SMAP }, { NULL, 0, 0 } }; cr0 = kmdb_unix_getcr0(); cr4 = kmdb_unix_getcr4(); mdb_printf("%%cr0 = 0x%08x <%b>\n", cr0, cr0, cr0_flag_bits); mdb_printf("%%cr4 = 0x%08x <%b>\n", cr4, cr4, cr4_flag_bits); return (DCMD_OK); } #endif static const mdb_dcmd_t dcmds[] = { { "gate_desc", ":", "dump a gate descriptor", gate_desc }, { "idt", ":[-v]", "dump an IDT", idt }, ! { "ttrace", "[-x]", "dump trap trace buffers", ttrace }, { "vatopfn", ":[-a as]", "translate address to physical page", va2pfn_dcmd }, { "report_maps", ":[-m]", "Given PFN, report mappings / page table usage", report_maps_dcmd, report_maps_help }, --- 926,967 ---- { "PCE", CR4_PCE, CR4_PCE }, { "OSFXSR", CR4_OSFXSR, CR4_OSFXSR }, { "OSXMMEXCPT", CR4_OSXMMEXCPT, CR4_OSXMMEXCPT }, { "VMXE", CR4_VMXE, CR4_VMXE }, { "SMXE", CR4_SMXE, CR4_SMXE }, + { "PCIDE", CR4_PCIDE, CR4_PCIDE }, { "OSXSAVE", CR4_OSXSAVE, CR4_OSXSAVE }, { "SMEP", CR4_SMEP, CR4_SMEP }, { "SMAP", CR4_SMAP, CR4_SMAP }, { NULL, 0, 0 } }; cr0 = kmdb_unix_getcr0(); + cr2 = kmdb_unix_getcr2(); + cr3 = kmdb_unix_getcr3(); cr4 = kmdb_unix_getcr4(); mdb_printf("%%cr0 = 0x%08x <%b>\n", cr0, cr0, cr0_flag_bits); + mdb_printf("%%cr2 = 0x%08x <%a>\n", cr2, cr2); + + if ((cr4 & CR4_PCIDE)) { + mdb_printf("%%cr3 = 0x%08x <pfn:%lu pcid:%u>\n", + cr3 >> MMU_PAGESHIFT, cr3 & MMU_PAGEOFFSET); + } else { + mdb_printf("%%cr3 = 0x%08x <pfn:%lu flags:%b>\n", cr3, + cr3 >> MMU_PAGESHIFT, cr3, cr3_flag_bits); + } + mdb_printf("%%cr4 = 0x%08x <%b>\n", cr4, cr4, cr4_flag_bits); + return (DCMD_OK); } #endif static const mdb_dcmd_t dcmds[] = { { "gate_desc", ":", "dump a gate descriptor", gate_desc }, { "idt", ":[-v]", "dump an IDT", idt }, ! { "ttrace", "[-x] [-t kthread]", "dump trap trace buffers", ttrace }, { "vatopfn", ":[-a as]", "translate address to physical page", va2pfn_dcmd }, { "report_maps", ":[-m]", "Given PFN, report mappings / page table usage", report_maps_dcmd, report_maps_help },