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