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