4 # These gdb macros should be useful during kernel development in
5 # determining what's going on in the kernel.
7 # All the convenience variables used by these macros begin with $kgm_
9 set $kgm_dummy = &proc0
10 set $kgm_dummy = &kmod
12 echo Loading Kernel GDB Macros package. Type "help kgm" for more info.\n
16 echo These are the gdb macros for kernel debugging. Type "help kgm" for more info.\n
20 | These are the kernel gdb macros. These gdb macros are intended to be
21 | used when debugging a remote kernel via the kdp protocol. Typically, you
22 | would connect to your remote target like so:
23 | (gdb) target remote-kdp
24 | (gdb) attach <name-of-remote-host>
26 | The following macros are available in this package:
28 | showalltasks Display a summary listing of all tasks
29 | showallthreads Display info about all threads in the system
30 | showallstacks Display the stack for each thread in the system
31 | showcurrentthreads Display info about the thread running on each cpu
32 | showcurrentstacks Display the stack for the thread running on each cpu
33 | showallvm Display a summary listing of all the vm maps
34 | showallvme Display a summary listing of all the vm map entries
35 | showallipc Display a summary listing of all the ipc spaces
36 | showallrights Display a summary listing of all the ipc rights
37 | showallkmods Display a summary listing of all the kernel modules
39 | showtask Display info about the specified task
40 | showtaskthreads Display info about the threads in the task
41 | showtaskstacks Display the stack for each thread in the task
42 | showtaskvm Display info about the specified task's vm_map
43 | showtaskvme Display info about the task's vm_map entries
44 | showtaskipc Display info about the specified task's ipc space
45 | showtaskrights Display info about the task's ipc space entries
47 | showact Display info about a thread specified by activation
48 | showactstack Display the stack for a thread specified by activation
50 | showmap Display info about the specified vm_map
51 | showmapvme Display a summary list of the specified vm_map's entries
53 | showipc Display info about the specified ipc space
54 | showrights Display a summary list of all the rights in an ipc space
56 | showpid Display info about the process identified by pid
57 | showproc Display info about the process identified by proc struct
59 | showkmod Display info about a kernel module
60 | showkmodaddr Given an address, display the kernel module and offset
62 | dumpcallqueue Dump out all the entries given a queue head
64 | zprint Display info about the memory zones
65 | paniclog Display the panic log info
67 | switchtoact Switch to different context specified by activation
68 | switchtoctx Switch to different context
69 | resetctx Reset context
70 | resume_on Resume when detaching from gdb
71 | resume_off Don't resume when detaching from gdb
73 | Type "help <macro>" for more specific help on a particular macro.
74 | Type "show user <macro>" to see what the macro is really doing.
79 printf "kmod address size "
80 printf "id refs version name\n"
84 set $kgm_kmodp = (struct kmod_info *)$arg0
85 printf "0x%08x ", $arg0
86 printf "0x%08x ", $kgm_kmodp->address
87 printf "0x%08x ", $kgm_kmodp->size
88 printf "%3d ", $kgm_kmodp->id
89 printf "%5d ", $kgm_kmodp->reference_count
90 printf "%10s ", &$kgm_kmodp->version
91 printf "%s\n", &$kgm_kmodp->name
94 set $kgm_kmodmin = 0xffffffff
95 set $kgm_fkmodmin = 0x00000000
96 set $kgm_kmodmax = 0x00000000
97 set $kgm_fkmodmax = 0xffffffff
102 printf "0x%x" , $arg0
103 if ((unsigned int)$arg0 >= (unsigned int)$kgm_pkmodst) && ((unsigned int)$arg0 <= (unsigned int)$kgm_pkmoden)
104 set $kgm_off = ((unsigned int)$arg0 - (unsigned int)$kgm_pkmodst)
105 printf " <%s + 0x%x>", $kgm_pkmod->name, $kgm_off
107 if ((unsigned int)$arg0 <= (unsigned int)$kgm_fkmodmax) && ((unsigned int)$arg0 >= (unsigned int)$kgm_fkmodmin)
108 set $kgm_kmodp = (struct kmod_info *)kmod
110 set $kgm_kmod = *$kgm_kmodp
111 if $kgm_kmod.address && ($kgm_kmod.address < $kgm_kmodmin)
112 set $kgm_kmodmin = $kgm_kmod.address
114 if ($kgm_kmod.address + $kgm_kmod.size) > $kgm_kmodmax
115 set $kgm_kmodmax = $kgm_kmod.address
117 set $kgm_off = ((unsigned int)$arg0 - (unsigned int)$kgm_kmod.address)
118 if ($kgm_kmod.address <= $arg0) && ($kgm_off <= $kgm_kmod.size)
119 printf " <%s + 0x%x>", $kgm_kmodp->name, $kgm_off
120 set $kgm_pkmod = $kgm_kmodp
121 set $kgm_pkmodst = $kgm_kmod.address
122 set $kgm_pkmoden = $kgm_pkmodst + $kgm_kmod.size
125 set $kgm_kmodp = $kgm_kmod.next
129 set $kgm_fkmodmin = $kgm_kmodmin
130 set $kgm_fkmodmax = $kgm_kmodmax
135 document showkmodaddr
136 | Given an address, print the offset and name for the kmod containing it
137 | The following is the syntax:
138 | (gdb) showkmodaddr <addr>
146 | Routine to print info about a kernel module
147 | The following is the syntax:
148 | (gdb) showkmod <kmod>
153 set $kgm_kmodp = (struct kmod_info *)kmod
155 showkmodint $kgm_kmodp
156 set $kgm_kmodp = $kgm_kmodp->next
159 document showallkmods
160 | Routine to print a summary listing of all the kernel modules
161 | The following is the syntax:
166 printf " activation "
167 printf "thread pri state wait_queue wait_event\n"
172 printf " 0x%08x ", $arg0
173 set $kgm_actp = *(struct thread *)$arg0
175 set $kgm_thread = *$kgm_actp.thread
176 printf "0x%08x ", $kgm_actp.thread
177 printf "%3d ", $kgm_thread.sched_pri
178 set $kgm_state = $kgm_thread.state
202 printf "0x%08x ", $kgm_thread.wait_queue
203 output /a $kgm_thread.wait_event
206 if ($kgm_thread.kernel_stack != 0)
207 if ($kgm_thread.reserved_stack != 0)
208 printf "\n\t\treserved_stack=0x%08x", $kgm_thread.reserved_stack
210 printf "\n\t\tkernel_stack=0x%08x", $kgm_thread.kernel_stack
211 if (machine_slot[0].cpu_type == 18)
212 set $mysp = $kgm_actp->mact.pcb->save_r1
214 set $kgm_statep = (struct i386_kernel_state *)($kgm_thread->kernel_stack + 0x4000 - sizeof(stru\
215 ct i386_kernel_state))
216 set $mysp = $kgm_statep->k_ebp
219 printf "\n\t\tstacktop=0x%08x", $mysp
220 while ($mysp != 0) && (($mysp & 0xf) == 0) && ($mysp < 0xb0000000) && ($mysp > $prevsp)
221 printf "\n\t\t0x%08x ", $mysp
222 if (machine_slot[0].cpu_type == 18)
223 set $kgm_return = *($mysp + 8)
225 set $kgm_return = *($mysp + 4)
227 if ($kgm_return > sectPRELINKB)
228 showkmodaddr $kgm_return
230 if (machine_slot[0].cpu_type == 18)
231 output /a * ($mysp + 8)
233 output /a * ($mysp + 4)
239 printf "\n\t\tstackbottom=0x%08x", $prevsp
241 printf "\n\t\t\tcontinuation="
242 output /a $kgm_thread.continuation
256 | Routine to print out the state of a specific thread.
257 | The following is the syntax:
258 | (gdb) showact <activation>
266 document showactstack
267 | Routine to print out the stack of a specific thread.
268 | The following is the syntax:
269 | (gdb) showactstack <activation>
273 define showallthreads
274 set $kgm_head_taskp = &default_pset.tasks
275 set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
276 while $kgm_taskp != $kgm_head_taskp
278 showtaskint $kgm_taskp
280 set $kgm_head_actp = &($kgm_taskp->threads)
281 set $kgm_actp = (struct thread *)($kgm_taskp->threads.next)
282 while $kgm_actp != $kgm_head_actp
283 showactint $kgm_actp 0
284 set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
287 set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
290 document showallthreads
291 | Routine to print out info about all threads in the system.
292 | The following is the syntax:
293 | (gdb) showallthreads
296 define showcurrentthreads
297 set $kgm_ncpus = machine_info.max_cpus
299 while $kgm_i < $kgm_ncpus
300 set $kgm_prp = processor_ptr[$kgm_i]
301 if ($kgm_prp != 0) && (($kgm_prp)->active_thread != 0)
302 set $kgm_actp = (($kgm_prp)->active_thread)->top_act
304 showtaskint ($kgm_actp)->task
306 showactint $kgm_actp 0
309 set $kgm_i = $kgm_i + 1
312 document showcurrentthreads
313 | Routine to print out info about the thread running on each cpu.
314 | The following is the syntax:
315 | (gdb) showcurrentthreads
319 set $kgm_head_taskp = &default_pset.tasks
320 set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
321 while $kgm_taskp != $kgm_head_taskp
323 showtaskint $kgm_taskp
324 set $kgm_head_actp = &($kgm_taskp->threads)
325 set $kgm_actp = (struct thread *)($kgm_taskp->threads.next)
326 while $kgm_actp != $kgm_head_actp
328 showactint $kgm_actp 1
329 set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
332 set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
335 document showallstacks
336 | Routine to print out the stack for each thread in the system.
337 | The following is the syntax:
338 | (gdb) showallstacks
341 define showcurrentstacks
342 set $kgm_ncpus = machine_info.max_cpus
344 while $kgm_i < $kgm_ncpus
345 set $kgm_prp = processor_ptr[$kgm_i]
346 if ($kgm_prp != 0) && (($kgm_prp)->active_thread != 0)
347 set $kgm_actp = (($kgm_prp)->active_thread)->top_act
349 showtaskint ($kgm_actp)->task
351 showactint $kgm_actp 1
354 set $kgm_i = $kgm_i + 1
357 document showcurrentstacks
358 | Routine to print out the thread running on each cpu (incl. its stack)
359 | The following is the syntax:
360 | (gdb) showcurrentstacks
363 define showwaiterheader
364 printf "waiters activation "
365 printf "thread pri state wait_queue wait_event\n"
368 define showwaitqwaiters
369 set $kgm_w_waitqp = (struct wait_queue *)$arg0
370 set $kgm_w_linksp = &($kgm_w_waitqp->wq_queue)
371 set $kgm_w_wqe = (struct wait_queue_element *)$kgm_w_linksp->next
373 while ( (queue_entry_t)$kgm_w_wqe != (queue_entry_t)$kgm_w_linksp)
374 if ($kgm_w_wqe->wqe_type != &_wait_queue_link)
379 set $kgm_w_shuttle = (struct thread *)$kgm_w_wqe
380 showactint $kgm_w_shuttle->top_act 0
382 set $kgm_w_wqe = (struct wait_queue_element *)$kgm_w_wqe->wqe_links.next
386 define showwaitqwaitercount
387 set $kgm_wc_waitqp = (struct wait_queue *)$arg0
388 set $kgm_wc_linksp = &($kgm_wc_waitqp->wq_queue)
389 set $kgm_wc_wqe = (struct wait_queue_element *)$kgm_wc_linksp->next
390 set $kgm_wc_count = 0
391 while ( (queue_entry_t)$kgm_wc_wqe != (queue_entry_t)$kgm_wc_linksp)
392 if ($kgm_wc_wqe->wqe_type != &_wait_queue_link)
393 set $kgm_wc_count = $kgm_wc_count + 1
395 set $kgm_wc_wqe = (struct wait_queue_element *)$kgm_wc_wqe->wqe_links.next
397 printf "0x%08x ", $kgm_wc_count
400 define showwaitqmembercount
401 set $kgm_mc_waitqsetp = (struct wait_queue_set *)$arg0
402 set $kgm_mc_setlinksp = &($kgm_mc_waitqsetp->wqs_setlinks)
403 set $kgm_mc_wql = (struct wait_queue_link *)$kgm_mc_setlinksp->next
404 set $kgm_mc_count = 0
405 while ( (queue_entry_t)$kgm_mc_wql != (queue_entry_t)$kgm_mc_setlinksp)
406 set $kgm_mc_count = $kgm_mc_count + 1
407 set $kgm_mc_wql = (struct wait_queue_link *)$kgm_mc_wql->wql_setlinks.next
409 printf "0x%08x ", $kgm_mc_count
413 define showwaitqmemberheader
414 printf "set-members wait_queue interlock "
415 printf "pol type member_cnt waiter_cnt\n"
418 define showwaitqmemberint
419 set $kgm_m_waitqp = (struct wait_queue *)$arg0
420 printf " 0x%08x ", $kgm_m_waitqp
421 printf "0x%08x ", $kgm_m_waitqp->wq_interlock.lock_data
422 if ($kgm_m_waitqp->wq_fifo)
427 if ($kgm_m_waitqp->wq_type == 0xf1d1)
429 showwaitqmembercount $kgm_m_waitqp
431 printf "Que 0x00000000 "
433 showwaitqwaitercount $kgm_m_waitqp
438 define showwaitqmemberofheader
439 printf "member-of wait_queue interlock "
440 printf "pol type member_cnt waiter_cnt\n"
443 define showwaitqmemberof
444 set $kgm_mo_waitqp = (struct wait_queue *)$arg0
445 set $kgm_mo_linksp = &($kgm_mo_waitqp->wq_queue)
446 set $kgm_mo_wqe = (struct wait_queue_element *)$kgm_mo_linksp->next
447 set $kgm_mo_found = 0
448 while ( (queue_entry_t)$kgm_mo_wqe != (queue_entry_t)$kgm_mo_linksp)
449 if ($kgm_mo_wqe->wqe_type == &_wait_queue_link)
451 set $kgm_mo_found = 1
452 showwaitqmemberofheader
454 set $kgm_mo_wqlp = (struct wait_queue_link *)$kgm_mo_wqe
455 set $kgm_mo_wqsetp = (struct wait_queue *)($kgm_mo_wqlp->wql_setqueue)
456 showwaitqmemberint $kgm_mo_wqsetp
458 set $kgm_mo_wqe = (struct wait_queue_element *)$kgm_mo_wqe->wqe_links.next
462 define showwaitqmembers
463 set $kgm_ms_waitqsetp = (struct wait_queue_set *)$arg0
464 set $kgm_ms_setlinksp = &($kgm_ms_waitqsetp->wqs_setlinks)
465 set $kgm_ms_wql = (struct wait_queue_link *)$kgm_ms_setlinksp->next
466 set $kgm_ms_found = 0
467 while ( (queue_entry_t)$kgm_ms_wql != (queue_entry_t)$kgm_ms_setlinksp)
468 set $kgm_ms_waitqp = $kgm_ms_wql->wql_element.wqe_queue
470 showwaitqmemberheader
471 set $kgm_ms_found = 1
473 showwaitqmemberint $kgm_ms_waitqp
474 set $kgm_ms_wql = (struct wait_queue_link *)$kgm_ms_wql->wql_setlinks.next
478 define showwaitqheader
479 printf "wait_queue ref_count interlock "
480 printf "pol type member_cnt waiter_cnt\n"
484 set $kgm_waitqp = (struct wait_queue *)$arg0
485 printf "0x%08x ", $kgm_waitqp
486 if ($kgm_waitqp->wq_type == 0xf1d1)
487 printf "0x%08x ", ((struct wait_queue_set *)$kgm_waitqp)->wqs_refcount
491 printf "0x%08x ", $kgm_waitqp->wq_interlock.lock_data
492 if ($kgm_waitqp->wq_fifo)
497 if ($kgm_waitqp->wq_type == 0xf1d1)
499 showwaitqmembercount $kgm_waitqp
501 printf "Que 0x00000000 "
503 showwaitqwaitercount $kgm_waitqp
508 set $kgm_waitq1p = (wait_queue_t)$arg0
510 showwaitqint $kgm_waitq1p
511 if ($kgm_waitq1p->wq_type == 0xf1d1)
512 showwaitqmembers $kgm_waitq1p
514 showwaitqmemberof $kgm_waitq1p
516 showwaitqwaiters $kgm_waitq1p
520 printf "vm_map pmap vm_size "
521 printf "#ents rpage hint first_free\n"
525 printf " entry start "
526 printf "prot #page object offset\n"
530 set $kgm_mapp = (vm_map_t)$arg0
531 set $kgm_map = *$kgm_mapp
532 printf "0x%08x ", $arg0
533 printf "0x%08x ", $kgm_map.pmap
534 printf "0x%08x ", $kgm_map.size
535 printf "%3d ", $kgm_map.hdr.nentries
536 printf "%5d ", $kgm_map.pmap->stats.resident_count
537 printf "0x%08x ", $kgm_map.hint
538 printf "0x%08x\n", $kgm_map.first_free
541 set $kgm_head_vmep = &($kgm_mapp->hdr.links)
542 set $kgm_vmep = $kgm_map.hdr.links.next
543 while (($kgm_vmep != 0) && ($kgm_vmep != $kgm_head_vmep))
544 set $kgm_vme = *$kgm_vmep
545 printf " 0x%08x ", $kgm_vmep
546 printf "0x%08x ", $kgm_vme.links.start
547 printf "%1x", $kgm_vme.protection
548 printf "%1x", $kgm_vme.max_protection
549 if $kgm_vme.inheritance == 0x0
552 if $kgm_vme.inheritance == 0x1
555 if $kgm_vme.inheritance == 0x2
558 if $kgm_vme.inheritance == 0x3
561 if $kgm_vme.is_sub_map
564 if $kgm_vme.needs_copy
570 printf "%5d ",($kgm_vme.links.end - $kgm_vme.links.start) >> 12
571 printf "0x%08x ", $kgm_vme.object.vm_object
572 printf "0x%08x\n", $kgm_vme.offset
573 set $kgm_vmep = $kgm_vme.links.next
585 | Routine to print out a summary listing of all the entries in a vm_map
586 | The following is the syntax:
587 | (gdb) showmapvme <vm_map>
596 | Routine to print out info about the specified vm_map
597 | The following is the syntax:
598 | (gdb) showmap <vm_map>
602 set $kgm_head_taskp = &default_pset.tasks
603 set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
604 while $kgm_taskp != $kgm_head_taskp
607 showtaskint $kgm_taskp
608 showvmint $kgm_taskp->map 0
609 set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
613 | Routine to print a summary listing of all the vm maps
614 | The following is the syntax:
620 set $kgm_head_taskp = &default_pset.tasks
621 set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
622 while $kgm_taskp != $kgm_head_taskp
625 showtaskint $kgm_taskp
626 showvmint $kgm_taskp->map 1
627 set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
631 | Routine to print a summary listing of all the vm map entries
632 | The following is the syntax:
638 printf "ipc_space is_table table_next "
639 printf "flags tsize splaytree splaybase\n"
642 define showipceheader
643 printf " name object "
644 printf "rite urefs destname destination\n"
648 set $kgm_ie = *(ipc_entry_t)$arg0
649 printf " 0x%08x ", $arg1
650 printf "0x%08x ", $kgm_ie.ie_object
651 if $kgm_ie.ie_bits & 0x00100000
653 printf "%5d\n", $kgm_ie.ie_bits & 0xffff
655 if $kgm_ie.ie_bits & 0x00080000
657 printf "%5d\n", $kgm_ie.ie_bits & 0xffff
659 if $kgm_ie.ie_bits & 0x00010000
660 if $kgm_ie.ie_bits & 0x00020000
666 if $kgm_ie.ie_bits & 0x00020000
670 if $kgm_ie.ie_bits & 0x00040000
673 if $kgm_ie.index.request
678 if $kgm_ie.ie_bits & 0x00800000
683 printf "%5d ", $kgm_ie.ie_bits & 0xffff
684 showportdest $kgm_ie.ie_object
690 set $kgm_isp = (ipc_space_t)$arg0
691 set $kgm_is = *$kgm_isp
692 printf "0x%08x ", $arg0
693 printf "0x%08x ", $kgm_is.is_table
694 printf "0x%08x ", $kgm_is.is_table_next
695 if $kgm_is.is_growing != 0
700 if $kgm_is.is_fast != 0
705 if $kgm_is.is_active != 0
710 printf "%5d ", $kgm_is.is_table_size
711 printf "0x%08x ", $kgm_is.is_tree_total
712 printf "0x%08x\n", &$kgm_isp->is_tree
716 set $kgm_iep = $kgm_is.is_table
717 set $kgm_destspacep = (ipc_space_t)0
718 while ( $kgm_iindex < $kgm_is.is_table_size )
719 set $kgm_ie = *$kgm_iep
720 if $kgm_ie.ie_bits & 0x001f0000
721 set $kgm_name = (($kgm_iindex << 8)|($kgm_ie.ie_bits >> 24))
722 showipceint $kgm_iep $kgm_name
724 set $kgm_iindex = $kgm_iindex + 1
725 set $kgm_iep = &($kgm_is.is_table[$kgm_iindex])
727 if $kgm_is.is_tree_total
728 printf "Still need to write tree traversal\n"
736 set $kgm_isp = (ipc_space_t)$arg0
738 showipcint $kgm_isp 0
741 | Routine to print the status of the specified ipc space
742 | The following is the syntax:
743 | (gdb) showipc <ipc_space>
747 set $kgm_isp = (ipc_space_t)$arg0
749 showipcint $kgm_isp 1
752 | Routine to print a summary list of all the rights in a specified ipc space
753 | The following is the syntax:
754 | (gdb) showrights <ipc_space>
759 set $kgm_taskp = (task_t)$arg0
762 showtaskint $kgm_taskp
763 showipcint $kgm_taskp->itk_space 0
766 | Routine to print info about the ipc space for a task
767 | The following is the syntax:
768 | (gdb) showtaskipc <task>
772 define showtaskrights
773 set $kgm_taskp = (task_t)$arg0
776 showtaskint $kgm_taskp
777 showipcint $kgm_taskp->itk_space 1
779 document showtaskrights
780 | Routine to print info about the ipc rights for a task
781 | The following is the syntax:
782 | (gdb) showtaskrights <task>
786 set $kgm_head_taskp = &default_pset.tasks
787 set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
788 while $kgm_taskp != $kgm_head_taskp
791 showtaskint $kgm_taskp
792 showipcint $kgm_taskp->itk_space 0
793 set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
797 | Routine to print a summary listing of all the ipc spaces
798 | The following is the syntax:
804 set $kgm_head_taskp = &default_pset.tasks
805 set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
806 while $kgm_taskp != $kgm_head_taskp
809 showtaskint $kgm_taskp
810 showipcint $kgm_taskp->itk_space 1
811 set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
814 document showallrights
815 | Routine to print a summary listing of all the ipc rights
816 | The following is the syntax:
817 | (gdb) showallrights
822 set $kgm_taskp = (task_t)$arg0
825 showtaskint $kgm_taskp
826 showvmint $kgm_taskp->map 0
829 | Routine to print out info about a task's vm_map
830 | The following is the syntax:
831 | (gdb) showtaskvm <task>
835 set $kgm_taskp = (task_t)$arg0
838 showtaskint $kgm_taskp
839 showvmint $kgm_taskp->map 1
842 | Routine to print out info about a task's vm_map_entries
843 | The following is the syntax:
844 | (gdb) showtaskvme <task>
848 define showtaskheader
849 printf "task vm_map ipc_space #acts "
855 set $kgm_task = *(struct task *)$arg0
856 printf "0x%08x ", $arg0
857 printf "0x%08x ", $kgm_task.map
858 printf "0x%08x ", $kgm_task.itk_space
859 printf "%3d ", $kgm_task.thread_count
860 showprocint $kgm_task.bsd_info
868 | Routine to print out info about a task.
869 | The following is the syntax:
870 | (gdb) showtask <task>
874 define showtaskthreads
876 set $kgm_taskp = (struct task *)$arg0
877 showtaskint $kgm_taskp
879 set $kgm_head_actp = &($kgm_taskp->threads)
880 set $kgm_actp = (struct thread *)($kgm_taskp->threads.next)
881 while $kgm_actp != $kgm_head_actp
882 showactint $kgm_actp 0
883 set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
886 document showtaskthreads
887 | Routine to print info about the threads in a task.
888 | The following is the syntax:
889 | (gdb) showtaskthreads <task>
893 define showtaskstacks
895 set $kgm_taskp = (struct task *)$arg0
896 showtaskint $kgm_taskp
897 set $kgm_head_actp = &($kgm_taskp->threads)
898 set $kgm_actp = (struct thread *)($kgm_taskp->threads.next)
899 while $kgm_actp != $kgm_head_actp
901 showactint $kgm_actp 1
902 set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
905 document showtaskstacks
906 | Routine to print out the stack for each thread in a task.
907 | The following is the syntax:
908 | (gdb) showtaskstacks <task>
914 set $kgm_head_taskp = &default_pset.tasks
915 set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
916 while $kgm_taskp != $kgm_head_taskp
917 showtaskint $kgm_taskp
918 set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
921 document showalltasks
922 | Routine to print a summary listing of all the tasks
923 | The following is the syntax:
928 define showprocheader
929 printf " pid proc command\n"
933 set $kgm_procp = (struct proc *)$arg0
935 printf "%5d ", $kgm_procp->p_pid
936 printf "0x%08x ", $kgm_procp
937 printf "%s\n", $kgm_procp->p_comm
939 printf " *0* 0x00000000 --\n"
945 set $kgm_head_taskp = &default_pset.tasks
946 set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
947 while $kgm_taskp != $kgm_head_taskp
948 set $kgm_procp = (struct proc *)$kgm_taskp->bsd_info
949 if (($kgm_procp != 0) && ($kgm_procp->p_pid == $arg0))
950 showtaskint $kgm_taskp
951 set $kgm_taskp = $kgm_head_taskp
953 set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
958 | Routine to print a single process by pid
959 | The following is the syntax:
960 | (gdb) showpid <pid>
965 set $kgm_procp = (struct proc *)$arg0
966 showtaskint $kgm_procp->task $arg1 $arg2
971 set switch_debugger=1
975 | kdb - Switch to the inline kernel debugger
979 | The kdb macro allows you to invoke the inline kernel debugger.
982 define showpsetheader
983 printf "portset waitqueue recvname "
984 printf "flags refs recvname process\n"
987 define showportheader
988 printf "port mqueue recvname "
989 printf "flags refs recvname process\n"
992 define showportmemberheader
993 printf "members port recvname "
994 printf "flags refs mqueue msgcount\n"
997 define showkmsgheader
998 printf "messages kmsg size "
999 printf "disp msgid remote-port local-port\n"
1003 printf " 0x%08x ", $arg0
1004 set $kgm_kmsgh = ((ipc_kmsg_t)$arg0)->ikm_header
1005 printf "0x%08x ", $kgm_kmsgh.msgh_size
1006 if (($kgm_kmsgh.msgh_bits & 0xff) == 19)
1011 if (($kgm_kmsgh.msgh_bits & 0xff00) == (19 < 8))
1016 if ($kgm_kmsgh.msgh_bits & 0xf0000000)
1021 printf "%5d ", $kgm_kmsgh.msgh_id
1022 printf "0x%08x ", $kgm_kmsgh.msgh_remote_port
1023 printf "0x%08x\n", $kgm_kmsgh.msgh_local_port
1029 set $kgm_portp = (struct ipc_port *)$arg0
1030 printf "0x%08x kobject(", $kgm_portp->ip_kobject
1031 set $kgm_kotype = ($kgm_portp->ip_object.io_bits & 0x00000fff)
1032 if ($kgm_kotype == 1)
1035 if ($kgm_kotype == 2)
1038 if ($kgm_kotype == 3)
1041 if ($kgm_kotype == 4)
1044 if ($kgm_kotype == 5)
1047 if ($kgm_kotype == 6)
1050 if ($kgm_kotype == 7)
1053 if ($kgm_kotype == 8)
1056 if ($kgm_kotype == 9)
1059 if ($kgm_kotype == 10)
1062 if ($kgm_kotype == 11)
1065 if ($kgm_kotype == 12)
1068 if ($kgm_kotype == 13)
1071 if ($kgm_kotype == 14)
1074 if ($kgm_kotype == 15)
1077 if ($kgm_kotype == 16)
1080 if ($kgm_kotype == 17)
1083 if ($kgm_kotype == 18)
1086 if ($kgm_kotype == 19)
1089 if ($kgm_kotype == 20)
1092 if ($kgm_kotype == 21)
1095 if ($kgm_kotype == 22)
1096 printf "IO_DONE_QUE"
1098 if ($kgm_kotype == 23)
1101 if ($kgm_kotype == 24)
1104 if ($kgm_kotype == 25)
1107 if ($kgm_kotype == 26)
1110 if ($kgm_kotype == 27)
1111 printf "IOKIT_SPARE"
1113 if ($kgm_kotype == 28)
1116 if ($kgm_kotype == 29)
1119 if ($kgm_kotype == 30)
1122 if ($kgm_kotype == 31)
1128 define showportdestproc
1129 set $kgm_portp = (struct ipc_port *)$arg0
1130 set $kgm_spacep = $kgm_portp->data.receiver
1131 # check against the previous cached value - this is slow
1132 if ($kgm_spacep != $kgm_destspacep)
1133 set $kgm_destprocp = (struct proc *)0
1134 set $kgm_head_taskp = &default_pset.tasks
1135 set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
1136 while (($kgm_destprocp == 0) && ($kgm_taskp != $kgm_head_taskp))
1137 set $kgm_destspacep = $kgm_taskp->itk_space
1138 if ($kgm_destspacep == $kgm_spacep)
1139 set $kgm_destprocp = (struct proc *)$kgm_taskp->bsd_info
1141 set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
1145 if $kgm_destprocp != 0
1146 printf "%s(%d)\n", $kgm_destprocp->p_comm, $kgm_destprocp->p_pid
1148 printf "task 0x%08x\n", $kgm_taskp
1153 set $kgm_portp = (struct ipc_port *)$arg0
1154 set $kgm_spacep = $kgm_portp->data.receiver
1155 if ($kgm_spacep == ipc_space_kernel)
1156 showkobject $kgm_portp
1158 if ($kgm_portp->ip_object.io_bits & 0x80000000)
1159 printf "0x%08x ", $kgm_portp->ip_object.io_receiver_name
1160 showportdestproc $kgm_portp
1162 printf "0x%08x inactive-port\n", $kgm_portp
1167 define showportmember
1168 printf " 0x%08x ", $arg0
1169 set $kgm_portp = (struct ipc_port *)$arg0
1170 printf "0x%08x ", $kgm_portp->ip_object.io_receiver_name
1171 if ($kgm_portp->ip_object.io_bits & 0x80000000)
1176 if ($kgm_portp->ip_object.io_bits & 0x7fff0000)
1181 printf "%5d ", $kgm_portp->ip_object.io_references
1182 printf "0x%08x ", &($kgm_portp->ip_messages)
1183 printf "0x%08x\n", $kgm_portp->ip_messages.data.port.msgcount
1187 printf "0x%08x ", $arg0
1188 set $kgm_portp = (struct ipc_port *)$arg0
1189 printf "0x%08x ", &($kgm_portp->ip_messages)
1190 printf "0x%08x ", $kgm_portp->ip_object.io_receiver_name
1191 if ($kgm_portp->ip_object.io_bits & 0x80000000)
1197 printf "%5d ", $kgm_portp->ip_object.io_references
1198 set $kgm_destspacep = (struct ipc_space *)0
1199 showportdest $kgm_portp
1200 set $kgm_kmsgp = (ipc_kmsg_t)$kgm_portp->ip_messages.data.port.messages.ikmq_base
1201 if $arg1 && $kgm_kmsgp
1203 showkmsgint $kgm_kmsgp
1204 set $kgm_kmsgheadp = $kgm_kmsgp
1205 set $kgm_kmsgp = $kgm_kmsgp->ikm_next
1206 while $kgm_kmsgp != $kgm_kmsgheadp
1207 showkmsgint $kgm_kmsgp
1208 set $kgm_kmsgp = $kgm_kmsgp->ikm_next
1214 printf "0x%08x ", $arg0
1215 set $kgm_psetp = (struct ipc_pset *)$arg0
1216 printf "0x%08x ", &($kgm_psetp->ips_messages)
1217 printf "0x%08x ", $kgm_psetp->ips_object.io_receiver_name
1218 if ($kgm_psetp->ips_object.io_bits & 0x80000000)
1224 printf "%5d ", $kgm_psetp->ips_object.io_references
1225 printf "0x%08x ", $kgm_psetp->ips_object.io_receiver_name
1226 set $kgm_setlinksp = &($kgm_psetp->ips_messages.data.set_queue.wqs_setlinks)
1227 set $kgm_wql = (struct wait_queue_link *)$kgm_setlinksp->next
1229 while ( (queue_entry_t)$kgm_wql != (queue_entry_t)$kgm_setlinksp)
1230 set $kgm_portp = (struct ipc_port *)((int)($kgm_wql->wql_element->wqe_queue) - ((int)$kgm_portoff))
1232 set $kgm_destspacep = (struct ipc_space *)0
1233 showportdestproc $kgm_portp
1234 showportmemberheader
1237 showportmember $kgm_portp 0
1238 set $kgm_wql = (struct wait_queue_link *)$kgm_wql->wql_setlinks.next
1255 define showipcobject
1256 set $kgm_object = (ipc_object_t)$arg0
1257 if ($kgm_objectp->io_bits & 0x7fff0000)
1258 showpset $kgm_objectp
1260 showport $kgm_objectp
1265 set $kgm_mqueue = *(struct ipc_mqueue *)$arg0
1266 set $kgm_psetoff = &(((struct ipc_pset *)0)->ips_messages)
1267 set $kgm_portoff = &(((struct ipc_port *)0)->ip_messages)
1268 if ($kgm_mqueue.data.set_queue.wqs_wait_queue.wq_type == 0xf1d1)
1269 set $kgm_pset = (((int)$arg0) - ((int)$kgm_psetoff))
1271 showpsetint $kgm_pset 1
1273 if ($kgm_mqueue.data.set_queue.wqs_wait_queue.wq_type == 0xf1d0)
1275 set $kgm_port = (((int)$arg0) - ((int)$kgm_portoff))
1276 showportint $kgm_port 1
1281 set $kgm_zone = (struct zone *)$arg0
1283 printf "0x%08x ", $kgm_zone
1284 printf "%8d ",$kgm_zone->count
1285 printf "%8x ",$kgm_zone->cur_size
1286 printf "%8x ",$kgm_zone->max_size
1287 printf "%6d ",$kgm_zone->elem_size
1288 printf "%8x ",$kgm_zone->alloc_size
1289 printf "%s ",$kgm_zone->zone_name
1291 if ($kgm_zone->exhaustible)
1294 if ($kgm_zone->collectable)
1297 if ($kgm_zone->expandable)
1305 printf "ZONE COUNT TOT_SZ MAX_SZ ELT_SZ ALLOC_SZ NAME\n"
1306 set $kgm_zone_ptr = (struct zone *)first_zone
1307 while ($kgm_zone_ptr != 0)
1308 zprint_one $kgm_zone_ptr
1309 set $kgm_zone_ptr = $kgm_zone_ptr->next_zone
1314 | Routine to print a summary listing of all the kernel zones
1315 | The following is the syntax:
1319 set $kdp_act_counter = 0
1322 if (machine_slot[0].cpu_type == 18)
1323 if ($kdp_act_counter == 0)
1324 set $kdpstate = (struct savearea *) kdp.saved_state
1326 set $kdp_act_counter = $kdp_act_counter + 1
1327 set $newact = (struct thread *) $arg0
1328 if (($newact.thread)->kernel_stack == 0)
1329 echo This activation does not have a stack.\n
1331 output/a $newact.thread.continuation
1334 set (struct savearea *) kdp.saved_state=$newact->mact->pcb
1336 set $pc=$newact->mact->pcb.save_srr0
1339 echo switchtoact not implemented for this architecture.\n
1343 document switchtoact
1344 Syntax: switchtoact <address of activation>
1345 | This command allows gdb to examine the execution context and call
1346 | stack for the specified activation. For example, to view the backtrace
1347 | for an activation issue "switchtoact <address>", followed by "bt".
1348 | Before resuming execution, issue a "resetctx" command, to
1349 | return to the original execution context.
1353 if (machine_slot[0].cpu_type == 18)
1354 if ($kdp_act_counter == 0)
1355 set $kdpstate = (struct savearea *) kdp.saved_state
1357 set $kdp_act_counter = $kdp_act_counter + 1
1358 set (struct savearea *) kdp.saved_state=(struct savearea *) $arg0
1360 set $pc=((struct savearea *) $arg0)->save_srr0
1363 echo switchtoctx not implemented for this architecture.\n
1367 document switchtoctx
1368 Syntax: switchtoctx <address of pcb>
1369 | This command allows gdb to examine an execution context and dump the
1370 | backtrace for this execution context.
1371 | Before resuming execution, issue a "resetctx" command, to
1372 | return to the original execution context.
1376 if (machine_slot[0].cpu_type == 18)
1377 set (struct savearea *)kdp.saved_state=$kdpstate
1379 set $pc=((struct savearea *) kdp.saved_state)->save_srr0
1381 set $kdp_act_counter = 0
1383 echo resetctx not implemented for this architecture.\n
1389 | Returns to the original execution context. This command should be
1390 | issued if you wish to resume execution after using the "switchtoact"
1391 | or "switchtoctx" commands.
1395 set noresume_on_disconnect = 0
1400 | The target system will resume when detaching or exiting from gdb.
1401 | This is the default behavior.
1405 set noresume_on_disconnect = 1
1409 | Syntax: resume_off
1410 | The target system won't resume after detaching from gdb and
1411 | can be attached with a new gdb session
1415 set $kgm_panic_bufptr = debug_buf
1416 set $kgm_panic_bufptr_max = debug_buf_ptr
1417 while $kgm_panic_bufptr < $kgm_panic_bufptr_max
1418 if *(char *)$kgm_panic_bufptr == 10
1421 printf "%c", *$kgm_panic_bufptr
1423 set $kgm_panic_bufptr= (char *)$kgm_panic_bufptr + 1
1429 | Display the panic log information
1433 define dumpcallqueue
1434 set $kgm_callhead = (queue_t)&$arg0
1435 set $kgm_call = (struct call_entry *)$kgm_callhead.next
1437 while $kgm_call != $kgm_callhead
1438 printf "0x%08x ", $kgm_call
1439 printf "0x%08x 0x%08x ", $kgm_call->param0, $kgm_call->param1
1440 output $kgm_call->state
1442 output $kgm_call->deadline
1444 output $kgm_call->func
1446 set $kgm_i = $kgm_i + 1
1447 set $kgm_call = (struct call_entry *)$kgm_call->q_link.next
1449 printf "%d entries\n", $kgm_i
1452 document dumpcallqueue
1453 | Syntax: dumpcallqueue <queue head>
1454 | Displays the contents of the specified call_entry queue.
1458 showtaskthreads $arg0
1460 document showtaskacts
1461 | See help showtaskthreads.
1467 document showallacts
1468 | See help showallthreads.