kvm Library

sergev edited this page Nov 15, 2014 · 11 revisions

Utilities like ps or vmstat use kvm library to get data from kernel. Traditionally, the library scanned /vmunix binary file for a list of kernel symbols and their addresses in memory. In case of embedded system, the kernel resides in flash memory, and is not present in the filesystem anymore. A solution is to modify the kvm library and kernel, to get symbol addresses from the kernel itself by utilizing sysctl() interface.

Here is a list of all utilities and kernel symbols to be exported via sysctl() call.

Source file Kernel symbols
lib/libkvm/kvm_file.c _filehead
_nfiles
lib/libkvm/kvm_getloadavg.c _averunnable
_fscale
lib/libkvm/kvm_proc.c _nprocs
_allproc
_zombproc
lib/libkvm/kvm_mips.c Sysmap
Sysmapsize
lib/libkvm/bin/ps/nlist.c _fscale
_ccpu
_avail_start
_avail_end
sbin/dmesg/dmesg.c _msgbufp
usr.bin/netstat/main.c _icmpstat
_ifnet
_igmpstat
_ip_mrtproto
_ipstat
_mbstat
_mrtstat
_mrttable
_rtstat
_rt_tables
_tcb
_tcpstat
_udb
_udpstat
_unixsw
_viftable
usr.bin/nfsstat/nfsstat.c _nfsstats
usr.bin/systat/disks.c _dk_ndrive
_dk_wpms
_scsi_dinit
usr.bin/systat/iostat.c _dk_busy
_dk_time
_dk_xfer
_dk_wds
_dk_seek
_cp_time
usr.bin/systat/main.c _hz
_stathz
usr.bin/systat/mbufs.c _mbstat
usr.bin/systat/netstat.c _tcb
_udb
usr.bin/systat/pigs.c _cp_time
_ccpu
_fscale
usr.bin/systat/swap.c _swapmap
_nswapmap
_swdevt
_nswap
_nswdev
_dmmax
usr.bin/systat/vmstat.c _cp_time
_cnt
_total
_dk_busy
_dk_time
_dk_xfer
_dk_wds
_dk_seek
_nchstats
_intrnames
_eintrnames
_intrcnt
_eintrcnt
usr.bin/vmstat/vmstat.c _cp_time
_dk_ndrive
_cnt
_boottime
_dk_xfer
_hz
_stathz
_nchstats
_intrnames
_eintrnames
_intrcnt
_eintrcnt
_kmemstats
_bucket
_scsi_dinit
usr.sbin/iostat/iostat.c _dk_time
_dk_xfer
_dk_wds
_tk_nin
_tk_nout
_dk_seek
_cp_time
_dk_wpms
_hz
_stathz
_dk_ndrive
_scsi_dinit
usr.sbin/kgmon/kgmon.c __gmonparam
_profhz
usr.sbin/pstat/pstat.c _swapmap
_nswapmap
_swdevt
_nswap
_nswdev
_dmmax
_mountlist
_numvnodes
_nfiles
_maxfiles
_niswap
_niswdev
_cons
_pt_tty
_npty
_uart_tty
_uart_cnt