forked from apple/darwin-xnu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kgmacros
5551 lines (5101 loc) · 149 KB
/
kgmacros
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
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Kernel gdb macros
#
# These gdb macros should be useful during kernel development in
# determining what's going on in the kernel.
#
# All the convenience variables used by these macros begin with $kgm_
set print asm-demangle on
set cp-abi gnu-v2
echo Loading Kernel GDB Macros package. Type "help kgm" for more info.\n
define kgm
printf ""
echo These are the gdb macros for kernel debugging. Type "help kgm" for more info.\n
end
document kgm
| These are the kernel gdb macros. These gdb macros are intended to be
| used when debugging a remote kernel via the kdp protocol. Typically, you
| would connect to your remote target like so:
| (gdb) target remote-kdp
| (gdb) attach <name-of-remote-host>
|
| The following macros are available in this package:
| showversion Displays a string describing the remote kernel version
|
| showalltasks Display a summary listing of all tasks
| showallthreads Display info about all threads in the system
| showallstacks Display the stack for each thread in the system
| showcurrentthreads Display info about the thread running on each cpu
| showcurrentstacks Display the stack for the thread running on each cpu
| showallvm Display a summary listing of all the vm maps
| showallvme Display a summary listing of all the vm map entries
| showallipc Display a summary listing of all the ipc spaces
| showallrights Display a summary listing of all the ipc rights
| showallkmods Display a summary listing of all the kernel modules
|
| showallclasses Display info about all OSObject subclasses in the system
| showobject Show info about an OSObject - its vtable ptr and retain count, & more info for simple container classes.
| showregistry Show info about all registry entries in the current plane
| showregistryprops Show info about all registry entries in the current plane, and their properties
| showregistryentry Show info about a registry entry; its properties and descendants in the current plane
| setregistryplane Set the plane to be used for the iokit registry macros (pass zero for list)
|
| showtask Display info about the specified task
| showtaskthreads Display info about the threads in the task
| showtaskstacks Display the stack for each thread in the task
| showtaskvm Display info about the specified task's vm_map
| showtaskvme Display info about the task's vm_map entries
| showtaskipc Display info about the specified task's ipc space
| showtaskrights Display info about the task's ipc space entries
|
| showact Display info about a thread specified by activation
| showactstack Display the stack for a thread specified by activation
|
| showmap Display info about the specified vm_map
| showmapvme Display a summary list of the specified vm_map's entries
|
| showipc Display info about the specified ipc space
| showrights Display a summary list of all the rights in an ipc space
|
| showpid Display info about the process identified by pid
| showproc Display info about the process identified by proc struct
| showprocinfo Display detailed info about the process identified by proc struct
| showprocfiles Given a proc_t pointer, display the list of open file descriptors
| showproclocks Given a proc_t pointer, display the list of advisory file locks
| zombproc Print out all procs in the zombie list
| allproc Print out all process in the system not in the zombie list
| zombstacks Print out all stacks of tasks that are exiting
|
| showinitchild Print out all processes in the system which are children of init process
|
| showkmod Display info about a kernel module
| showkmodaddr Given an address, display the kernel module and offset
|
| dumpcallqueue Dump out all the entries given a queue head
|
| showallmtx Display info about mutexes usage
| showallrwlck Display info about reader/writer locks usage
|
| zprint Display info about the memory zones
| showioalloc Display info about iokit allocations
| paniclog Display the panic log info
|
| switchtoact Switch to different context specified by activation
| switchtoctx Switch to different context
| showuserstack Display numeric backtrace of the user stack for an
| activation
|
| switchtouserthread Switch to the user context of the specified thread
| resetstacks Return to the original kernel context
|
| resetctx Reset context
| resume_on Resume when detaching from gdb
| resume_off Don't resume when detaching from gdb
|
| sendcore Configure kernel to send a coredump to the specified IP
| disablecore Configure the kernel to disable coredump transmission
| switchtocorethread Corefile version of "switchtoact"
| resetcorectx Corefile version of "resetctx"
|
| readphys Reads the specified untranslated address
| readphys64 Reads the specified untranslated 64-bit address
|
| rtentry_showdbg Print the debug information of a route entry
| rtentry_trash Walk the list of trash route entries
|
| mbuf_walkpkt Walk the mbuf packet chain (m_nextpkt)
| mbuf_walk Walk the mbuf chain (m_next)
| mbuf_buf2slab Find the slab structure of the corresponding buffer
| mbuf_buf2mca Find the mcache audit structure of the corresponding mbuf
| mbuf_showmca Print the contents of an mbuf mcache audit structure
| mbuf_showactive Print all active/in-use mbuf objects
| mbuf_showinactive Print all freed/in-cache mbuf objects
| mbuf_showall Print all mbuf objects
| mbuf_slabs Print all slabs in the group
| mbuf_slabstbl Print slabs table
| mbuf_stat Print extended mbuf allocator statistics
|
| mcache_walkobj Walk the mcache object chain (obj_next)
| mcache_stat Print all mcaches in the system
| mcache_showcache Display the number of objects in the cache
|
| showbootermemorymap Dump phys memory map from EFI
|
| systemlog Display the kernel's printf ring buffer
|
| showvnodepath Print the path for a vnode
| showvnodelocks Display list of advisory locks held/blocked on a vnode
| showallvols Display a summary of mounted volumes
| showvnode Display info about one vnode
| showvolvnodes Display info about all vnodes of a given volume
| showvolbusyvnodes Display info about busy (iocount!=0) vnodes of a given volume
| showallbusyvnodes Display info about all busy (iocount!=0) vnodes
| showallvnodes Display info about all vnodes
| print_vnode Print out the fields of a vnode struct
| showprocvnodes Print out all the open fds which are vnodes in a process
| showallprocvnodes Print out all the open fds which are vnodes in any process
| showmountvnodes Print the vnode list
| showmountallvnodes Print the vnode inactive list
| showworkqvnodes Print the vnode worker list
| shownewvnodes Print the new vnode list
|
| ifconfig display ifconfig-like output
| showifaddrs show the list of addresses for the given ifp
| showifmultiaddrs show the list of multicast addresses for the given ifp
|
| showallpmworkqueues Display info about all IOPMWorkQueue objects
| showregistrypmstate Display power management state for all IOPower registry entries
| showioservicepm Display the IOServicePM object
| showstacksaftertask showallstacks starting after a given task
| showstacksafterthread showallstacks starting after a given thread
|
| showMCAstate Print machine-check register state after MC exception.
|
| showallgdbstacks Cause GDB to trace all thread stacks
| showallgdbcorestacks Corefile equivalent of "showallgdbstacks"
| kdp-reenter Schedule reentry into the debugger and continue.
| kdp-reboot Restart remote target
|
| Type "help <macro>" for more specific help on a particular macro.
| Type "show user <macro>" to see what the macro is really doing.
end
# This macro should appear before any symbol references, to facilitate
# a gdb "source" without a loaded symbol file.
define showversion
printf "%s\n", *(char **)0x501C
end
document showversion
Syntax: showversion
| Read the kernel version string from a fixed address in low
| memory. Useful if you don't know which kernel is on the other end,
| and need to find the appropriate symbols. Beware that if you've
| loaded a symbol file, but aren't connected to a remote target,
| the version string from the symbol file will be displayed instead.
| This macro expects to be connected to the remote kernel to function
| correctly.
end
set $kgm_mtype = ((struct mach_header)_mh_execute_header).cputype
# This option tells gdb to relax its stack tracing heuristics
# Useful for debugging across stack switches
# (to the interrupt stack, for instance). Requires gdb-675 or greater.
# Don't do this for arm as a workaround to 5486905
if ($kgm_mtype != 12)
set backtrace sanity-checks off
end
set $kgm_dummy = &proc0
set $kgm_dummy = &kmod
set $kgm_reg_depth = 0
set $kgm_reg_plane = (void **) gIOServicePlane
set $kgm_namekey = (OSSymbol *) 0
set $kgm_childkey = (OSSymbol *) 0
set $kgm_show_object_addrs = 0
set $kgm_show_object_retain = 0
set $kgm_show_props = 0
set $kgm_show_kmod_syms = 0
define showkmodheader
printf "kmod address size "
printf "id refs version name\n"
end
define showkmodint
set $kgm_kmodp = (struct kmod_info *)$arg0
printf "0x%08x ", $arg0
printf "0x%08x ", $kgm_kmodp->address
printf "0x%08x ", $kgm_kmodp->size
printf "%3d ", $kgm_kmodp->id
printf "%5d ", $kgm_kmodp->reference_count
printf "%10s ", &$kgm_kmodp->version
printf "%s\n", &$kgm_kmodp->name
end
set $kgm_kmodmin = 0xffffffff
set $kgm_fkmodmin = 0x00000000
set $kgm_kmodmax = 0x00000000
set $kgm_fkmodmax = 0xffffffff
set $kgm_pkmod = 0
set $kgm_pkmodst = 0
set $kgm_pkmoden = 0
define showkmodaddrint
printf "0x%x" , $arg0
if ((unsigned int)$arg0 >= (unsigned int)$kgm_pkmodst) && ((unsigned int)$arg0 <= (unsigned int)$kgm_pkmoden)
set $kgm_off = ((unsigned int)$arg0 - (unsigned int)$kgm_pkmodst)
printf " <%s + 0x%x>", $kgm_pkmod->name, $kgm_off
else
if ((unsigned int)$arg0 <= (unsigned int)$kgm_fkmodmax) && ((unsigned int)$arg0 >= (unsigned int)$kgm_fkmodmin)
set $kgm_kmodp = (struct kmod_info *)kmod
while $kgm_kmodp
set $kgm_kmod = *$kgm_kmodp
if $kgm_kmod.address && ($kgm_kmod.address < $kgm_kmodmin)
set $kgm_kmodmin = $kgm_kmod.address
end
if ($kgm_kmod.address + $kgm_kmod.size) > $kgm_kmodmax
set $kgm_kmodmax = $kgm_kmod.address + $kgm_kmod.size
end
set $kgm_off = ((unsigned int)$arg0 - (unsigned int)$kgm_kmod.address)
if ($kgm_kmod.address <= $arg0) && ($kgm_off <= $kgm_kmod.size)
printf " <%s + 0x%x>", $kgm_kmodp->name, $kgm_off
set $kgm_pkmod = $kgm_kmodp
set $kgm_pkmodst = $kgm_kmod.address
set $kgm_pkmoden = $kgm_pkmodst + $kgm_kmod.size
set $kgm_kmodp = 0
else
set $kgm_kmodp = $kgm_kmod.next
end
end
if !$kgm_pkmod
set $kgm_fkmodmin = $kgm_kmodmin
set $kgm_fkmodmax = $kgm_kmodmax
end
end
end
end
define showkmodaddr
showkmodaddrint $arg0
end
document showkmodaddr
Syntax: (gdb) showkmodaddr <addr>
| Given an address, print the offset and name for the kmod containing it
end
define showkmod
showkmodheader
showkmodint $arg0
end
document showkmod
Syntax: (gdb) showkmod <kmod>
| Routine to print info about a kernel module
end
define showallkmods
showkmodheader
set $kgm_kmodp = (struct kmod_info *)kmod
while $kgm_kmodp
showkmodint $kgm_kmodp
set $kgm_kmodp = $kgm_kmodp->next
end
end
document showallkmods
Syntax: (gdb) showallkmods
| Routine to print a summary listing of all the kernel modules
end
define showactheader
printf " thread "
printf "processor pri state wait_queue wait_event\n"
end
define showactint
printf " 0x%08x ", $arg0
set $kgm_thread = *(struct thread *)$arg0
printf "0x%08x ", $kgm_thread.last_processor
printf "%3d ", $kgm_thread.sched_pri
set $kgm_state = $kgm_thread.state
if $kgm_state & 0x80
printf "I"
end
if $kgm_state & 0x40
printf "P"
end
if $kgm_state & 0x20
printf "A"
end
if $kgm_state & 0x10
printf "H"
end
if $kgm_state & 0x08
printf "U"
end
if $kgm_state & 0x04
printf "R"
end
if $kgm_state & 0x02
printf "S"
end
if $kgm_state & 0x01
printf "W\t"
printf "0x%08x ", $kgm_thread.wait_queue
if (((unsigned)$kgm_thread.wait_event > (unsigned)sectPRELINKB) \
&& ($arg1 != 2) && ($kgm_show_kmod_syms == 0))
showkmodaddr $kgm_thread.wait_event
else
output /a (unsigned) $kgm_thread.wait_event
end
if ($kgm_thread.uthread != 0)
set $kgm_uthread = (struct uthread *)$kgm_thread.uthread
if ($kgm_uthread->uu_wmesg != 0)
printf " \"%s\"", $kgm_uthread->uu_wmesg
end
end
end
if $arg1 != 0
if ($kgm_thread.kernel_stack != 0)
if ($kgm_thread.reserved_stack != 0)
printf "\n\t\treserved_stack=0x%08x", $kgm_thread.reserved_stack
end
printf "\n\t\tkernel_stack=0x%08x", $kgm_thread.kernel_stack
if ($kgm_mtype == 18)
set $mysp = $kgm_thread.machine.pcb->save_r1
end
if ($kgm_mtype == 7)
set $kgm_statep = (struct x86_kernel_state32 *) \
($kgm_thread->kernel_stack + 0x4000 \
- sizeof(struct x86_kernel_state32))
set $mysp = $kgm_statep->k_ebp
end
if ($kgm_mtype == 12)
if ($arg0 == $r9)
set $mysp = $r7
else
set $kgm_statep = (struct arm_saved_state *)$kgm_thread.machine.kstackptr
set $mysp = $kgm_statep->r[7]
end
end
set $prevsp = $mysp - 16
printf "\n\t\tstacktop=0x%08x", $mysp
if ($kgm_mtype == 18)
set $stkmask = 0xf
else
set $stkmask = 0x3
end
set $kgm_return = 0
while ($mysp != 0) && (($mysp & $stkmask) == 0) \
&& ($mysp != $prevsp) \
&& ((((unsigned) $mysp ^ (unsigned) $prevsp) < 0x2000) \
|| (((unsigned)$mysp < ((unsigned) ($kgm_thread->kernel_stack+0x4000))) \
&& ((unsigned)$mysp > (unsigned) ($kgm_thread->kernel_stack))))
printf "\n\t\t0x%08x ", $mysp
if ($kgm_mtype == 18)
set $kgm_return = *($mysp + 8)
end
if ($kgm_mtype == 7)
set $kgm_return = *($mysp + 4)
end
if ($kgm_mtype == 12)
set $kgm_return = *($mysp + 4)
end
if (((unsigned) $kgm_return > (unsigned) sectPRELINKB) \
&& ($kgm_show_kmod_syms == 0))
showkmodaddr $kgm_return
else
output /a (unsigned) $kgm_return
end
set $prevsp = $mysp
set $mysp = * $mysp
end
set $kgm_return = 0
printf "\n\t\tstackbottom=0x%08x", $prevsp
else
printf "\n\t\t\tcontinuation="
output /a (unsigned) $kgm_thread.continuation
end
printf "\n"
else
printf "\n"
end
end
define showact
showactheader
showactint $arg0 0
end
document showact
Syntax: (gdb) showact <activation>
| Routine to print out the state of a specific thread.
end
define showactstack
showactheader
showactint $arg0 1
end
document showactstack
Syntax: (gdb) showactstack <activation>
| Routine to print out the stack of a specific thread.
end
define showallthreads
set $kgm_head_taskp = &tasks
set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_taskp != $kgm_head_taskp
showtaskheader
showtaskint $kgm_taskp
showactheader
set $kgm_head_actp = &($kgm_taskp->threads)
set $kgm_actp = (struct thread *)($kgm_taskp->threads.next)
while $kgm_actp != $kgm_head_actp
showactint $kgm_actp 0
set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
end
printf "\n"
set $kgm_taskp = (struct task *)($kgm_taskp->tasks.next)
end
end
document showallthreads
Syntax: (gdb) showallthreads
| Routine to print out info about all threads in the system.
end
define showcurrentthreads
set $kgm_prp = (struct processor *)processor_list
while $kgm_prp != 0
if ($kgm_prp)->active_thread != 0
set $kgm_actp = ($kgm_prp)->active_thread
showtaskheader
showtaskint ($kgm_actp)->task
showactheader
showactint $kgm_actp 0
printf "\n"
end
set $kgm_prp = ($kgm_prp)->processor_list
end
end
document showcurrentthreads
Syntax: (gdb) showcurrentthreads
| Routine to print out info about the thread running on each cpu.
end
set $decode_wait_events = 0
define showallstacks
set $kgm_head_taskp = &tasks
set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_taskp != $kgm_head_taskp
showtaskheader
showtaskint $kgm_taskp
set $kgm_head_actp = &($kgm_taskp->threads)
set $kgm_actp = (struct thread *)($kgm_taskp->threads.next)
while $kgm_actp != $kgm_head_actp
showactheader
if ($decode_wait_events > 0)
showactint $kgm_actp 1
else
showactint $kgm_actp 2
end
set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
end
printf "\n"
set $kgm_taskp = (struct task *)($kgm_taskp->tasks.next)
end
end
document showallstacks
Syntax: (gdb) showallstacks
| Routine to print out the stack for each thread in the system.
| If the variable $decode_wait_events is non-zero, the routine attempts to
| interpret thread wait_events as kernel module offsets, which can add to
| processing time.
end
define showcurrentstacks
set $kgm_prp = processor_list
while $kgm_prp != 0
if ($kgm_prp)->active_thread != 0
set $kgm_actp = ($kgm_prp)->active_thread
showtaskheader
showtaskint ($kgm_actp)->task
showactheader
showactint $kgm_actp 1
printf "\n"
end
set $kgm_prp = ($kgm_prp)->processor_list
end
end
document showcurrentstacks
Syntax: (gdb) showcurrentstacks
| Routine to print out the thread running on each cpu (incl. its stack)
end
define showwaiterheader
printf "waiters activation "
printf "thread pri state wait_queue wait_event\n"
end
define showwaitqwaiters
set $kgm_w_waitqp = (struct wait_queue *)$arg0
set $kgm_w_linksp = &($kgm_w_waitqp->wq_queue)
set $kgm_w_wqe = (struct wait_queue_element *)$kgm_w_linksp->next
set $kgm_w_found = 0
while ( (queue_entry_t)$kgm_w_wqe != (queue_entry_t)$kgm_w_linksp)
if ($kgm_w_wqe->wqe_type != &_wait_queue_link)
if !$kgm_w_found
set $kgm_w_found = 1
showwaiterheader
end
set $kgm_w_shuttle = (struct thread *)$kgm_w_wqe
showactint $kgm_w_shuttle 0
end
set $kgm_w_wqe = (struct wait_queue_element *)$kgm_w_wqe->wqe_links.next
end
end
define showwaitqwaitercount
set $kgm_wc_waitqp = (struct wait_queue *)$arg0
set $kgm_wc_linksp = &($kgm_wc_waitqp->wq_queue)
set $kgm_wc_wqe = (struct wait_queue_element *)$kgm_wc_linksp->next
set $kgm_wc_count = 0
while ( (queue_entry_t)$kgm_wc_wqe != (queue_entry_t)$kgm_wc_linksp)
if ($kgm_wc_wqe->wqe_type != &_wait_queue_link)
set $kgm_wc_count = $kgm_wc_count + 1
end
set $kgm_wc_wqe = (struct wait_queue_element *)$kgm_wc_wqe->wqe_links.next
end
printf "0x%08x ", $kgm_wc_count
end
define showwaitqmembercount
set $kgm_mc_waitqsetp = (struct wait_queue_set *)$arg0
set $kgm_mc_setlinksp = &($kgm_mc_waitqsetp->wqs_setlinks)
set $kgm_mc_wql = (struct wait_queue_link *)$kgm_mc_setlinksp->next
set $kgm_mc_count = 0
while ( (queue_entry_t)$kgm_mc_wql != (queue_entry_t)$kgm_mc_setlinksp)
set $kgm_mc_count = $kgm_mc_count + 1
set $kgm_mc_wql = (struct wait_queue_link *)$kgm_mc_wql->wql_setlinks.next
end
printf "0x%08x ", $kgm_mc_count
end
define showwaitqmemberheader
printf "set-members wait_queue interlock "
printf "pol type member_cnt waiter_cnt\n"
end
define showwaitqmemberint
set $kgm_m_waitqp = (struct wait_queue *)$arg0
printf " 0x%08x ", $kgm_m_waitqp
printf "0x%08x ", $kgm_m_waitqp->wq_interlock.lock_data
if ($kgm_m_waitqp->wq_fifo)
printf "Fifo "
else
printf "Prio "
end
if ($kgm_m_waitqp->wq_type == 0xf1d1)
printf "Set "
showwaitqmembercount $kgm_m_waitqp
else
printf "Que 0x00000000 "
end
showwaitqwaitercount $kgm_m_waitqp
printf "\n"
end
define showwaitqmemberofheader
printf "member-of wait_queue interlock "
printf "pol type member_cnt waiter_cnt\n"
end
define showwaitqmemberof
set $kgm_mo_waitqp = (struct wait_queue *)$arg0
set $kgm_mo_linksp = &($kgm_mo_waitqp->wq_queue)
set $kgm_mo_wqe = (struct wait_queue_element *)$kgm_mo_linksp->next
set $kgm_mo_found = 0
while ( (queue_entry_t)$kgm_mo_wqe != (queue_entry_t)$kgm_mo_linksp)
if ($kgm_mo_wqe->wqe_type == &_wait_queue_link)
if !$kgm_mo_found
set $kgm_mo_found = 1
showwaitqmemberofheader
end
set $kgm_mo_wqlp = (struct wait_queue_link *)$kgm_mo_wqe
set $kgm_mo_wqsetp = (struct wait_queue *)($kgm_mo_wqlp->wql_setqueue)
showwaitqmemberint $kgm_mo_wqsetp
end
set $kgm_mo_wqe = (struct wait_queue_element *)$kgm_mo_wqe->wqe_links.next
end
end
define showwaitqmembers
set $kgm_ms_waitqsetp = (struct wait_queue_set *)$arg0
set $kgm_ms_setlinksp = &($kgm_ms_waitqsetp->wqs_setlinks)
set $kgm_ms_wql = (struct wait_queue_link *)$kgm_ms_setlinksp->next
set $kgm_ms_found = 0
while ( (queue_entry_t)$kgm_ms_wql != (queue_entry_t)$kgm_ms_setlinksp)
set $kgm_ms_waitqp = $kgm_ms_wql->wql_element.wqe_queue
if !$kgm_ms_found
showwaitqmemberheader
set $kgm_ms_found = 1
end
showwaitqmemberint $kgm_ms_waitqp
set $kgm_ms_wql = (struct wait_queue_link *)$kgm_ms_wql->wql_setlinks.next
end
end
define showwaitqheader
printf "wait_queue ref_count interlock "
printf "pol type member_cnt waiter_cnt\n"
end
define showwaitqint
set $kgm_waitqp = (struct wait_queue *)$arg0
printf "0x%08x ", $kgm_waitqp
if ($kgm_waitqp->wq_type == 0xf1d1)
printf "0x%08x ", ((struct wait_queue_set *)$kgm_waitqp)->wqs_refcount
else
printf "0x00000000 "
end
printf "0x%08x ", $kgm_waitqp->wq_interlock.lock_data
if ($kgm_waitqp->wq_fifo)
printf "Fifo "
else
printf "Prio "
end
if ($kgm_waitqp->wq_type == 0xf1d1)
printf "Set "
showwaitqmembercount $kgm_waitqp
else
printf "Que 0x00000000 "
end
showwaitqwaitercount $kgm_waitqp
printf "\n"
end
define showwaitq
set $kgm_waitq1p = (wait_queue_t)$arg0
showwaitqheader
showwaitqint $kgm_waitq1p
if ($kgm_waitq1p->wq_type == 0xf1d1)
showwaitqmembers $kgm_waitq1p
else
showwaitqmemberof $kgm_waitq1p
end
showwaitqwaiters $kgm_waitq1p
end
define showmapheader
printf "vm_map pmap vm_size "
printf "#ents rpage hint first_free\n"
end
define showvmeheader
printf " entry start "
printf " prot #page object offset\n"
end
define showvmint
set $kgm_mapp = (vm_map_t)$arg0
set $kgm_map = *$kgm_mapp
printf "0x%08x ", $arg0
printf "0x%08x ", $kgm_map.pmap
printf "0x%08x ", $kgm_map.size
printf "%3d ", $kgm_map.hdr.nentries
if $kgm_map.pmap
printf "%5d ", $kgm_map.pmap->stats.resident_count
else
printf "<n/a> "
end
printf "0x%08x ", $kgm_map.hint
printf "0x%08x\n", $kgm_map.first_free
if $arg1 != 0
showvmeheader
set $kgm_head_vmep = &($kgm_mapp->hdr.links)
set $kgm_vmep = $kgm_map.hdr.links.next
while (($kgm_vmep != 0) && ($kgm_vmep != $kgm_head_vmep))
set $kgm_vme = *$kgm_vmep
printf " 0x%08x ", $kgm_vmep
printf "0x%016llx ", $kgm_vme.links.start
printf "%1x", $kgm_vme.protection
printf "%1x", $kgm_vme.max_protection
if $kgm_vme.inheritance == 0x0
printf "S"
end
if $kgm_vme.inheritance == 0x1
printf "C"
end
if $kgm_vme.inheritance == 0x2
printf "-"
end
if $kgm_vme.inheritance == 0x3
printf "D"
end
if $kgm_vme.is_sub_map
printf "s "
else
if $kgm_vme.needs_copy
printf "n "
else
printf " "
end
end
printf "%5d ",($kgm_vme.links.end - $kgm_vme.links.start) >> 12
printf "0x%08x ", $kgm_vme.object.vm_object
printf "0x%016llx\n", $kgm_vme.offset
set $kgm_vmep = $kgm_vme.links.next
end
end
printf "\n"
end
define showmapvme
showmapheader
showvmint $arg0 1
end
document showmapvme
Syntax: (gdb) showmapvme <vm_map>
| Routine to print out a summary listing of all the entries in a vm_map
end
define showmap
showmapheader
showvmint $arg0 0
end
document showmap
Syntax: (gdb) showmap <vm_map>
| Routine to print out info about the specified vm_map
end
define showallvm
set $kgm_head_taskp = &tasks
set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_taskp != $kgm_head_taskp
showtaskheader
showmapheader
showtaskint $kgm_taskp
showvmint $kgm_taskp->map 0
set $kgm_taskp = (struct task *)($kgm_taskp->tasks.next)
end
end
document showallvm
Syntax: (gdb) showallvm
| Routine to print a summary listing of all the vm maps
end
define showallvme
set $kgm_head_taskp = &tasks
set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_taskp != $kgm_head_taskp
showtaskheader
showmapheader
showtaskint $kgm_taskp
showvmint $kgm_taskp->map 1
set $kgm_taskp = (struct task *)($kgm_taskp->tasks.next)
end
end
document showallvme
Syntax: (gdb) showallvme
| Routine to print a summary listing of all the vm map entries
end
define showipcheader
printf "ipc_space is_table table_next "
printf "flags tsize splaytree splaybase\n"
end
define showipceheader
printf " name object "
printf "rite urefs destname destination\n"
end
define showipceint
set $kgm_ie = *(ipc_entry_t)$arg0
printf " 0x%08x ", $arg1
printf "0x%08x ", $kgm_ie.ie_object
if $kgm_ie.ie_bits & 0x00100000
printf "Dead "
printf "%5d\n", $kgm_ie.ie_bits & 0xffff
else
if $kgm_ie.ie_bits & 0x00080000
printf "SET "
printf "%5d\n", $kgm_ie.ie_bits & 0xffff
else
if $kgm_ie.ie_bits & 0x00010000
if $kgm_ie.ie_bits & 0x00020000
printf " SR"
else
printf " S"
end
else
if $kgm_ie.ie_bits & 0x00020000
printf " R"
end
end
if $kgm_ie.ie_bits & 0x00040000
printf " O"
end
if $kgm_ie.index.request
printf "n"
else
printf " "
end
if $kgm_ie.ie_bits & 0x00800000
printf "c"
else
printf " "
end
printf "%5d ", $kgm_ie.ie_bits & 0xffff
showportdest $kgm_ie.ie_object
end
end
end
define showipcint
set $kgm_isp = (ipc_space_t)$arg0
set $kgm_is = *$kgm_isp
printf "0x%08x ", $arg0
printf "0x%08x ", $kgm_is.is_table
printf "0x%08x ", $kgm_is.is_table_next
if $kgm_is.is_growing != 0
printf "G"
else
printf " "
end
if $kgm_is.is_fast != 0
printf "F"
else
printf " "
end
if $kgm_is.is_active != 0
printf "A "
else
printf " "
end
printf "%5d ", $kgm_is.is_table_size
printf "0x%08x ", $kgm_is.is_tree_total
printf "0x%08x\n", &$kgm_isp->is_tree
if $arg1 != 0
showipceheader
set $kgm_iindex = 0
set $kgm_iep = $kgm_is.is_table
set $kgm_destspacep = (ipc_space_t)0
while ( $kgm_iindex < $kgm_is.is_table_size )
set $kgm_ie = *$kgm_iep
if $kgm_ie.ie_bits & 0x001f0000
set $kgm_name = (($kgm_iindex << 8)|($kgm_ie.ie_bits >> 24))
showipceint $kgm_iep $kgm_name
end
set $kgm_iindex = $kgm_iindex + 1
set $kgm_iep = &($kgm_is.is_table[$kgm_iindex])
end
if $kgm_is.is_tree_total
printf "Still need to write tree traversal\n"
end
end
printf "\n"
end
define showipc
set $kgm_isp = (ipc_space_t)$arg0
showipcheader
showipcint $kgm_isp 0
end
document showipc
Syntax: (gdb) showipc <ipc_space>
| Routine to print the status of the specified ipc space
end
define showrights
set $kgm_isp = (ipc_space_t)$arg0
showipcheader
showipcint $kgm_isp 1
end
document showrights
Syntax: (gdb) showrights <ipc_space>
| Routine to print a summary list of all the rights in a specified ipc space
end
define showtaskipc
set $kgm_taskp = (task_t)$arg0
showtaskheader
showipcheader
showtaskint $kgm_taskp
showipcint $kgm_taskp->itk_space 0
end
document showtaskipc
Syntax: (gdb) showtaskipc <task>
| Routine to print info about the ipc space for a task
end
define showtaskrights
set $kgm_taskp = (task_t)$arg0
showtaskheader
showipcheader
showtaskint $kgm_taskp
showipcint $kgm_taskp->itk_space 1
end
document showtaskrights
Syntax: (gdb) showtaskrights <task>
| Routine to print info about the ipc rights for a task
end
define showallipc
set $kgm_head_taskp = &tasks
set $kgm_cur_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_cur_taskp != $kgm_head_taskp
showtaskheader
showipcheader
showtaskint $kgm_cur_taskp
showipcint $kgm_cur_taskp->itk_space 0
set $kgm_cur_taskp = (struct task *)($kgm_cur_taskp->tasks.next)
end
end
document showallipc
Syntax: (gdb) showallipc
| Routine to print a summary listing of all the ipc spaces
end
define showallrights
set $kgm_head_taskp = &tasks
set $kgm_cur_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_cur_taskp != $kgm_head_taskp
showtaskheader
showipcheader
showtaskint $kgm_cur_taskp
showipcint $kgm_cur_taskp->itk_space 1
set $kgm_cur_taskp = (struct task *)($kgm_cur_taskp->tasks.next)
end
end
document showallrights
Syntax: (gdb) showallrights
| Routine to print a summary listing of all the ipc rights
end
define showtaskvm
set $kgm_taskp = (task_t)$arg0
showtaskheader
showmapheader
showtaskint $kgm_taskp
showvmint $kgm_taskp->map 0
end
document showtaskvm
Syntax: (gdb) showtaskvm <task>
| Routine to print out info about a task's vm_map
end
define showtaskvme
set $kgm_taskp = (task_t)$arg0
showtaskheader
showmapheader
showtaskint $kgm_taskp
showvmint $kgm_taskp->map 1
end
document showtaskvme
Syntax: (gdb) showtaskvme <task>
| Routine to print out info about a task's vm_map_entries
end