lwps revision 1.4
11.4Syamt# $NetBSD: lwps,v 1.4 2011/02/05 14:12:05 yamt Exp $ 21.1Sad 31.1Saddefine lwps 41.1Sad set $i = 0 51.1Sad 61.1Sad while ($i < 2) 71.1Sad if ($i == 0) 81.1Sad set $p = allproc.lh_first 91.1Sad end 101.1Sad if ($p) 111.1Sad printf "\t lwp pid lid flag wchan\n" 121.1Sad end 131.1Sad while ($p) 141.1Sad set $l = $p->p_lwps.lh_first 151.1Sad set $j = 0 161.1Sad while ($j < $p->p_nlwps) 171.4Syamt printf "0x%016lx %5d %5d %8x 0x%016lx", \ 181.1Sad $l, $p->p_pid, $l->l_lid, $l->l_flag, $l->l_wchan 191.1Sad if ($l->l_wmesg) 201.1Sad printf " (%s)", (char *)$l->l_wmesg 211.3Seeh# If the preceding command cannot dereference the pointer, use this instead: 221.3Seeh# printf " (%lx)", $l->l_wmesg 231.1Sad end 241.2Sskrll set $l = $l->l_sibling.le_next 251.1Sad printf "\n" 261.1Sad set $j++ 271.1Sad end 281.1Sad set $p = $p->p_list.le_next 291.1Sad end 301.1Sad set $i++ 311.1Sad end 321.1Sadend 331.3Seehdocument lwps 341.3Seehps for lwps 351.3Seehend 361.3Seeh 371.3Seehdefine threadlist 381.3Seeh set $i = 0 391.3Seeh 401.3Seeh while ($i < 2) 411.3Seeh if ($i == 0) 421.3Seeh set $p = allproc.lh_first 431.3Seeh end 441.3Seeh while ($p) 451.3Seeh set $l = $p->p_lwps.lh_first 461.3Seeh set $j = 0 471.3Seeh while ($j < $p->p_nlwps) 481.3Seeh printf "\n" 491.3Seeh printf "proc: %16lx %5d %8x %4x %5d %16lx %s", \ 501.3Seeh $p, $p->p_pid, \ 511.3Seeh $p->p_flag, $p->p_stat, $p->p_nlwps, $p->p_lwps.lh_first, \ 521.3Seeh (char *) $p->p_comm 531.3Seeh printf "\n" 541.3Seeh printf "Thread: %16lx %5d %5d %8x %16lx\n", \ 551.3Seeh $l, $p->p_pid, $l->l_lid, $l->l_flag, $l->l_wchan 561.3Seeh kvm proc $l 571.3Seeh where 581.3Seeh printf "\n" 591.3Seeh printf "\n" 601.3Seeh set $l = $l->l_sibling.le_next 611.3Seeh set $j++ 621.3Seeh end 631.3Seeh set $p = $p->p_list.le_next 641.3Seeh end 651.3Seeh set $i++ 661.3Seeh end 671.3Seehend 681.3Seehdocument threadlist 691.3SeehPrint out the stack of all threads in the system. 701.3Seehend 711.3Seeh 721.3Seehdefine lock 731.3Seeh set $ld = (struct lockdebug *)ld_rb_tree 741.3Seeh set $a = $ld->ld_lock 751.3Seeh set $b = (volatile void *)$arg0 761.3Seeh 771.3Seeh while ($ld && $a != $b) 781.3Seeh if ($a < $b) 791.3Seeh set $ld = (struct lockdebug *)$ld->ld_rb_node.rb_nodes[1] 801.3Seeh end 811.3Seeh if ($a > $b) 821.3Seeh set $ld = (struct lockdebug *)$ld->ld_rb_node.rb_nodes[0] 831.3Seeh end 841.3Seeh if ($ld == 0) 851.3Seeh loop_break 861.3Seeh end 871.3Seeh set $a = $ld->ld_lock 881.3Seeh# printf "a=%lx b=%lx ld=%lx a<b %d a>b %d\n", $a, $b, $ld, ($a < $b), ($a > $b) 891.3Seeh end 901.3Seeh if ($ld) 911.3Seeh printf "lock address : %#018lx type : ", \ 921.3Seeh (long)$ld->ld_lock 931.3Seeh if ($ld->ld_flags & 0x2) 941.3Seeh printf "sleep/adaptive\n" 951.3Seeh else 961.3Seeh printf "spin\n" 971.3Seeh end 981.3Seeh printf "initialized : %#018lx", \ 991.3Seeh (long)$ld->ld_initaddr 1001.3Seeh if ($ld->ld_lockops->lo_type == 0x2) 1011.3Seeh printf " interlock: %#018lx\n", $ld->ld_locked 1021.3Seeh else 1031.3Seeh printf "\n" 1041.3Seeh printf "shared holds : %18u exclusive: ", \ 1051.3Seeh $ld->ld_shares 1061.3Seeh if (($ld->ld_flags & 0x1) != 0) 1071.3Seeh printf "1\n" 1081.3Seeh else 1091.3Seeh printf "0\n" 1101.3Seeh end 1111.3Seeh printf "shares wanted: %18u exclusive: %18u\n", \ 1121.3Seeh (unsigned)$ld->ld_shwant, (unsigned)$ld->ld_exwant 1131.3Seeh printf "cpu last held: %18u\n", \ 1141.3Seeh (unsigned)$ld->ld_cpu 1151.3Seeh printf "current lwp : %#018lx last held: %#018lx\n", \ 1161.3Seeh (long)0, (long)$ld->ld_lwp 1171.3Seeh printf "last locked : %#018lx unlocked : %#018lx\n", \ 1181.3Seeh (long)$ld->ld_locked, (long)$ld->ld_unlocked 1191.3Seeh end 1201.3Seeh end 1211.3Seehend 1221.3Seehdocument lock 1231.3SeehPrint out lockdebug info like ddb does. 1241.3Seehend 125