proc->thread stage 5: BUF/VFS clearance! Remove the ucred argument from
[dragonfly.git] / sys / dev / raid / vinum / .gdbinit.kernel
CommitLineData
984263bc
MD
1set remotebaud 38400
2set remotetimeout 1
3set complaints 1
4set print pretty
5define xi
6x/10i $eip
7end
8define xs
9x/12x $esp
10end
11define xb
12x/12x $ebp
13end
14define z
15ni
16x/1i $eip
17end
18define zs
19si
20x/1i $eip
21end
22define xp
23printf " esp: "
24output/x $esp
25echo (
26output (((int)$ebp)-(int)$esp)/4-4
27printf " words on stack)\n ebp: "
28output/x $ebp
29printf "\n eip: "
30x/1i $eip
31printf "Saved ebp: "
32output/x *(int*)$ebp
33printf " (maximum of "
34output ((*(int*)$ebp)-(int)$ebp)/4-4
35printf " parameters possible)\nSaved eip: "
36x/1i *(int*)($ebp+4)
37printf "\nParm 1 at "
38output/x (int) ($ebp+8)
39printf ": "
40output (char*) *(int*)($ebp+8)
41printf "\nParm 2 at "
42output/x (int) ($ebp+12)
43printf ": "
44output (char*) *(int*)($ebp+12)
45printf "\nParm 3 at "
46output/x (int) ($ebp+16)
47printf ": "
48output (char*) *(int*)($ebp+16)
49printf "\nParm 4 at "
50output/x (int) ($ebp+20)
51printf ": "
52output (char*) *(int*)($ebp+20)
53echo \n
54end
55document xp
56Show the register contents and the first four parameter
57words of the current frame.
58end
59define xxp
60printf " esp: "
61output/x $esp
62printf "\n ebp: "
63output/x $ebp
64printf "\n eip: "
65x/1i $eip
66printf "Saved ebp: "
67output/x *(int*)$ebp
68printf " (maximum of "
69output ((*(int*)$ebp)-(int)$ebp)/4-4
70printf " parameters possible)\nSaved eip: "
71x/1i *(int*)($ebp+4)
72printf "\nParm 1 at "
73output/x (int) ($ebp+8)
74printf ": "
75output (char*) *(int*)($ebp+8)
76printf "\nParm 2 at "
77output/x (int) ($ebp+12)
78printf ": "
79output (char*) *(int*)($ebp+12)
80printf "\nParm 3 at "
81output/x (int) ($ebp+16)
82printf ": "
83output (char*) *(int*)($ebp+16)
84printf "\nParm 4 at "
85output/x (int) ($ebp+20)
86printf ": "
87output (char*) *(int*)($ebp+20)
88printf "\nParm 5 at "
89output/x (int) ($ebp+24)
90printf ": "
91output (char*) *(int*)($ebp+24)
92printf "\nParm 6 at "
93output/x (int) ($ebp+28)
94printf ": "
95output (char*) *(int*)($ebp+28)
96printf "\nParm 7 at "
97output/x (int) ($ebp+32)
98printf ": "
99output (char*) *(int*)($ebp+32)
100printf "\nParm 8 at "
101output/x (int) ($ebp+36)
102printf ": "
103output (char*) *(int*)($ebp+36)
104printf "\nParm 9 at "
105output/x (int) ($ebp+40)
106printf ": "
107output (char*) *(int*)($ebp+40)
108printf "\nParm 10 at "
109output/x (int) ($ebp+44)
110printf ": "
111output (char*) *(int*)($ebp+44)
112echo \n
113end
114document xxp
115Show the register contents and the first ten parameter
116words of the current frame.
117end
118define xp0
119x/12x *(int*)$esp
120p *(int*)$esp
121p (char*)*$esp
122end
123define xp1
124x/12x *(int*)($ebp+4)
125p *(int*)($ebp+4)
126p (char**)($ebp+4)
127end
128define xp2
129x/12x *(int*)($ebp+8)
130p *(int*)($ebp+8)
131p *(char**)($ebp+8)
132end
133define xp3
134x/12x *(int*)($ebp+12)
135p *(int*)($ebp+12)
136p (char**)($ebp+12)
137end
138define xp4
139x/12x *(int*)($ebp+16)
140p *(int*)($ebp+16)
141p (char**)($ebp+16)
142end
143document xp0
144Show the first parameter of current stack frame in various formats
145end
146document xp1
147Show the second parameter of current stack frame in various formats
148end
149document xp2
150Show the third parameter of current stack frame in various formats
151end
152document xp3
153Show the fourth parameter of current stack frame in various formats
154end
155document xp4
156Show the fifth parameter of current stack frame in various formats
157end
158define f0
159f 0
160xp
161end
162define f1
163f 1
164xp
165end
166define f2
167f 2
168xp
169end
170define f3
171f 3
172xp
173end
174define f4
175f 4
176xp
177end
178define f5
179f 5
180xp
181end
182document f0
183Select stack frame 0 and show assembler-level details
184end
185document f1
186Select stack frame 1 and show assembler-level details
187end
188document f2
189Select stack frame 2 and show assembler-level details
190end
191document f3
192Select stack frame 3 and show assembler-level details
193end
194document f4
195Select stack frame 4 and show assembler-level details
196end
197document f5
198Select stack frame 5 and show assembler-level details
199end
200document z
201Single step 1 instruction (over calls) and show next instruction.
202end
203document zs
204Single step 1 instruction (through calls) and show next instruction.
205end
206document xi
207List the next 10 instructions from the current IP value
208end
209document xs
210Show the last 12 words on stack in hex
211end
212document xb
213Show 12 words starting at current BP value in hex
214end
215define tr
216target remote /dev/cuaa1
217end
218document tr
219Attach to a remote kernel via /dev/cuaa0
220end
221set output-radix 16
222define pname
223p (char *)curproc->p_comm
224end
225document pname
226Print the command name of the current process
227end
228define bpp
229set $bp = (struct buf *) $arg0
230 if $bp->b_dev
231 printf " Buffer at 0x%x: dev 0x%x data 0x%x bcount 0x%x blkno 0x%x resid 0x%x\n", \
232 $bp, \
233 $bp->b_dev->si_udev, \
234 $bp->b_data, \
235 $bp->b_bcount, \
236 $bp->b_blkno, \
237 $bp->b_resid
238 else
239 printf " Buffer at 0x%x: dev (none) data 0x%x bcount 0x%x blkno 0x%x resid 0x%x\n", \
240 $bp, \
241 $bp->b_data, \
242 $bp->b_bcount, \
243 $bp->b_blkno, \
244 $bp->b_resid
245 end
246 printf " flags 0x%x: ", $bp->b_flags
247 if $bp->b_flags & 0x10
248 printf "busy "
249 end
250 if $bp->b_flags & 0x40
251 printf "call "
252 end
253 if $bp->b_flags & 0x200
254 printf "done "
255 end
256 if $bp->b_flags & 0x800
257 printf "error "
258 end
259 if $bp->b_flags & 0x40000
260 printf "phys "
261 end
262 if $bp->b_flags & 0x100000
263 printf "read "
264 end
265 printf "\n"
266end
267define bpl
268set $bp = (struct buf *) $arg0
269printf "b_proc: "
270output $bp->b_proc
271printf "\nb_flags: "
272output $bp->b_flags
273printf "\nb_qindex: "
274output $bp->b_qindex
275printf "\nb_usecount: "
276output $bp->b_usecount
277printf "\nb_error: "
278output $bp->b_error
279printf "\nb_bufsize: "
280output $bp->b_bufsize
281printf "\nb_bcount: "
282output $bp->b_bcount
283printf "\nb_resid: "
284output $bp->b_resid
285printf "\nb_dev: "
286output $bp->b_dev
287printf "\nb_data: "
288output $bp->b_data
289printf "\nb_kvasize: "
290output $bp->b_kvasize
291printf "\nb_lblkno: "
292output $bp->b_lblkno
293printf "\nb_blkno: "
294output $bp->b_blkno
295printf "\nb_iodone: "
296output $bp->b_iodone
297printf "\nb_vp: "
298output $bp->b_vp
299printf "\nb_dirtyoff: "
300output $bp->b_dirtyoff
301printf "\nb_dirtyend: "
302output $bp->b_dirtyend
303printf "\nb_generation: "
304output $bp->b_generation
984263bc
MD
305printf "\nb_validoff: "
306output $bp->b_validoff
307printf "\nb_validend: "
308output $bp->b_validend
309printf "\nb_pblkno: "
310output $bp->b_pblkno
311printf "\nb_saveaddr: "
312output $bp->b_saveaddr
313printf "\nb_savekva: "
314output $bp->b_savekva
315printf "\nb_driver1: "
316output $bp->b_driver1
317printf "\nb_driver2: "
318output $bp->b_driver2
319printf "\nb_spc: "
320output $bp->b_spc
321printf "\nb_npages: "
322output $bp->b_npages
323printf "\n"
324end
325define bp
326bpp bp
327end
328define bpd
329 printf "Buffer data:\n%s", (char *) bp->b_data
330end
331document bpd
332Show the contents (char*) of bp->data in the current frame.
333end
334document bp
335Show information about the buffer header pointed to by the
336variable bp in the current frame.
337end
338document bpp
339Show summary information about the buffer header (struct bp) pointed
340at by the parameter.
341end
342document bpl
343Show detailled information about the buffer header (struct bp) pointed
344at by the parameter.
345end
346document bpl
347Show detailled information about the buffer header (struct bp) pointed
348at by the local variable bp.
349end
350define bx
351printf "\n b_vnbufs "
352output/x bp->b_vnbufs
353printf "\n b_freelist "
354output/x bp->b_freelist
355printf "\n b_act "
356output/x bp->b_act
357printf "\n b_flags "
358output/x bp->b_flags
359printf "\n b_qindex "
360output/x bp->b_qindex
361printf "\n b_usecount "
362output/x bp->b_usecount
363printf "\n b_error "
364output/x bp->b_error
365printf "\n b_bufsize "
366output/x bp->b_bufsize
367printf "\n b_bcount "
368output/x bp->b_bcount
369printf "\n b_resid "
370output/x bp->b_resid
371printf "\n b_dev "
372output/x bp->b_dev
373printf "\n b_data "
374output/x bp->b_data
375printf "\n b_kvasize "
376output/x bp->b_kvasize
377printf "\n b_blkno "
378output/x bp->b_blkno
379printf "\n b_iodone_chain "
380output/x bp->b_iodone_chain
381printf "\n b_vp "
382output/x bp->b_vp
383printf "\n b_dirtyoff "
384output/x bp->b_dirtyoff
385printf "\n b_validoff "
386output/x bp->b_validoff
387echo \n
388end
389define ddb
390set boothowto=0x80000000
391s
392end
393document ddb
394Switch back to ddb.
395end
396define ps
397 set $nproc = nprocs
398 set $aproc = allproc.lh_first
399 set $proc = allproc.lh_first
400 printf " pid proc addr uid ppid pgrp flag stat comm wchan\n"
401 while (--$nproc >= 0)
402 set $pptr = $proc.p_pptr
403 if ($pptr == 0)
404 set $pptr = $proc
405 end
406 if ($proc.p_stat)
407 printf "%5d %08x %08x %4d %5d %5d %06x %d %-10s ", \
408 $proc.p_pid, $aproc, \
409 $proc.p_addr, $proc.p_cred->p_ruid, $pptr->p_pid, \
410 $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
411 &$proc.p_comm[0]
412 if ($proc.p_wchan)
413 if ($proc.p_wmesg)
414 printf "%s ", $proc.p_wmesg
415 end
416 printf "%x", $proc.p_wchan
417 end
418 printf "\n"
419 end
420 set $aproc = $proc.p_list.le_next
421 if ($aproc == 0 && $nproc > 0)
422 set $aproc = zombproc
423 end
424 set $proc = $aproc
425 end
426end
427document ps
428"ps" -- when kernel debugging, type out a ps-like listing of active processes.
429end
430define pcb
431 set $nproc = nprocs
432 set $aproc = allproc.lh_first
433 set $proc = allproc.lh_first
434 while (--$nproc >= 0)
435 set $pptr = $proc.p_pptr
436 if ($proc->p_pid == $arg0)
437 set $pcba = $pptr->p_addr->u_pcb
438 printf "ip: %08x sp: %08x bp: %08x bx: %08x\n", $pcba->pcb_eip, $pcba->pcb_esp, $pcba->pcb_ebp, $pcba->pcb_ebx
439 x/1i $pcba->pcb_eip
440 set $nproc = 0
441 end
442 set $aproc = $proc.p_list.le_next
443 if ($aproc == 0 && $nproc > 0)
444 set $aproc = zombproc
445 end
446 set $proc = $aproc
447 end
448end
449document pcb
450Show some pcb contents of process whose pid is specified.
451end
452define btr
453set $frame = $arg0
454set $fno = 0
455while (*(int *) $frame > 0xc0000000)
456 set $myebp = *(int *) $frame
457 set $myeip = *(int *) ($frame + 4)
458 printf " frame %d at %p: ebp %8x, eip ", $fno, $frame, $myebp
459 x/1i $myeip
460 set $frame = $myebp
461 set $fno = $fno + 1
462end
463end
464document btr
465Show a backtrace from the ebp address specified. This can be used to
466get a backtrace from any stack resident in memory.
467end
468define btp
469 set $nproc = nprocs
470 set $aproc = allproc.lh_first
471 set $proc = allproc.lh_first
472 while (--$nproc >= 0)
473 if ($proc->p_pid == $arg0)
474 btr $proc->p_addr->u_pcb->pcb_ebp
475 set $nproc = 0
476 else
477 set $aproc = $proc.p_list.le_next
478 if ($aproc == 0 && $nproc > 0)
479 set $aproc = zombproc
480 end
481 set $proc = $aproc
482 end
483 end
484end
485document btp
486Show a backtrace for the process whose pid is specified as a parameter.
487end
488define btpa
489 set $nproc = nprocs
490 set $aproc = allproc.lh_first
491 set $proc = allproc.lh_first
492 printf " pid proc addr uid ppid pgrp flag stat comm wchan\n"
493 while (--$nproc >= 0)
494 set $pptr = $proc.p_pptr
495 if ($pptr == 0)
496 set $pptr = $proc
497 end
498 if ($proc.p_stat)
499 printf "%5d %08x %08x %4d %5d %5d %06x %d %-10s ", \
500 $proc.p_pid, $aproc, \
501 $proc.p_addr, $proc.p_cred->p_ruid, $pptr->p_pid, \
502 $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
503 &$proc.p_comm[0]
504 if ($proc.p_wchan)
505 if ($proc.p_wmesg)
506 printf "%s ", $proc.p_wmesg
507 end
508 printf "%x", $proc.p_wchan
509 end
510 printf "\n"
511 if ($proc->p_flag & 4)
512 btr $proc->p_addr->u_pcb->pcb_ebp
513 else
514 echo (not loaded)\n
515 end
516 end
517 set $aproc = $proc.p_list.le_next
518 if ($aproc == 0 && $nproc > 0)
519 set $aproc = zombproc
520 end
521 set $proc = $aproc
522 end
523end
524document btpa
525Show backtraces for all processes in the system.
526end
527define btpp
528 if ($myvectorproc->p_flag & 4)
529 btr $myvectorproc->p_addr->u_pcb->pcb_ebp
530 else
531 echo (not loaded)\n
532 end
533end
534document btpp
535Show a backtrace for the process previously selected with 'defproc'.
536end
537define defproc
538 set $nproc = nprocs
539 set $aproc = allproc.lh_first
540 set $proc = allproc.lh_first
541 while (--$nproc >= 0)
542 if ($proc->p_pid == $arg0)
543 set $pptr = $proc.p_pptr
544 if ($pptr == 0)
545 set $pptr = $proc
546 end
547 set $myvectorproc = $proc
548 if ($proc.p_stat)
549 printf "%5d %08x %08x %4d %5d %5d %06x %d %-10s ", \
550 $proc.p_pid, $aproc, \
551 $proc.p_addr, $proc.p_cred->p_ruid, $pptr->p_pid, \
552 $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
553 &$proc.p_comm[0]
554 if ($proc.p_wchan)
555 if ($proc.p_wmesg)
556 printf "%s ", $proc.p_wmesg
557 end
558 printf "%x", $proc.p_wchan
559 end
560 printf "\n"
561 end
562 btpp
563 set $nproc = 0
564 else
565 set $proc = $proc.p_list.le_next
566 end
567 end
568end
569document defproc
570Specify a process for btpp and fr commands.
571end
572define fr
573set $fno = 0
574set $searching = 1
575if ($myvectorproc->p_flag & 4)
576 set $frame = $myvectorproc->p_addr->u_pcb->pcb_ebp
577 while (($searching == 1) && (*(int *) $frame > 0xc0000000))
578 set $myebp = *(int *) $frame
579 set $myeip = *(int *) ($frame + 4)
580 if ($fno == $arg0)
581 printf " frame %d at %p: ebp %8x, eip ", $fno, $frame, $myebp
582 x/1i $myeip
583 printf "Called from %8x, stack frame at %8x\n", *(int *) ($myebp+4), *(int *) $myebp
584 printf "last 20 local variables:\n"
585 x/20x ($myebp-80)
586 printf "call parameters:\n"
587 x/8x ($myebp+8)
588 set $searching = 0
589 else
590 set $frame = $myebp
591 set $fno = $fno + 1
592 end
593 end
594 if ($searching == 1)
595 echo frame not found\n
596 end
597else
598 printf "process %d is not loaded in memory\n", $myvectorproc->p_pid
599end
600end
601document fr
602Show the frame of the stack of the process previously selected with 'defproc'.
603end
604set height 70
605set width 120
606define vdev
607if (vp->v_type == VBLK)
608 p *vp->v_un.vu_spec.vu_specinfo
609 printf "numoutput: %d\n", vp->v_numoutput
610else
611 echo "Not a block device"
612end
613end
614document vdev
615Show some information of the vnode pointed to by the local variable vp.
616end
617define y
618echo Check your .gdbinit, it contains a y command\n
619end
620define kldstat
621 set $file = files.tqh_first
622 printf "Id Refs Address Size Name\n"
623 while ($file != 0)
624 printf "%2d %4d 0x%8x %8x %s\n", \
625 $file->id, \
626 $file->refs, \
627 $file->address, \
628 $file->size, \
629 $file->filename
630 set $file = $file->link.tqe_next
631 end
632end
633document kldstat
634Equivalent of the kldstat(9) command, without options.
635end
636define msgbuf
637printf "%s", msgbufp->msg_ptr
638end
639document msgbuf
640Print 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.
641end