Friday Oct 19, 2007

I've been using mdb on a project and thought I'd post some of the dcmds and walkers I have written down here. These are all executed with mdb -k, but most work if you're inspecting a core dump or running kmdb.

Kernel related
::mappings

ktextseg::print
ktextseg::ptable
ktextseg::pte
ktextseg::vatopfn
ktextseg::vtop


0xfffffffffb800000::vatopfn
0xfffffffffb800000::vtop
0xfffffffffb800000::page


::kmem_cachekmastats
::nm
::objects


VM related
::memlist
::memstat
::threadlist


Scheduler/Dispatcher related
::class

CPU related
::cpuinfo
::cpupart
::errorq
::interrupts
::modinfo
::regs


FS related
::fsinfo
::nfs_stat


NUMA related
::lgrp

And here's an example of how it works and how cool this thing is.
We list the existing lgrps in the system with ::lgrps, print the root lgrp using it's virtual address, walk the lgroup's cpu_list with the lgrp_cpulist walker and print one of them.

> ::lgrp   
   LGRPID             ADDR           PARENT         PLATHAND      #CPU      CPUS
        0 fffffffffbc1f610                0          DEFAULT         2      0-1
> fffffffffbc1f610::print
{
    lgrp_id = 0
    lgrp_latency = 0
    lgrp_plathand = 0xbabecafe
    lgrp_parent = 0
    lgrp_reserved1 = 0
    lgrp_childcnt = 0
    lgrp_children = 0
    lgrp_leaves = 0x1
    lgrp_set = [ 0x1, 0x1 ]
    lgrp_mnodes = 0x1
    lgrp_nmnodes = 0x1
    lgrp_reserved2 = 0
    lgrp_cpu = cpus
    lgrp_cpucnt = 0x2
    lgrp_kstat = 0xfffffffec0440330
}
> fffffffffbc1f610::walk lgrp_cpulist
fffffffffbc26b30
fffffffec113b800
> fffffffffbc26b30
> fffffffffbc26b30::print 
[
    {
        cpu_id = 0
        cpu_seqid = 0
        cpu_flags = 0x1b
        cpu_self = cpus
        cpu_thread = 0xfffffffec6d894a0
        cpu_idle_thread = 0xffffff0002005c80
        cpu_pause_thread = 0xffffff00022abc80
        cpu_lwp = 0xfffffffec56e18b0
        cpu_fpowner = 0
        cpu_part = cp_default
        ...


And the always helpful ::whatis dcmd, describing what's on a given address.

> fffffffffbc26b30::whatis
fffffffffbc26b30 is cpus+0 in unix's data segment


This blog copyright 2009 by rv