Home | History | Annotate | Line # | Download | only in gdbscripts
lwps revision 1.4
      1  1.4   yamt #	$NetBSD: lwps,v 1.4 2011/02/05 14:12:05 yamt Exp $
      2  1.1     ad 
      3  1.1     ad define lwps
      4  1.1     ad 	set $i = 0
      5  1.1     ad 
      6  1.1     ad 	while ($i < 2)
      7  1.1     ad 		if ($i == 0)
      8  1.1     ad 			set $p = allproc.lh_first
      9  1.1     ad 		end
     10  1.1     ad 		if ($p)
     11  1.1     ad 			printf "\t     lwp   pid   lid     flag            wchan\n"
     12  1.1     ad 		end
     13  1.1     ad 		while ($p)
     14  1.1     ad 			set $l = $p->p_lwps.lh_first
     15  1.1     ad 			set $j = 0
     16  1.1     ad 			while ($j < $p->p_nlwps)
     17  1.4   yamt 				printf "0x%016lx %5d %5d %8x 0x%016lx", \
     18  1.1     ad 					$l, $p->p_pid, $l->l_lid, $l->l_flag, $l->l_wchan
     19  1.1     ad 				if ($l->l_wmesg)
     20  1.1     ad 					printf " (%s)", (char *)$l->l_wmesg
     21  1.3    eeh # If the preceding command cannot dereference the pointer, use this instead:
     22  1.3    eeh #					printf " (%lx)", $l->l_wmesg
     23  1.1     ad 				end
     24  1.2  skrll 				set $l = $l->l_sibling.le_next
     25  1.1     ad 				printf "\n"
     26  1.1     ad 				set $j++
     27  1.1     ad 			end
     28  1.1     ad 			set $p = $p->p_list.le_next
     29  1.1     ad 		end
     30  1.1     ad 		set $i++
     31  1.1     ad 	end
     32  1.1     ad end
     33  1.3    eeh document lwps
     34  1.3    eeh ps for lwps
     35  1.3    eeh end
     36  1.3    eeh 
     37  1.3    eeh define threadlist
     38  1.3    eeh 	set $i = 0
     39  1.3    eeh 
     40  1.3    eeh 	while ($i < 2)
     41  1.3    eeh 		if ($i == 0)
     42  1.3    eeh 			set $p = allproc.lh_first
     43  1.3    eeh 		end
     44  1.3    eeh 		while ($p)
     45  1.3    eeh 			set $l = $p->p_lwps.lh_first
     46  1.3    eeh 			set $j = 0
     47  1.3    eeh 			while ($j < $p->p_nlwps)
     48  1.3    eeh 			        printf "\n"
     49  1.3    eeh 			printf "proc: %16lx %5d %8x %4x %5d %16lx %s", \
     50  1.3    eeh 				$p, $p->p_pid, \
     51  1.3    eeh 				$p->p_flag, $p->p_stat, $p->p_nlwps, $p->p_lwps.lh_first, \
     52  1.3    eeh 				(char *) $p->p_comm
     53  1.3    eeh 			printf "\n"
     54  1.3    eeh 				printf "Thread: %16lx %5d %5d %8x %16lx\n", \
     55  1.3    eeh 					$l, $p->p_pid, $l->l_lid, $l->l_flag, $l->l_wchan
     56  1.3    eeh 			        kvm proc $l
     57  1.3    eeh 				where
     58  1.3    eeh 			        printf "\n"
     59  1.3    eeh 			        printf "\n"
     60  1.3    eeh 				set $l = $l->l_sibling.le_next
     61  1.3    eeh 				set $j++
     62  1.3    eeh 		end
     63  1.3    eeh 			set $p = $p->p_list.le_next
     64  1.3    eeh 		end
     65  1.3    eeh 		set $i++
     66  1.3    eeh 	end
     67  1.3    eeh end
     68  1.3    eeh document threadlist
     69  1.3    eeh Print out the stack of all threads in the system.
     70  1.3    eeh end
     71  1.3    eeh 
     72  1.3    eeh define lock
     73  1.3    eeh 	set $ld = (struct lockdebug *)ld_rb_tree
     74  1.3    eeh 	set $a = $ld->ld_lock
     75  1.3    eeh 	set $b = (volatile void *)$arg0
     76  1.3    eeh 
     77  1.3    eeh 	while ($ld && $a != $b)
     78  1.3    eeh 		if ($a < $b) 
     79  1.3    eeh 			set $ld = (struct lockdebug *)$ld->ld_rb_node.rb_nodes[1]
     80  1.3    eeh 		end
     81  1.3    eeh 		if ($a > $b) 
     82  1.3    eeh 			set $ld = (struct lockdebug *)$ld->ld_rb_node.rb_nodes[0]
     83  1.3    eeh 		end
     84  1.3    eeh 		if ($ld == 0)
     85  1.3    eeh 			loop_break
     86  1.3    eeh 		end
     87  1.3    eeh 		set $a = $ld->ld_lock
     88  1.3    eeh # printf "a=%lx b=%lx ld=%lx a<b %d a>b %d\n", $a, $b, $ld,  ($a < $b), ($a > $b)
     89  1.3    eeh 	end
     90  1.3    eeh 	if ($ld)
     91  1.3    eeh 		printf "lock address : %#018lx type     : ", \
     92  1.3    eeh 			(long)$ld->ld_lock
     93  1.3    eeh 		if ($ld->ld_flags & 0x2)
     94  1.3    eeh 			printf "sleep/adaptive\n"
     95  1.3    eeh 		else
     96  1.3    eeh 			printf "spin\n"
     97  1.3    eeh 		end
     98  1.3    eeh 		printf "initialized  : %#018lx", \
     99  1.3    eeh 			(long)$ld->ld_initaddr
    100  1.3    eeh 		if ($ld->ld_lockops->lo_type == 0x2)
    101  1.3    eeh 			printf " interlock: %#018lx\n", $ld->ld_locked
    102  1.3    eeh 		else
    103  1.3    eeh 			printf "\n"
    104  1.3    eeh 			printf "shared holds : %18u exclusive: ", \
    105  1.3    eeh 				$ld->ld_shares
    106  1.3    eeh 			if (($ld->ld_flags & 0x1) != 0)
    107  1.3    eeh 				printf "1\n"
    108  1.3    eeh 			else
    109  1.3    eeh 				printf "0\n"
    110  1.3    eeh 			end
    111  1.3    eeh 			printf "shares wanted: %18u exclusive: %18u\n", \
    112  1.3    eeh 				(unsigned)$ld->ld_shwant, (unsigned)$ld->ld_exwant
    113  1.3    eeh 			printf "cpu last held: %18u\n", \
    114  1.3    eeh 				(unsigned)$ld->ld_cpu
    115  1.3    eeh 			printf "current lwp  : %#018lx last held: %#018lx\n", \
    116  1.3    eeh 				(long)0, (long)$ld->ld_lwp
    117  1.3    eeh 			printf "last locked  : %#018lx unlocked : %#018lx\n", \
    118  1.3    eeh 				(long)$ld->ld_locked, (long)$ld->ld_unlocked
    119  1.3    eeh 		end
    120  1.3    eeh 	end
    121  1.3    eeh end
    122  1.3    eeh document lock
    123  1.3    eeh Print out lockdebug info like ddb does.
    124  1.3    eeh end
    125