2 # General kernel macros
4 # Print the command name of the current process
6 p (char *)curproc->p_comm
9 Print the command name of the current process.
12 # Show contents of bp supplied as first parameter:
16 set $bp = (struct buf *) $arg0
18 printf " Buffer at 0x%x: dev 0x%x data 0x%x bcount 0x%x blkno 0x%x resid 0x%x\n", \
20 $bp->b_io.bio_dev->si_udev, \
22 $bp->b_io.bio_bcount, \
23 $bp->b_io.bio_blkno, \
26 printf " Buffer at 0x%x: dev (none) data 0x%x bcount 0x%x blkno 0x%x resid 0x%x\n", \
29 $bp->b_io.bio_bcount, \
30 $bp->b_io.bio_blkno, \
33 printf " flags 0x%x: ", $bp->b_flags
34 if $bp->b_flags & 0x10
37 if $bp->b_flags & 0x40
40 if $bp->b_flags & 0x200
43 if $bp->b_flags & 0x800
46 if $bp->b_flags & 0x40000
49 if $bp->b_flags & 0x100000
55 Show summary information about the buffer header (struct bp) pointed at by the parameter.
58 # Show more detailed contents of bp supplied as first parameter:
62 set $bp = (struct buf *) $arg0
69 printf "\nb_usecount: "
70 output $bp->b_usecount
73 printf "\nb_bufsize: "
75 printf "\nb_io.bio_bcount: "
76 output $bp->b_io.bio_bcount
77 printf "\nb_io.bio_resid: "
78 output $bp->b_io.bio_resid
79 printf "\nb_io.bio_dev: "
80 output $bp->b_io.bio_dev
81 printf "\nb_io.bio_data: "
82 output $bp->b_io.bio_data
83 printf "\nb_kvasize: "
87 printf "\nb_io.bio_blkno: "
88 output $bp->b_io.bio_blkno
93 printf "\nb_dirtyoff: "
94 output $bp->b_dirtyoff
95 printf "\nb_dirtyend: "
96 output $bp->b_dirtyend
97 printf "\nb_generation: "
98 output $bp->b_generation
103 printf "\nb_validoff: "
104 output $bp->b_validoff
105 printf "\nb_validend: "
106 output $bp->b_validend
107 printf "\nb_pblkno: "
109 printf "\nb_saveaddr: "
110 output $bp->b_saveaddr
111 printf "\nb_savekva: "
112 output $bp->b_savekva
113 printf "\nb_driver1: "
114 output $bp->b_driver1
115 printf "\nb_driver2: "
116 output $bp->b_driver2
119 printf "\nb_npages: "
124 Show detailed information about the buffer header (struct bp) pointed at by the parameter.
127 # Show contents of buffer header in local variable bp.
132 Show information about the buffer header pointed to by the variable bp in the current frame.
135 # Show data of buffer header in local variable bp as string.
137 printf "Buffer data:\n%s", (char *) bp->b_io.bio_data
140 Show the contents (char*) of bp->data in the current frame.
143 Show detailed information about the buffer header (struct bp) pointed at by the local variable bp.
146 printf "\n b_vnbufs "
147 output/x bp->b_vnbufs
148 printf "\n b_freelist "
149 output/x bp->b_freelist
154 printf "\n b_qindex "
155 output/x bp->b_qindex
156 printf "\n b_usecount "
157 output/x bp->b_usecount
160 printf "\n b_bufsize "
161 output/x bp->b_bufsize
162 printf "\n b_io.bio_bcount "
163 output/x bp->b_io.bio_bcount
164 printf "\n b_io.bio_resid "
165 output/x bp->b_io.bio_resid
166 printf "\n b_io.bio_dev "
167 output/x bp->b_io.bio_dev
168 printf "\n b_io.bio_data "
169 output/x bp->b_io.bio_data
170 printf "\n b_kvasize "
171 output/x bp->b_kvasize
172 printf "\n b_io.bio_blkno "
173 output/x bp->b_io.bio_blkno
174 printf "\n b_iodone_chain "
175 output/x bp->b_iodone_chain
178 printf "\n b_dirtyoff "
179 output/x bp->b_dirtyoff
180 printf "\n b_validoff "
181 output/x bp->b_validoff
185 Print a number of fields from the buffer header pointed at in by the pointer bp in the current environment.
190 set boothowto=0x80000000
197 # ps: equivalent of the userland command
200 set $aproc = allproc.lh_first
201 set $proc = allproc.lh_first
203 printf "pid/ID ppid/tid uid pgrp flag st comm/name proc/thread\n"
204 while (--$nproc >= 0)
205 set $pptr = $proc.p_pptr
210 printf " %5d %6d %4d %5d %8x %2d %-10s %p\n", \
211 $proc.p_pid, $pptr->p_pid, \
212 $proc.p_ucred->cr_ruid, \
213 $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_state, \
214 &$proc.p_comm[0], $aproc
215 set $thread = $proc->p_threads.tqh_first
217 printf "(%5d) %6d %-10s %p", \
218 $tid, $thread->td_tid, $thread->td_name, $thread
219 if ($thread.td_wmesg)
220 printf " %s", $thread.td_wmesg
223 set $thread = $thread->td_plist.tqe_next
227 set $aproc = $proc.p_list.le_next
228 if ($aproc == 0 && $nproc > 0)
229 set $aproc = zombproc
235 Show process status without options.
238 # Specify a process for other commands to refer to.
239 # Most are machine-dependent.
242 set $aproc = allproc.lh_first
243 set $proc = allproc.lh_first
244 while (--$nproc >= 0)
245 if ($proc->p_pid == $arg0)
246 set $pptr = $proc.p_pptr
250 set $myvectorproc = $proc
252 set $thread = $proc->p_threads.tqh_first
254 printf "%5d %08x %08x %4d %5d %5d %06x %d %-10s ", \
255 $proc.p_pid, $aproc, \
256 $proc.p_uarea, $proc.p_ucred->cr_ruid, $pptr->p_pid, \
257 $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_state, \
259 if ($thread.td_wchan)
260 if ($thread.td_wmesg)
261 printf "%s ", $thread.td_wmesg
263 printf "%x", $thread.td_wchan
266 set $thread = $thread->td_plist.tqe_next
272 set $proc = $proc.p_list.le_next
277 Specify a process for btpp and fr commands.
281 if (vp->v_type == VBLK)
282 p *vp->v_un.vu_spec.vu_specinfo
283 printf "numoutput: %d\n", vp->v_numoutput
285 echo "Not a block device"
289 Show some information of the vnode pointed to by the local variable vp.
292 # Kludge. When changing macros, it's convenient to copy and paste
293 # definitions from the editor into the debugger window.
294 # Unfortunately, gdb insists on asking for confirmation after the
295 # "define" line. y enables you to insert the confirmation in the
296 # definition without affecting the way the macro runs (much).
298 echo Check your .gdbinit: it contains a y command\n
302 Kludge for writing macros This is a no-op except for printing a message See gdb(4) for more details.
305 # dmesg: print msgbuf. Can take forever.
307 printf "%s", msgbufp->msg_ptr
310 Print the system message buffer (dmesg) This can take a long time due to the time it takes to transmit the data across a serial line and even on a firewire connection the processing time slows it down
313 # checkmem: check unallocated memory for modifications
314 # this assumes that DIAGNOSTIC is set, which causes
315 # free memory to be set to 0xdeadc0de
317 # Use: checkmem offset length
320 # XXX sizeof int. Needs changing for 64 bit machines.
321 # subtract 1 because the last word is always different.
322 set $length = $arg1 / 4 - 1
324 while ($word < $length)
325 if ((int *) $offset) [$word] != 0xdeadc0de
326 printf "invalid word 0x%x at 0x%x\n", ((int *) $offset) [$word], &((int *) $offset) [$word]
328 set $word = $word + 1
333 Check unallocated memory for modifications This assumes that DIAGNOSTIC is set which causes free memory to be set to 0xdeadc0de.
337 exec-file kernel.$arg0
338 symbol-file symbols.$arg0
339 core-file vmcore.$arg0
343 set $kld = linker_files.tqh_first
344 printf "Id Refs Address Size Name\n"
346 printf "%2d %4d 0x%08x %-8x %s\n", \
347 $kld->id, $kld->refs, $kld->address, $kld->size, $kld->filename
348 set $kld = $kld->link.tqe_next
353 Lists the modules that were loaded when the kernel crashed.
357 set $kld = linker_files.tqh_first
358 printf "Id Refs Address Size Name\n"
360 printf "%2d %4d 0x%08x %-8x %s\n", \
361 $kld->id, $kld->refs, $kld->address, $kld->size, $kld->filename
362 printf " Contains modules:\n"
364 set $module = $kld->modules.tqh_first
366 printf " %2d %s\n", $module->id, $module->name
367 set $module = $module->link.tqe_next
369 set $kld = $kld->link.tqe_next