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