CVS commit: src/sys/gdbscripts

2020-05-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  2 12:58:46 UTC 2020

Modified Files:
src/sys/gdbscripts: modload

Log Message:
gdb has been fixed, so no need to reload the symbol file.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/gdbscripts/modload

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/modload
diff -u src/sys/gdbscripts/modload:1.2 src/sys/gdbscripts/modload:1.3
--- src/sys/gdbscripts/modload:1.2	Fri May  1 13:00:42 2020
+++ src/sys/gdbscripts/modload	Sat May  2 08:58:46 2020
@@ -1,7 +1,5 @@
-# $NetBSD: modload,v 1.2 2020/05/01 17:00:42 christos Exp $
+# $NetBSD: modload,v 1.3 2020/05/02 12:58:46 christos Exp $
 # Load the symbol files for all active modules
-# Note that you need to re-run add-symbol-file netbsd.gdb after you
-# load the modules.
 define modload
 	set $h = module_list
 	set $e = $h.tqh_first



CVS commit: src/sys/gdbscripts

2020-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri May  1 17:00:43 UTC 2020

Modified Files:
src/sys/gdbscripts: modload

Log Message:
mention the need to reload the kernel symbols


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/gdbscripts/modload

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/modload
diff -u src/sys/gdbscripts/modload:1.1 src/sys/gdbscripts/modload:1.2
--- src/sys/gdbscripts/modload:1.1	Tue Apr 28 15:45:58 2020
+++ src/sys/gdbscripts/modload	Fri May  1 13:00:42 2020
@@ -1,5 +1,7 @@
-# $NetBSD: modload,v 1.1 2020/04/28 19:45:58 christos Exp $
+# $NetBSD: modload,v 1.2 2020/05/01 17:00:42 christos Exp $
 # Load the symbol files for all active modules
+# Note that you need to re-run add-symbol-file netbsd.gdb after you
+# load the modules.
 define modload
 	set $h = module_list
 	set $e = $h.tqh_first



CVS commit: src/sys/gdbscripts

2020-04-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 28 19:45:58 UTC 2020

Added Files:
src/sys/gdbscripts: modload

Log Message:
add a script to load the symbol files of all the modules in the kernel


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/gdbscripts/modload

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/gdbscripts/modload
diff -u /dev/null src/sys/gdbscripts/modload:1.1
--- /dev/null	Tue Apr 28 15:45:58 2020
+++ src/sys/gdbscripts/modload	Tue Apr 28 15:45:58 2020
@@ -0,0 +1,14 @@
+# $NetBSD: modload,v 1.1 2020/04/28 19:45:58 christos Exp $
+# Load the symbol files for all active modules
+define modload
+	set $h = module_list
+	set $e = $h.tqh_first
+	while ($e != 0)
+		if ($e->mod_kobj != 0)
+			set $ko = $e->mod_kobj
+			set $n = $e->mod_info.mi_name
+			eval "add-symbol-file %s/%s/%s.kmod -s .text 0x%lx -s .data 0x%lx -s .rodata 0x%lx\n", module_base, $n, $n, $ko->ko_text_address, $ko->ko_data_address, $ko->ko_rodata_address
+		end
+		set $e = $e->mod_chain.tqe_next
+	end
+end



CVS commit: src/sys/gdbscripts

2020-04-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr 27 20:31:11 UTC 2020

Modified Files:
src/sys/gdbscripts: module

Log Message:
make this work again


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/gdbscripts/module

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/module
diff -u src/sys/gdbscripts/module:1.2 src/sys/gdbscripts/module:1.3
--- src/sys/gdbscripts/module:1.2	Wed Mar  6 06:26:22 2013
+++ src/sys/gdbscripts/module	Mon Apr 27 16:31:11 2020
@@ -72,10 +72,14 @@ define modules
 	set $e = $h.tqh_first
 	while ($e != 0)
 		if ($e->mod_kobj != 0)
-			printf "module %s\t0x%016lx-0x%016lx\n", \
+			printf "module %s\n\t  text=0x%016lx/%u\n\t  data=0x%016lx/%u\n\trodata=0x%016lx/%u\n", \
 			$e->mod_info.mi_name, \
-			$e->mod_kobj->ko_address, \
-			$e->mod_kobj->ko_address + $e->mod_kobj->ko_size
+			$e->mod_kobj->ko_text_address, \
+			$e->mod_kobj->ko_text_size, \
+			$e->mod_kobj->ko_data_address, \
+			$e->mod_kobj->ko_data_size, \
+			$e->mod_kobj->ko_rodata_address, \
+			$e->mod_kobj->ko_rodata_size
 		else
 			printf "module %s\n", \
 			$e->mod_info.mi_name



CVS commit: src/sys/gdbscripts

2020-04-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 14 13:58:12 UTC 2020

Added Files:
src/sys/gdbscripts: dmesg

Log Message:
Add dmesg functionality.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/gdbscripts/dmesg

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/gdbscripts/dmesg
diff -u /dev/null src/sys/gdbscripts/dmesg:1.1
--- /dev/null	Tue Apr 14 09:58:12 2020
+++ src/sys/gdbscripts/dmesg	Tue Apr 14 09:58:11 2020
@@ -0,0 +1,47 @@
+#	$NetBSD: dmesg,v 1.1 2020/04/14 13:58:11 christos Exp $
+
+define dmesg
+	set $mbp = msgbufp
+	set $bufdata = &$mbp->msg_bufc[0]
+	set $print = $mbp->msg_bufs
+	set $newl = 0
+	set $skip = 0
+	set $i = -1 
+	set $p = $bufdata + $mbp->msg_bufx - 1
+
+	while ($i < $mbp->msg_bufs)
+		set $i = $i + 1
+		set $p = $p + 1
+		if ($p == $bufdata + $mbp->msg_bufs)
+			set $p = $bufdata
+		end
+		if ($i < $mbp->msg_bufs - $print)
+			loop_continue
+		end
+		set $c = $p[0]
+		# Skip syslog sequences
+		if ($skip)
+			if ($c == '>')
+set $newl = 0
+set $skip = 0
+			end
+			loop_continue
+		end
+		if ($newl && $c == '<')
+			set $skip = 1
+			loop_continue
+		end
+		if ($c == '\0')
+			loop_continue
+		end
+		set $newl = $c == '\n'
+		printf "%c", $c
+	end
+	if (!$newl)
+		printf "\n"
+	end
+end
+
+document dmesg
+print the message buffer
+end



CVS commit: src/sys/gdbscripts

2020-04-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 14 00:08:07 UTC 2020

Modified Files:
src/sys/gdbscripts: vdump

Log Message:
catch up with field move


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/gdbscripts/vdump

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/vdump
diff -u src/sys/gdbscripts/vdump:1.6 src/sys/gdbscripts/vdump:1.7
--- src/sys/gdbscripts/vdump:1.6	Wed Dec 14 10:48:55 2016
+++ src/sys/gdbscripts/vdump	Mon Apr 13 20:08:07 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: vdump,v 1.6 2016/12/14 15:48:55 hannken Exp $
+#	$NetBSD: vdump,v 1.7 2020/04/14 00:08:07 christos Exp $
 
 #	@(#)vdump	8.1 (Berkeley) 6/10/93
 #
@@ -8,7 +8,7 @@ define dumpvnodes
 	set $vp = (struct vnode *)$arg0
 	set $vi = (struct vnode_impl *)$arg0
 	while ($vp)
-		printf "vnode=0x%x lruf=0x%x mountf=0x%x usecount=%d\n", $vp, $vi->vi_lrulist.tqe_next, $vp->v_mntvnodes.tqe_next, $vp->v_uobj.uo_refs
+		printf "vnode=0x%x lruf=0x%x mountf=0x%x usecount=%d\n", $vp, $vi->vi_lrulist.tqe_next, $vi->vi_mntvnodes.tqe_next, $vp->v_uobj.uo_refs
 		set $vi = (struct vnode_impl *)$vi->vi_lrulist.tqe_next
 		set $vp = (struct vnode *)$vi
 	end



CVS commit: src/sys/gdbscripts

2019-12-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec  6 02:37:53 UTC 2019

Modified Files:
src/sys/gdbscripts: vchain

Log Message:
more updates for the vnode and mount list iterator changes
that happened a while back.  also, port to 64 bit properly.
now these all appear to work again.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/gdbscripts/vchain

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/vchain
diff -u src/sys/gdbscripts/vchain:1.10 src/sys/gdbscripts/vchain:1.11
--- src/sys/gdbscripts/vchain:1.10	Fri Dec  6 01:01:02 2019
+++ src/sys/gdbscripts/vchain	Fri Dec  6 02:37:53 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: vchain,v 1.10 2019/12/06 01:01:02 mrg Exp $
+#	$NetBSD: vchain,v 1.11 2019/12/06 02:37:53 mrg Exp $
 
 #	@(#)vchain	8.1 (Berkeley) 6/10/93
 #
@@ -6,14 +6,15 @@
 define vchain
 	set $num = 0
 
-	set $vp=(struct vnode *)$arg0
-	set $vi=(struct vnode_impl *)$arg0
-	while ($vp)
-		printf "vp: 0x%lx lrulist_next: 0x%lx usecount: %d flags: i:0x%x v:0x%x u:0x%x\n",\
-		   $vp, $vi->vi_lrulist.tqe_next, $vp->v_uobj.uo_refs, \
+	set $vi = (struct vnode_impl *)$arg0
+	printf "lrulist_next: 0x%lx\n", $vi->vi_lrulist.tqe_next
+	while ($vi)
+		set $vp = &$vi->vi_vnode
+		printf "vp: 0x%lx usecount: %d flags: i:0x%x v:0x%x u:0x%x\n",\
+		   $vp, $vp->v_uobj.uo_refs, \
 		   $vp->v_iflag, $vp->v_vflag, $vp->v_uflag
 		set $num++
-		set $vp = $vp->v_mntvnodes.tqe_next
+		set $vi = $vi->vi_mntvnodes.tqe_next
 	end
 	printf "Number of vnodes: %d\n", $num
 end
@@ -28,23 +29,26 @@ define vprint
 end
 
 define mp_vchain
-	set $mp = (struct mount *)$arg0
-	vchain $mp->mnt_vnodelist.tqh_first
+	set $mp = $arg0->me_mount
+	set $first = $mp->mnt_vnodelist.tqh_first
+	if ($first)
+		vchain $mp->mnt_vnodelist.tqh_first
+	end
 end
 document mp_vchain
 print the vnode chain for a given mount point
 end
 
 define vall
-	set $mp=mountlist.tqh_first
-	while ($mp)
-		printf "\tmount point at 0x%x\n", $mp
-		mp_vchain $mp
-		set $mp=$mp->mnt_list.tqe_next
+	set $mpe=mountlist.tqh_first
+	while ($mpe)
+		printf "\tmount point at 0x%lx\n", $mpe
+		mp_vchain $mpe
+		set $mpe = $mpe->me_list.tqe_next
 
 		# "break"
-		if ((const void *)$mp == (const void *))
-			set $mp = 0
+		if ((const void *)$mpe == (const void *))
+			set $mpe = 0
 		end
 	end
 end
@@ -57,7 +61,7 @@ define mountdump
 	while ($me)
 		if ($me->me_type == ME_MOUNT)
 			set $mp = $me->me_mount
-			printf "%s on %s type %s, (mp 0x%x, privdata 0x%x)\n", \
+			printf "%s on %s type %s, (mp 0x%lx, privdata 0x%lx)\n", \
 			$mp->mnt_stat->f_mntfromname, \
 			$mp->mnt_stat->f_mntonname, \
 			$mp->mnt_op->vfs_name, $mp, $mp->mnt_data



CVS commit: src/sys/gdbscripts

2019-12-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec  6 01:01:02 UTC 2019

Modified Files:
src/sys/gdbscripts: vchain

Log Message:
it's mountlist not mount_list.  now 'mountdump' works again.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/gdbscripts/vchain

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/vchain
diff -u src/sys/gdbscripts/vchain:1.9 src/sys/gdbscripts/vchain:1.10
--- src/sys/gdbscripts/vchain:1.9	Thu Apr 13 09:52:18 2017
+++ src/sys/gdbscripts/vchain	Fri Dec  6 01:01:02 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: vchain,v 1.9 2017/04/13 09:52:18 hannken Exp $
+#	$NetBSD: vchain,v 1.10 2019/12/06 01:01:02 mrg Exp $
 
 #	@(#)vchain	8.1 (Berkeley) 6/10/93
 #
@@ -53,7 +53,7 @@ print vnode chains for all mount points
 end
 
 define mountdump
-	set $me=mount_list.tqh_first
+	set $me=mountlist.tqh_first
 	while ($me)
 		if ($me->me_type == ME_MOUNT)
 			set $mp = $me->me_mount
@@ -63,7 +63,7 @@ define mountdump
 			$mp->mnt_op->vfs_name, $mp, $mp->mnt_data
 		end
 		set $me=$me->me_list.tqe_next
-		if ((const void *)$me == (const void *)_list)
+		if ((const void *)$me == (const void *))
 			set $me = 0
 		end
 	end



CVS commit: src/sys/gdbscripts

2019-05-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu May  9 07:59:49 UTC 2019

Modified Files:
src/sys/gdbscripts: devs procs

Log Message:
document 'devs' and 'procs' commands.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/gdbscripts/devs
cvs rdiff -u -r1.3 -r1.4 src/sys/gdbscripts/procs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/devs
diff -u src/sys/gdbscripts/devs:1.1 src/sys/gdbscripts/devs:1.2
--- src/sys/gdbscripts/devs:1.1	Mon May  6 02:41:02 2019
+++ src/sys/gdbscripts/devs	Thu May  9 07:59:49 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: devs,v 1.1 2019/05/06 02:41:02 mrg Exp $
+#	$NetBSD: devs,v 1.2 2019/05/09 07:59:49 mrg Exp $
 
 define devs
 	set $i = 0
@@ -18,3 +18,7 @@ define devs
 		set $i++
 	end
 end
+document devs
+dump a list of all devices known on the system with their name,
+and these pointers: this device, parent device, device private.
+end

Index: src/sys/gdbscripts/procs
diff -u src/sys/gdbscripts/procs:1.3 src/sys/gdbscripts/procs:1.4
--- src/sys/gdbscripts/procs:1.3	Mon May  6 02:41:02 2019
+++ src/sys/gdbscripts/procs	Thu May  9 07:59:49 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: procs,v 1.3 2019/05/06 02:41:02 mrg Exp $
+#	$NetBSD: procs,v 1.4 2019/05/09 07:59:49 mrg Exp $
 
 define procs
 	set $i = 0
@@ -20,3 +20,8 @@ define procs
 		set $i++
 	end
 end
+document procs
+list all processes.
+displays struct proc *, pid, flags, status, nlwps, first lwp addr
+and command name.
+end



CVS commit: src/sys/gdbscripts

2019-05-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon May  6 02:41:02 UTC 2019

Modified Files:
src/sys/gdbscripts: procs
Added Files:
src/sys/gdbscripts: devs

Log Message:
add a 'devs' script to display a list of all devices by device_t,
name, parent, private data.

for procs, put the printf \n into the same line.  non trivial
speed up with large process table.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/gdbscripts/devs
cvs rdiff -u -r1.2 -r1.3 src/sys/gdbscripts/procs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/procs
diff -u src/sys/gdbscripts/procs:1.2 src/sys/gdbscripts/procs:1.3
--- src/sys/gdbscripts/procs:1.2	Wed Nov 18 18:05:51 2009
+++ src/sys/gdbscripts/procs	Mon May  6 02:41:02 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: procs,v 1.2 2009/11/18 18:05:51 eeh Exp $
+#	$NetBSD: procs,v 1.3 2019/05/06 02:41:02 mrg Exp $
 
 define procs
 	set $i = 0
@@ -11,11 +11,10 @@ define procs
 			printf "proc   pid flag stat nlwpslwp  comm\n"
 		end
 		while ($p)
-			printf "%16lx %5d %8x %4x %5d %16lx %s", \
+			printf "%16lx %5d %8x %4x %5d %16lx %s\n", \
 $p, $p->p_pid, \
 $p->p_flag, $p->p_stat, $p->p_nlwps, $p->p_lwps.lh_first, \
 (char *) $p->p_comm
-			printf "\n"
 			set $p = $p->p_list.le_next
 		end
 		set $i++

Added files:

Index: src/sys/gdbscripts/devs
diff -u /dev/null src/sys/gdbscripts/devs:1.1
--- /dev/null	Mon May  6 02:41:02 2019
+++ src/sys/gdbscripts/devs	Mon May  6 02:41:02 2019
@@ -0,0 +1,20 @@
+#	$NetBSD: devs,v 1.1 2019/05/06 02:41:02 mrg Exp $
+
+define devs
+	set $i = 0
+
+	while ($i < 2)
+		if ($i == 0)
+			set $d = alldevs.tqh_first
+		end
+		if ($d)
+			printf "device_tparent   private  dv_xname\n"
+		end
+		while ($d)
+			printf "%16lx  %16lx  %16lx  %s\n", \
+$d, $d->dv_parent, $d->dv_private, $d->dv_xname
+			set $d = $d->dv_list.tqe_next
+		end
+		set $i++
+	end
+end



CVS commit: src/sys/gdbscripts

2017-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jun  5 18:44:13 UTC 2017

Modified Files:
src/sys/gdbscripts: cpus

Log Message:
Typo in previous


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/gdbscripts/cpus

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/cpus
diff -u src/sys/gdbscripts/cpus:1.2 src/sys/gdbscripts/cpus:1.3
--- src/sys/gdbscripts/cpus:1.2	Mon Jun  5 18:34:16 2017
+++ src/sys/gdbscripts/cpus	Mon Jun  5 18:44:13 2017
@@ -1,10 +1,10 @@
-#	$NetBSD: cpus,v 1.2 2017/06/05 18:34:16 skrll Exp $
+#	$NetBSD: cpus,v 1.3 2017/06/05 18:44:13 skrll Exp $
 
 define cpus
 	set $cpu = 0
 	printf "\t cpu id   curlwp\n"
 	while ($cpu < ncpu)
-		set $ci = _infos[$cpu]
+		set $ci = cpu_infos[$cpu]
 		printf "%16lx %2d %16lx\n", $ci, $ci->ci_cpuid, $ci->ci_curlwp
 		set $cpu++
 	end



CVS commit: src/sys/gdbscripts

2017-06-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jun  5 18:34:16 UTC 2017

Modified Files:
src/sys/gdbscripts: cpus

Log Message:
Make cpus MI


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/gdbscripts/cpus

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/cpus
diff -u src/sys/gdbscripts/cpus:1.1 src/sys/gdbscripts/cpus:1.2
--- src/sys/gdbscripts/cpus:1.1	Wed Feb 20 21:01:23 2008
+++ src/sys/gdbscripts/cpus	Mon Jun  5 18:34:16 2017
@@ -1,10 +1,11 @@
-#	$NetBSD: cpus,v 1.1 2008/02/20 21:01:23 ad Exp $
+#	$NetBSD: cpus,v 1.2 2017/06/05 18:34:16 skrll Exp $
 
 define cpus
-	set $ci = _info_primary
+	set $cpu = 0
 	printf "\t cpu id   curlwp\n"
-	while ($ci != 0)
+	while ($cpu < ncpu)
+		set $ci = _infos[$cpu]
 		printf "%16lx %2d %16lx\n", $ci, $ci->ci_cpuid, $ci->ci_curlwp
-		set $ci = $ci->ci_next
+		set $cpu++
 	end
 end



CVS commit: src/sys/gdbscripts

2017-04-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Apr 13 09:52:18 UTC 2017

Modified Files:
src/sys/gdbscripts: vchain

Log Message:
Change command mountdump to evaluate mountlist_entry.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/gdbscripts/vchain

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/vchain
diff -u src/sys/gdbscripts/vchain:1.8 src/sys/gdbscripts/vchain:1.9
--- src/sys/gdbscripts/vchain:1.8	Wed Dec 14 15:48:55 2016
+++ src/sys/gdbscripts/vchain	Thu Apr 13 09:52:18 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: vchain,v 1.8 2016/12/14 15:48:55 hannken Exp $
+#	$NetBSD: vchain,v 1.9 2017/04/13 09:52:18 hannken Exp $
 
 #	@(#)vchain	8.1 (Berkeley) 6/10/93
 #
@@ -53,14 +53,18 @@ print vnode chains for all mount points
 end
 
 define mountdump
-	set $mp=mountlist.tqh_first
-	while ($mp)
-		printf "%s on %s type %s, (mp 0x%x, privdata 0x%x)\n", \
-		$mp->mnt_stat->f_mntfromname, $mp->mnt_stat->f_mntonname, \
-		$mp->mnt_op->vfs_name, $mp, $mp->mnt_data
-		set $mp=$mp->mnt_list.tqe_next
-		if ((const void *)$mp == (const void *))
-			set $mp = 0
+	set $me=mount_list.tqh_first
+	while ($me)
+		if ($me->me_type == ME_MOUNT)
+			set $mp = $me->me_mount
+			printf "%s on %s type %s, (mp 0x%x, privdata 0x%x)\n", \
+			$mp->mnt_stat->f_mntfromname, \
+			$mp->mnt_stat->f_mntonname, \
+			$mp->mnt_op->vfs_name, $mp, $mp->mnt_data
+		end
+		set $me=$me->me_list.tqe_next
+		if ((const void *)$me == (const void *)_list)
+			set $me = 0
 		end
 	end
 end



CVS commit: src/sys/gdbscripts

2016-05-11 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu May 12 00:35:10 UTC 2016

Modified Files:
src/sys/gdbscripts: kernhist

Log Message:
make '$e' in here the whole structure instead of a pointer, to combine
several pointer derefs into one speaking this up significantly.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/gdbscripts/kernhist

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/kernhist
diff -u src/sys/gdbscripts/kernhist:1.1 src/sys/gdbscripts/kernhist:1.2
--- src/sys/gdbscripts/kernhist:1.1	Wed May 11 09:22:55 2016
+++ src/sys/gdbscripts/kernhist	Thu May 12 00:35:10 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: kernhist,v 1.1 2016/05/11 09:22:55 mrg Exp $
+#	$NetBSD: kernhist,v 1.2 2016/05/12 00:35:10 mrg Exp $
 
 # by mrg and skrll
 
@@ -12,13 +12,13 @@ define kernhist
 
 	printf "Kernel history %s has %d entries (next free %d)\n", $hist->name, $histn, $histf
 	while (1)
-		set $e = &$hist->e[$lcv]
-		set $fmt = $e->fmt
+		set $e = $hist->e[$lcv]
+		set $fmt = $e.fmt
 
 		if ($fmt)
-			printf "%06lx.%06d ", $e->tv.tv_sec, $e->tv.tv_usec
-			printf "%s#%ld@%d: ", $e->fn, $e->call, $e->cpunum
-			printf "%s: %lx %lx %lx %lx\n", $fmt, $e->v[0], $e->v[1], $e->v[2], $e->v[3]
+			printf "%06lx.%06d ", $e.tv.tv_sec, $e.tv.tv_usec
+			printf "%s#%ld@%d: ", $e.fn, $e.call, $e.cpunum
+			printf "%s: %lx %lx %lx %lx\n", $fmt, $e.v[0], $e.v[1], $e.v[2], $e.v[3]
 			set $lcv = ($lcv + 1) % $histn
 		else
 			if ($histf == 0)



CVS commit: src/sys/gdbscripts

2016-05-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed May 11 10:39:31 UTC 2016

Modified Files:
src/sys/gdbscripts: Makefile.inc

Log Message:
Add kernhist to SYS_GDBINIT


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/gdbscripts/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/Makefile.inc
diff -u src/sys/gdbscripts/Makefile.inc:1.5 src/sys/gdbscripts/Makefile.inc:1.6
--- src/sys/gdbscripts/Makefile.inc:1.5	Wed Nov  2 16:51:21 2011
+++ src/sys/gdbscripts/Makefile.inc	Wed May 11 10:39:31 2016
@@ -1,3 +1,3 @@
-#	$NetBSD: Makefile.inc,v 1.5 2011/11/02 16:51:21 yamt Exp $
+#	$NetBSD: Makefile.inc,v 1.6 2016/05/11 10:39:31 skrll Exp $
 
-SYS_GDBINIT=	bdump cpus kdump lwps module msgbuf pgrpdump procs vchain vdump
+SYS_GDBINIT=	bdump cpus kdump kernhist lwps module msgbuf pgrpdump procs vchain vdump



CVS commit: src/sys/gdbscripts

2016-05-11 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed May 11 09:22:55 UTC 2016

Added Files:
src/sys/gdbscripts: kernhist

Log Message:
add a gdb script to dump kernel histories.  based upon a script by skrll,
updated by myself to run faster and more stupidly (but more workingly.)

normal gdb scripts don't seem to be able to call printf with the format
string as a variable, so we simply print the format itself as a string
and the (upto 4) arguments as unsigned long (how they're strored.)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/gdbscripts/kernhist

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/gdbscripts/kernhist
diff -u /dev/null src/sys/gdbscripts/kernhist:1.1
--- /dev/null	Wed May 11 09:22:55 2016
+++ src/sys/gdbscripts/kernhist	Wed May 11 09:22:55 2016
@@ -0,0 +1,42 @@
+#	$NetBSD: kernhist,v 1.1 2016/05/11 09:22:55 mrg Exp $
+
+# by mrg and skrll
+
+define kernhist
+	dont-repeat
+
+	set $hist = (struct kern_history *)&$arg0
+	set $histf = $hist->f
+	set $histn = $hist->n
+	set $lcv = $histf
+
+	printf "Kernel history %s has %d entries (next free %d)\n", $hist->name, $histn, $histf
+	while (1)
+		set $e = &$hist->e[$lcv]
+		set $fmt = $e->fmt
+
+		if ($fmt)
+			printf "%06lx.%06d ", $e->tv.tv_sec, $e->tv.tv_usec
+			printf "%s#%ld@%d: ", $e->fn, $e->call, $e->cpunum
+			printf "%s: %lx %lx %lx %lx\n", $fmt, $e->v[0], $e->v[1], $e->v[2], $e->v[3]
+			set $lcv = ($lcv + 1) % $histn
+		else
+			if ($histf == 0)
+printf "No entries\n"
+loop_break
+			end
+			# if fmt is NULL and hist->f isn't zero, skip back to
+			# the start of the list since it hasn't looped yet.
+			set $lcv = 0
+		end
+
+		if ($lcv == $histf)
+			loop_break
+		end
+	end
+end
+document kernhist
+dump a kernel hist.  eg, "kernhist usbhist".  note that the format
+is not expanded due to there being now way to pass a variable format
+string to gdb's printf.
+end



CVS commit: src/sys/gdbscripts

2011-11-02 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Wed Nov  2 16:51:21 UTC 2011

Modified Files:
src/sys/gdbscripts: Makefile.inc
Added Files:
src/sys/gdbscripts: module

Log Message:
a macro to dump kernel modules


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/gdbscripts/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/sys/gdbscripts/module

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/Makefile.inc
diff -u src/sys/gdbscripts/Makefile.inc:1.4 src/sys/gdbscripts/Makefile.inc:1.5
--- src/sys/gdbscripts/Makefile.inc:1.4	Wed Feb 20 21:01:23 2008
+++ src/sys/gdbscripts/Makefile.inc	Wed Nov  2 16:51:21 2011
@@ -1,3 +1,3 @@
-#	$NetBSD: Makefile.inc,v 1.4 2008/02/20 21:01:23 ad Exp $
+#	$NetBSD: Makefile.inc,v 1.5 2011/11/02 16:51:21 yamt Exp $
 
-SYS_GDBINIT=	bdump cpus kdump lwps msgbuf pgrpdump procs vchain vdump
+SYS_GDBINIT=	bdump cpus kdump lwps module msgbuf pgrpdump procs vchain vdump

Added files:

Index: src/sys/gdbscripts/module
diff -u /dev/null src/sys/gdbscripts/module:1.1
--- /dev/null	Wed Nov  2 16:51:22 2011
+++ src/sys/gdbscripts/module	Wed Nov  2 16:51:21 2011
@@ -0,0 +1,16 @@
+define modules
+	set $h = module_list
+	set $e = $h-tqh_first
+	while ($e != 0)
+		if ($e-mod_kobj != 0)
+			printf module %s\t0x%016x-0x%016x\n, \
+			$e-mod_info.mi_name, \
+			$e-mod_kobj-ko_address, \
+			$e-mod_kobj-ko_address + $e-mod_kobj-ko_size
+		else
+			printf module %s\n, \
+			$e-mod_info.mi_name
+		end
+		set $e = $e-mod_chain.tqe_next
+	end
+end



CVS commit: src/sys/gdbscripts

2011-02-05 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sat Feb  5 14:12:06 UTC 2011

Modified Files:
src/sys/gdbscripts: lwps

Log Message:
fix format


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/gdbscripts/lwps

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/lwps
diff -u src/sys/gdbscripts/lwps:1.3 src/sys/gdbscripts/lwps:1.4
--- src/sys/gdbscripts/lwps:1.3	Wed Nov 18 18:12:00 2009
+++ src/sys/gdbscripts/lwps	Sat Feb  5 14:12:05 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: lwps,v 1.3 2009/11/18 18:12:00 eeh Exp $
+#	$NetBSD: lwps,v 1.4 2011/02/05 14:12:05 yamt Exp $
 
 define lwps
 	set $i = 0
@@ -14,7 +14,7 @@
 			set $l = $p-p_lwps.lh_first
 			set $j = 0
 			while ($j  $p-p_nlwps)
-printf 0x%16lx %5d %5d %8x 0x%16lx, \
+printf 0x%016lx %5d %5d %8x 0x%016lx, \
 	$l, $p-p_pid, $l-l_lid, $l-l_flag, $l-l_wchan
 if ($l-l_wmesg)
 	printf  (%s), (char *)$l-l_wmesg



CVS commit: src/sys/gdbscripts

2009-11-18 Thread Eduardo Horvath
Module Name:src
Committed By:   eeh
Date:   Wed Nov 18 18:04:26 UTC 2009

Modified Files:
src/sys/gdbscripts: vchain

Log Message:
Print out all 64-bits of 64-bit values on 64-bit machines and add documentation
of these commands to gdb.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/gdbscripts/vchain

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/vchain
diff -u src/sys/gdbscripts/vchain:1.5 src/sys/gdbscripts/vchain:1.6
--- src/sys/gdbscripts/vchain:1.5	Sat Nov  4 20:33:17 2006
+++ src/sys/gdbscripts/vchain	Wed Nov 18 18:04:26 2009
@@ -1,32 +1,39 @@
-#	$NetBSD: vchain,v 1.5 2006/11/04 20:33:17 pooka Exp $
+#	$NetBSD: vchain,v 1.6 2009/11/18 18:04:26 eeh Exp $
 
 #	@(#)vchain	8.1 (Berkeley) 6/10/93
 #
-# Given a vnode, follow its mount pointers
+
 define vchain
 	set $num = 0
 
 	set $vp=(struct vnode *)$arg0
 	while ($vp)
-		printf vp: 0x%x freelist_next: 0x%x usecount: %d flags: 0x%x\n, $vp, $vp-v_freelist.tqe_next, $vp-v_uobj.uo_refs, $vp-v_flag
+		printf vp: 0x%lx freelist_next: 0x%lx usecount: %d flags: i:0x%x v:0x%x u:0x%x\n,\
+		   $vp, $vp-v_freelist.tqe_next, $vp-v_uobj.uo_refs, \
+		   $vp-v_iflag, $vp-v_vflag, $vp-v_uflag
 		set $num++
 		set $vp = $vp-v_mntvnodes.tqe_next
 	end
 	printf Number of vnodes: %d\n, $num
 end
 
+document vchain
+Given a vnode, follow its mount pointers
+end
+
 define vprint
 	set $vp=(struct vnode *)$arg0
 	set $ip=(struct inode *)$vp-v_data
 end
 
-# print the vnode chain for a given mount point
 define mp_vchain
 	set $mp = (struct mount *)$arg0
 	vchain $mp-mnt_vnodelist.tqh_first
 end
+document mp_vchain
+print the vnode chain for a given mount point
+end
 
-# print vnode chains for all mount points
 define vall
 	set $mp=mountlist.cqh_first
 	while ($mp)
@@ -40,6 +47,9 @@
 		end
 	end
 end
+document vall
+print vnode chains for all mount points
+end
 
 define mountdump
 	set $mp=mountlist.cqh_first
@@ -52,3 +62,4 @@
 			set $mp = 0
 		end
 	end
+end
\ No newline at end of file



CVS commit: src/sys/gdbscripts

2009-11-18 Thread Eduardo Horvath
Module Name:src
Committed By:   eeh
Date:   Wed Nov 18 18:05:51 UTC 2009

Modified Files:
src/sys/gdbscripts: procs

Log Message:
Add the lwp address so you don't have to leave gdb and use ps to grab an lwp's
stack.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/gdbscripts/procs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/procs
diff -u src/sys/gdbscripts/procs:1.1 src/sys/gdbscripts/procs:1.2
--- src/sys/gdbscripts/procs:1.1	Wed Feb 20 20:56:35 2008
+++ src/sys/gdbscripts/procs	Wed Nov 18 18:05:51 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: procs,v 1.1 2008/02/20 20:56:35 ad Exp $
+#	$NetBSD: procs,v 1.2 2009/11/18 18:05:51 eeh Exp $
 
 define procs
 	set $i = 0
@@ -8,12 +8,12 @@
 			set $p = allproc.lh_first
 		end
 		if ($p)
-			printf proc   pid flag stat nlwps comm\n
+			printf proc   pid flag stat nlwpslwp  comm\n
 		end
 		while ($p)
-			printf %16lx %5d %8x %4x %5d %s, \
+			printf %16lx %5d %8x %4x %5d %16lx %s, \
 $p, $p-p_pid, \
-$p-p_flag, $p-p_stat, $p-p_nlwps, \
+$p-p_flag, $p-p_stat, $p-p_nlwps, $p-p_lwps.lh_first, \
 (char *) $p-p_comm
 			printf \n
 			set $p = $p-p_list.le_next



CVS commit: src/sys/gdbscripts

2009-11-18 Thread Eduardo Horvath
Module Name:src
Committed By:   eeh
Date:   Wed Nov 18 18:12:00 UTC 2009

Modified Files:
src/sys/gdbscripts: lwps

Log Message:
Add a command to dump all thread stacks in the system and a command to dump
lockdebug state.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/gdbscripts/lwps

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/lwps
diff -u src/sys/gdbscripts/lwps:1.2 src/sys/gdbscripts/lwps:1.3
--- src/sys/gdbscripts/lwps:1.2	Tue Jul 28 10:38:20 2009
+++ src/sys/gdbscripts/lwps	Wed Nov 18 18:12:00 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: lwps,v 1.2 2009/07/28 10:38:20 skrll Exp $
+#	$NetBSD: lwps,v 1.3 2009/11/18 18:12:00 eeh Exp $
 
 define lwps
 	set $i = 0
@@ -14,10 +14,12 @@
 			set $l = $p-p_lwps.lh_first
 			set $j = 0
 			while ($j  $p-p_nlwps)
-printf %16lx %5d %5d %8x %16lx, \
+printf 0x%16lx %5d %5d %8x 0x%16lx, \
 	$l, $p-p_pid, $l-l_lid, $l-l_flag, $l-l_wchan
 if ($l-l_wmesg)
 	printf  (%s), (char *)$l-l_wmesg
+# If the preceding command cannot dereference the pointer, use this instead:
+#	printf  (%lx), $l-l_wmesg
 end
 set $l = $l-l_sibling.le_next
 printf \n
@@ -28,3 +30,95 @@
 		set $i++
 	end
 end
+document lwps
+ps for lwps
+end
+
+define threadlist
+	set $i = 0
+
+	while ($i  2)
+		if ($i == 0)
+			set $p = allproc.lh_first
+		end
+		while ($p)
+			set $l = $p-p_lwps.lh_first
+			set $j = 0
+			while ($j  $p-p_nlwps)
+			printf \n
+			printf proc: %16lx %5d %8x %4x %5d %16lx %s, \
+$p, $p-p_pid, \
+$p-p_flag, $p-p_stat, $p-p_nlwps, $p-p_lwps.lh_first, \
+(char *) $p-p_comm
+			printf \n
+printf Thread: %16lx %5d %5d %8x %16lx\n, \
+	$l, $p-p_pid, $l-l_lid, $l-l_flag, $l-l_wchan
+			kvm proc $l
+where
+			printf \n
+			printf \n
+set $l = $l-l_sibling.le_next
+set $j++
+		end
+			set $p = $p-p_list.le_next
+		end
+		set $i++
+	end
+end
+document threadlist
+Print out the stack of all threads in the system.
+end
+
+define lock
+	set $ld = (struct lockdebug *)ld_rb_tree
+	set $a = $ld-ld_lock
+	set $b = (volatile void *)$arg0
+
+	while ($ld  $a != $b)
+		if ($a  $b) 
+			set $ld = (struct lockdebug *)$ld-ld_rb_node.rb_nodes[1]
+		end
+		if ($a  $b) 
+			set $ld = (struct lockdebug *)$ld-ld_rb_node.rb_nodes[0]
+		end
+		if ($ld == 0)
+			loop_break
+		end
+		set $a = $ld-ld_lock
+# printf a=%lx b=%lx ld=%lx ab %d ab %d\n, $a, $b, $ld,  ($a  $b), ($a  $b)
+	end
+	if ($ld)
+		printf lock address : %#018lx type : , \
+			(long)$ld-ld_lock
+		if ($ld-ld_flags  0x2)
+			printf sleep/adaptive\n
+		else
+			printf spin\n
+		end
+		printf initialized  : %#018lx, \
+			(long)$ld-ld_initaddr
+		if ($ld-ld_lockops-lo_type == 0x2)
+			printf  interlock: %#018lx\n, $ld-ld_locked
+		else
+			printf \n
+			printf shared holds : %18u exclusive: , \
+$ld-ld_shares
+			if (($ld-ld_flags  0x1) != 0)
+printf 1\n
+			else
+printf 0\n
+			end
+			printf shares wanted: %18u exclusive: %18u\n, \
+(unsigned)$ld-ld_shwant, (unsigned)$ld-ld_exwant
+			printf cpu last held: %18u\n, \
+(unsigned)$ld-ld_cpu
+			printf current lwp  : %#018lx last held: %#018lx\n, \
+(long)0, (long)$ld-ld_lwp
+			printf last locked  : %#018lx unlocked : %#018lx\n, \
+(long)$ld-ld_locked, (long)$ld-ld_unlocked
+		end
+	end
+end
+document lock
+Print out lockdebug info like ddb does.
+end



CVS commit: src/sys/gdbscripts

2009-07-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 28 10:38:20 UTC 2009

Modified Files:
src/sys/gdbscripts: lwps

Log Message:
Use the right pointer to traverse the proc's lwp list.

From PR 41788.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/gdbscripts/lwps

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/gdbscripts/lwps
diff -u src/sys/gdbscripts/lwps:1.1 src/sys/gdbscripts/lwps:1.2
--- src/sys/gdbscripts/lwps:1.1	Wed Feb 20 20:56:35 2008
+++ src/sys/gdbscripts/lwps	Tue Jul 28 10:38:20 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: lwps,v 1.1 2008/02/20 20:56:35 ad Exp $
+#	$NetBSD: lwps,v 1.2 2009/07/28 10:38:20 skrll Exp $
 
 define lwps
 	set $i = 0
@@ -19,7 +19,7 @@
 if ($l-l_wmesg)
 	printf  (%s), (char *)$l-l_wmesg
 end
-set $l = $l-l_list.le_next
+set $l = $l-l_sibling.le_next
 printf \n
 set $j++
 			end