The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kgmacros

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 #
    2 # Kernel gdb macros
    3 #
    4 #  These gdb macros should be useful during kernel development in
    5 #  determining what's going on in the kernel.
    6 #
    7 #  All the convenience variables used by these macros begin with $kgm_
    8 
    9 set $kgm_dummy = &proc0
   10 set $kgm_dummy = &kmod
   11 
   12 echo Loading Kernel GDB Macros package.  Type "help kgm" for more info.\n
   13 
   14 define kgm
   15 printf ""
   16 echo  These are the gdb macros for kernel debugging.  Type "help kgm" for more info.\n
   17 end
   18 
   19 document kgm
   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>
   25 |
   26 | The following macros are available in this package:
   27 |
   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
   38 |
   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
   46 |
   47 |     showact        Display info about a thread specified by activation
   48 |     showactstack   Display the stack for a thread specified by activation
   49 |
   50 |     showmap        Display info about the specified vm_map
   51 |     showmapvme     Display a summary list of the specified vm_map's entries
   52 |
   53 |     showipc        Display info about the specified ipc space
   54 |     showrights     Display a summary list of all the rights in an ipc space
   55 |
   56 |     showpid        Display info about the process identified by pid
   57 |     showproc       Display info about the process identified by proc struct
   58 |
   59 |     showkmod       Display info about a kernel module
   60 |     showkmodaddr   Given an address, display the kernel module and offset
   61 |
   62 |     dumpcallqueue  Dump out all the entries given a queue head
   63 |
   64 |     zprint         Display info about the memory zones
   65 |     paniclog       Display the panic log info
   66 |
   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 
   72 |
   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.
   75 end
   76 
   77 
   78 define showkmodheader
   79     printf "kmod        address     size        "
   80     printf "id    refs     version  name\n"
   81 end
   82 
   83 define showkmodint
   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
   92 end
   93 
   94 set $kgm_kmodmin = 0xffffffff
   95 set $kgm_fkmodmin = 0x00000000
   96 set $kgm_kmodmax = 0x00000000
   97 set $kgm_fkmodmax = 0xffffffff
   98 set $kgm_pkmod = 0
   99 set $kgm_pkmodst = 0
  100 set $kgm_pkmoden = 0
  101 define showkmodaddr
  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
  106     else
  107         if  ((unsigned int)$arg0 <= (unsigned int)$kgm_fkmodmax) && ((unsigned int)$arg0 >= (unsigned int)$kgm_fkmodmin)
  108             set $kgm_kmodp = (struct kmod_info *)kmod
  109             while $kgm_kmodp
  110                 set $kgm_kmod = *$kgm_kmodp
  111                 if $kgm_kmod.address && ($kgm_kmod.address < $kgm_kmodmin)
  112                     set $kgm_kmodmin = $kgm_kmod.address
  113                 end
  114                 if ($kgm_kmod.address + $kgm_kmod.size) > $kgm_kmodmax
  115                     set $kgm_kmodmax = $kgm_kmod.address
  116                 end
  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
  123                     set $kgm_kmodp = 0
  124                 else
  125                     set $kgm_kmodp = $kgm_kmod.next
  126                 end
  127             end
  128             if !$kgm_pkmod
  129                 set $kgm_fkmodmin = $kgm_kmodmin
  130                 set $kgm_fkmodmax = $kgm_kmodmax
  131             end
  132         end
  133     end
  134 end
  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>
  139 end
  140 
  141 define showkmod
  142     showkmodheader
  143     showkmodint $arg0
  144 end
  145 document showkmod
  146 | Routine to print info about a kernel module
  147 | The following is the syntax:
  148 |     (gdb) showkmod <kmod>
  149 end
  150 
  151 define showallkmods
  152     showkmodheader
  153     set $kgm_kmodp = (struct kmod_info *)kmod
  154     while $kgm_kmodp
  155         showkmodint $kgm_kmodp
  156         set $kgm_kmodp = $kgm_kmodp->next
  157     end
  158 end
  159 document showallkmods
  160 | Routine to print a summary listing of all the kernel modules
  161 | The following is the syntax:
  162 |     (gdb) showallkmods
  163 end
  164 
  165 define showactheader
  166     printf "            activation  "
  167     printf "thread      pri  state  wait_queue  wait_event\n"
  168 end
  169 
  170 
  171 define showactint
  172    printf "            0x%08x  ", $arg0
  173    set $kgm_actp = *(struct thread *)$arg0
  174    if $kgm_actp.thread
  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
  179         if $kgm_state & 0x80
  180             printf "I" 
  181         end
  182         if $kgm_state & 0x40
  183             printf "P" 
  184         end
  185         if $kgm_state & 0x20
  186             printf "A" 
  187         end
  188         if $kgm_state & 0x10
  189             printf "H" 
  190         end
  191         if $kgm_state & 0x08
  192             printf "U" 
  193         end
  194         if $kgm_state & 0x04
  195             printf "R" 
  196         end
  197         if $kgm_state & 0x02
  198             printf "S" 
  199         end
  200         if $kgm_state & 0x01
  201             printf "W\t" 
  202             printf "0x%08x  ", $kgm_thread.wait_queue
  203             output /a $kgm_thread.wait_event
  204         end
  205         if $arg1 != 0
  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
  209                 end
  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
  213                 else
  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
  217                 end
  218                 set $prevsp = 0
  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)
  224                                 else
  225                                         set $kgm_return = *($mysp + 4)
  226                                 end
  227                                 if ($kgm_return > sectPRELINKB)
  228                                     showkmodaddr $kgm_return
  229                                 else
  230                                 if (machine_slot[0].cpu_type == 18)
  231                                     output /a * ($mysp + 8)
  232                                 else
  233                                     output /a * ($mysp + 4)
  234                                 end
  235                                 end
  236                                 set $prevsp = $mysp
  237                                 set $mysp = * $mysp
  238                 end
  239                 printf "\n\t\tstackbottom=0x%08x", $prevsp
  240             else
  241                 printf "\n\t\t\tcontinuation="
  242                 output /a $kgm_thread.continuation
  243             end
  244             printf "\n"
  245         else
  246             printf "\n"
  247         end
  248     end
  249 end         
  250 
  251 define showact
  252     showactheader
  253     showactint $arg0 0
  254 end
  255 document showact
  256 | Routine to print out the state of a specific thread.
  257 | The following is the syntax:
  258 |     (gdb) showact <activation> 
  259 end
  260 
  261 
  262 define showactstack
  263     showactheader
  264     showactint $arg0 1
  265 end
  266 document showactstack
  267 | Routine to print out the stack of a specific thread.
  268 | The following is the syntax:
  269 |     (gdb) showactstack <activation> 
  270 end
  271 
  272 
  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
  277         showtaskheader
  278         showtaskint $kgm_taskp
  279         showactheader
  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)
  285         end
  286         printf "\n"
  287         set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
  288     end
  289 end
  290 document showallthreads
  291 | Routine to print out info about all threads in the system.
  292 | The following is the syntax:
  293 |     (gdb) showallthreads
  294 end
  295 
  296 define showcurrentthreads
  297 set $kgm_ncpus = machine_info.max_cpus
  298 set $kgm_i = 0
  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
  303             showtaskheader
  304             showtaskint ($kgm_actp)->task
  305             showactheader
  306             showactint $kgm_actp 0
  307             printf "\n"
  308         end
  309         set $kgm_i = $kgm_i + 1
  310     end
  311 end
  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
  316 end
  317 
  318 define showallstacks
  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
  322         showtaskheader
  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
  327             showactheader
  328             showactint $kgm_actp 1
  329             set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
  330         end
  331         printf "\n"
  332         set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
  333     end
  334 end
  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
  339 end
  340 
  341 define showcurrentstacks
  342 set $kgm_ncpus = machine_info.max_cpus
  343 set $kgm_i = 0
  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
  348             showtaskheader
  349             showtaskint ($kgm_actp)->task
  350             showactheader
  351             showactint $kgm_actp 1
  352             printf "\n"
  353         end
  354         set $kgm_i = $kgm_i + 1
  355     end
  356 end
  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
  361 end
  362 
  363 define showwaiterheader
  364     printf "waiters     activation  "
  365     printf "thread      pri  state  wait_queue  wait_event\n"
  366 end
  367 
  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
  372     set $kgm_w_found = 0
  373     while ( (queue_entry_t)$kgm_w_wqe != (queue_entry_t)$kgm_w_linksp)
  374         if ($kgm_w_wqe->wqe_type != &_wait_queue_link)
  375                 if !$kgm_w_found
  376                         set $kgm_w_found = 1
  377                         showwaiterheader
  378                 end
  379                 set $kgm_w_shuttle = (struct thread *)$kgm_w_wqe
  380                 showactint $kgm_w_shuttle->top_act 0
  381         end     
  382         set $kgm_w_wqe = (struct wait_queue_element *)$kgm_w_wqe->wqe_links.next
  383     end
  384 end
  385 
  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
  394         end
  395         set $kgm_wc_wqe = (struct wait_queue_element *)$kgm_wc_wqe->wqe_links.next
  396     end
  397     printf "0x%08x  ", $kgm_wc_count
  398 end
  399 
  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
  408     end
  409     printf "0x%08x  ", $kgm_mc_count
  410 end
  411 
  412     
  413 define showwaitqmemberheader
  414     printf "set-members wait_queue  interlock   "
  415     printf "pol  type   member_cnt  waiter_cnt\n"
  416 end
  417 
  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)
  423         printf "Fifo "
  424     else
  425         printf "Prio "
  426     end
  427     if ($kgm_m_waitqp->wq_type == 0xf1d1)
  428         printf "Set    "
  429         showwaitqmembercount $kgm_m_waitqp
  430     else
  431         printf "Que    0x00000000  "
  432     end
  433     showwaitqwaitercount $kgm_m_waitqp
  434     printf "\n"
  435 end
  436 
  437 
  438 define showwaitqmemberofheader
  439     printf "member-of   wait_queue  interlock   "
  440     printf "pol  type   member_cnt  waiter_cnt\n"
  441 end
  442 
  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)
  450                 if !$kgm_mo_found
  451                         set $kgm_mo_found = 1
  452                         showwaitqmemberofheader
  453                 end
  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
  457         end     
  458         set $kgm_mo_wqe = (struct wait_queue_element *)$kgm_mo_wqe->wqe_links.next
  459     end
  460 end
  461 
  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
  469         if !$kgm_ms_found  
  470             showwaitqmemberheader
  471             set $kgm_ms_found = 1
  472         end
  473         showwaitqmemberint $kgm_ms_waitqp
  474         set $kgm_ms_wql = (struct wait_queue_link *)$kgm_ms_wql->wql_setlinks.next
  475     end
  476 end
  477 
  478 define showwaitqheader
  479     printf "wait_queue  ref_count   interlock   "
  480     printf "pol  type   member_cnt  waiter_cnt\n"
  481 end
  482 
  483 define showwaitqint
  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
  488     else
  489         printf "0x00000000  "
  490     end
  491     printf "0x%08x  ", $kgm_waitqp->wq_interlock.lock_data
  492     if ($kgm_waitqp->wq_fifo)
  493         printf "Fifo "
  494     else
  495         printf "Prio "
  496     end
  497     if ($kgm_waitqp->wq_type == 0xf1d1)
  498         printf "Set    "
  499         showwaitqmembercount $kgm_waitqp
  500     else
  501         printf "Que    0x00000000  "
  502     end
  503     showwaitqwaitercount $kgm_waitqp
  504     printf "\n"
  505 end
  506 
  507 define showwaitq
  508     set $kgm_waitq1p = (wait_queue_t)$arg0
  509     showwaitqheader
  510     showwaitqint $kgm_waitq1p   
  511     if ($kgm_waitq1p->wq_type == 0xf1d1)
  512         showwaitqmembers $kgm_waitq1p
  513     else
  514         showwaitqmemberof $kgm_waitq1p
  515     end
  516     showwaitqwaiters $kgm_waitq1p
  517 end
  518 
  519 define showmapheader
  520     printf "vm_map      pmap        vm_size    "
  521     printf "#ents rpage  hint        first_free\n"
  522 end
  523 
  524 define showvmeheader
  525     printf "            entry       start       "
  526     printf "prot #page  object      offset\n"
  527 end
  528 
  529 define showvmint
  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
  539     if $arg1 != 0
  540         showvmeheader   
  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
  550                 printf "S"
  551             end
  552             if $kgm_vme.inheritance == 0x1
  553                 printf "C"
  554             end
  555             if $kgm_vme.inheritance == 0x2
  556                 printf "-"
  557             end
  558             if $kgm_vme.inheritance == 0x3
  559                 printf "D"
  560             end
  561             if $kgm_vme.is_sub_map
  562                 printf "s "
  563             else
  564                 if $kgm_vme.needs_copy
  565                     printf "n "
  566                 else
  567                     printf "  "
  568                 end
  569             end
  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
  574         end
  575     end
  576     printf "\n"
  577 end
  578 
  579 
  580 define showmapvme
  581         showmapheader
  582         showvmint $arg0 1
  583 end
  584 document showmapvme
  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>
  588 end
  589 
  590 
  591 define showmap
  592         showmapheader
  593         showvmint $arg0 0
  594 end
  595 document showmap
  596 | Routine to print out info about the specified vm_map
  597 | The following is the syntax:
  598 |     (gdb) showmap <vm_map>
  599 end
  600 
  601 define showallvm
  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
  605         showtaskheader
  606         showmapheader
  607         showtaskint $kgm_taskp
  608         showvmint $kgm_taskp->map 0
  609         set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
  610     end
  611 end
  612 document showallvm
  613 | Routine to print a summary listing of all the vm maps
  614 | The following is the syntax:
  615 |     (gdb) showallvm
  616 end
  617 
  618 
  619 define showallvme
  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
  623         showtaskheader
  624         showmapheader
  625         showtaskint $kgm_taskp
  626         showvmint $kgm_taskp->map 1
  627         set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
  628     end
  629 end
  630 document showallvme
  631 | Routine to print a summary listing of all the vm map entries
  632 | The following is the syntax:
  633 |     (gdb) showallvme
  634 end
  635 
  636 
  637 define showipcheader
  638     printf "ipc_space   is_table    table_next "
  639     printf "flags tsize  splaytree   splaybase\n"
  640 end
  641 
  642 define showipceheader
  643     printf "            name        object      "
  644     printf "rite urefs  destname    destination\n"
  645 end
  646 
  647 define showipceint
  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
  652         printf "Dead "
  653         printf "%5d\n", $kgm_ie.ie_bits & 0xffff
  654     else
  655         if $kgm_ie.ie_bits & 0x00080000
  656             printf "SET  "
  657             printf "%5d\n", $kgm_ie.ie_bits & 0xffff
  658         else
  659             if $kgm_ie.ie_bits & 0x00010000
  660                 if $kgm_ie.ie_bits & 0x00020000
  661                     printf " SR"
  662                 else
  663                     printf "  S"
  664                 end
  665             else
  666                 if $kgm_ie.ie_bits & 0x00020000
  667                    printf "  R"
  668                 end
  669             end
  670             if $kgm_ie.ie_bits & 0x00040000
  671                 printf "  O"
  672             end
  673             if $kgm_ie.index.request
  674                 printf "n"
  675             else
  676                 printf " "
  677             end
  678             if $kgm_ie.ie_bits & 0x00800000
  679                 printf "c"
  680             else
  681                 printf " "
  682             end
  683             printf "%5d  ", $kgm_ie.ie_bits & 0xffff
  684             showportdest $kgm_ie.ie_object
  685         end
  686     end
  687 end
  688 
  689 define showipcint
  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
  696         printf "G"
  697     else
  698         printf " "
  699     end
  700     if $kgm_is.is_fast != 0
  701         printf "F"
  702     else
  703         printf " "
  704     end
  705     if $kgm_is.is_active != 0
  706         printf "A  "
  707     else
  708         printf "   "
  709     end
  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
  713     if $arg1 != 0
  714         showipceheader
  715         set $kgm_iindex = 0
  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
  723             end
  724             set $kgm_iindex = $kgm_iindex + 1
  725             set $kgm_iep = &($kgm_is.is_table[$kgm_iindex])
  726         end
  727         if $kgm_is.is_tree_total
  728             printf "Still need to write tree traversal\n"
  729         end
  730     end
  731     printf "\n"
  732 end
  733 
  734 
  735 define showipc
  736         set $kgm_isp = (ipc_space_t)$arg0
  737         showipcheader
  738         showipcint $kgm_isp 0
  739 end
  740 document showipc
  741 | Routine to print the status of the specified ipc space
  742 | The following is the syntax:
  743 |     (gdb) showipc <ipc_space>
  744 end
  745 
  746 define showrights
  747         set $kgm_isp = (ipc_space_t)$arg0
  748         showipcheader
  749         showipcint $kgm_isp 1
  750 end
  751 document showrights
  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>
  755 end
  756 
  757 
  758 define showtaskipc
  759         set $kgm_taskp = (task_t)$arg0
  760         showtaskheader
  761     showipcheader
  762         showtaskint $kgm_taskp
  763         showipcint $kgm_taskp->itk_space 0
  764 end
  765 document showtaskipc
  766 | Routine to print info about the ipc space for a task
  767 | The following is the syntax:
  768 |     (gdb) showtaskipc <task>
  769 end
  770 
  771 
  772 define showtaskrights
  773         set $kgm_taskp = (task_t)$arg0
  774         showtaskheader
  775         showipcheader
  776         showtaskint $kgm_taskp
  777         showipcint $kgm_taskp->itk_space 1
  778 end
  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>
  783 end
  784 
  785 define showallipc
  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
  789         showtaskheader
  790         showipcheader
  791         showtaskint $kgm_taskp
  792         showipcint $kgm_taskp->itk_space 0
  793         set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
  794     end
  795 end
  796 document showallipc
  797 | Routine to print a summary listing of all the ipc spaces
  798 | The following is the syntax:
  799 |     (gdb) showallipc
  800 end
  801 
  802 
  803 define showallrights
  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
  807         showtaskheader
  808         showipcheader
  809         showtaskint $kgm_taskp
  810         showipcint $kgm_taskp->itk_space 1
  811         set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
  812     end
  813 end
  814 document showallrights
  815 | Routine to print a summary listing of all the ipc rights
  816 | The following is the syntax:
  817 |     (gdb) showallrights
  818 end
  819 
  820 
  821 define showtaskvm
  822         set $kgm_taskp = (task_t)$arg0
  823         showtaskheader
  824         showmapheader
  825         showtaskint $kgm_taskp
  826         showvmint $kgm_taskp->map 0
  827 end
  828 document showtaskvm
  829 | Routine to print out info about a task's vm_map
  830 | The following is the syntax:
  831 |     (gdb) showtaskvm <task>
  832 end
  833 
  834 define showtaskvme
  835         set $kgm_taskp = (task_t)$arg0
  836         showtaskheader
  837         showmapheader
  838         showtaskint $kgm_taskp
  839         showvmint $kgm_taskp->map 1
  840 end
  841 document showtaskvme
  842 | Routine to print out info about a task's vm_map_entries
  843 | The following is the syntax:
  844 |     (gdb) showtaskvme <task>
  845 end
  846 
  847 
  848 define showtaskheader
  849     printf "task        vm_map      ipc_space  #acts  "
  850     showprocheader
  851 end
  852 
  853 
  854 define showtaskint
  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
  861 end
  862 
  863 define showtask
  864     showtaskheader
  865     showtaskint $arg0
  866 end
  867 document showtask
  868 | Routine to print out info about a task.
  869 | The following is the syntax:
  870 |     (gdb) showtask <task>
  871 end
  872 
  873 
  874 define showtaskthreads
  875     showtaskheader
  876     set $kgm_taskp = (struct task *)$arg0
  877     showtaskint $kgm_taskp
  878     showactheader
  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)
  884     end
  885 end
  886 document showtaskthreads
  887 | Routine to print info about the threads in a task.
  888 | The following is the syntax:
  889 |     (gdb) showtaskthreads <task>
  890 end
  891 
  892 
  893 define showtaskstacks
  894     showtaskheader
  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
  900         showactheader
  901         showactint $kgm_actp 1
  902         set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
  903     end
  904 end
  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>
  909 end
  910 
  911 
  912 define showalltasks
  913     showtaskheader
  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)
  919     end
  920 end
  921 document showalltasks
  922 | Routine to print a summary listing of all the tasks
  923 | The following is the syntax:
  924 |     (gdb) showalltasks
  925 end
  926 
  927 
  928 define showprocheader
  929     printf " pid  proc        command\n"
  930 end
  931 
  932 define showprocint
  933     set $kgm_procp = (struct proc *)$arg0
  934     if $kgm_procp != 0
  935         printf "%5d  ", $kgm_procp->p_pid
  936         printf "0x%08x  ", $kgm_procp
  937         printf "%s\n", $kgm_procp->p_comm
  938     else
  939         printf "  *0*  0x00000000  --\n"
  940     end
  941 end
  942 
  943 define showpid
  944     showtaskheader
  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
  952         else
  953             set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
  954         end
  955     end
  956 end
  957 document showpid
  958 | Routine to print a single process by pid
  959 | The following is the syntax:
  960 |     (gdb) showpid <pid>
  961 end
  962 
  963 define showproc
  964     showtaskheader
  965     set $kgm_procp = (struct proc *)$arg0
  966     showtaskint $kgm_procp->task $arg1 $arg2
  967 end
  968 
  969 
  970 define kdb
  971     set switch_debugger=1
  972     continue
  973 end
  974 document kdb
  975 | kdb - Switch to the inline kernel debugger
  976 |
  977 | usage: kdb
  978 |
  979 | The kdb macro allows you to invoke the inline kernel debugger.
  980 end
  981 
  982 define showpsetheader
  983     printf "portset     waitqueue   recvname    "
  984     printf "flags refs  recvname    process\n"
  985 end
  986 
  987 define showportheader
  988     printf "port        mqueue      recvname    "
  989     printf "flags refs  recvname    process\n"
  990 end
  991 
  992 define showportmemberheader
  993     printf "members     port        recvname    "
  994     printf "flags refs  mqueue      msgcount\n"
  995 end
  996 
  997 define showkmsgheader
  998     printf "messages    kmsg        size        "
  999     printf "disp msgid  remote-port local-port\n"
 1000 end
 1001 
 1002 define showkmsgint
 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)
 1007         printf "rC"
 1008     else
 1009         printf "rM"
 1010     end
 1011     if (($kgm_kmsgh.msgh_bits & 0xff00) == (19 < 8))
 1012         printf "lC"
 1013     else
 1014         printf "lM"
 1015     end
 1016     if ($kgm_kmsgh.msgh_bits & 0xf0000000)
 1017         printf "c"
 1018     else
 1019         printf "s"
 1020     end
 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
 1024 end
 1025 
 1026 
 1027 
 1028 define showkobject
 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)
 1033         printf "THREAD"
 1034     end
 1035     if ($kgm_kotype == 2)
 1036         printf "TASK"
 1037     end
 1038     if ($kgm_kotype == 3)
 1039         printf "HOST"
 1040     end
 1041     if ($kgm_kotype == 4)
 1042         printf "HOST_PRIV"
 1043     end
 1044     if ($kgm_kotype == 5)
 1045         printf "PROCESSOR"
 1046     end
 1047     if ($kgm_kotype == 6)
 1048         printf "PSET"
 1049     end
 1050     if ($kgm_kotype == 7)
 1051         printf "PSET_NAME"
 1052     end
 1053     if ($kgm_kotype == 8)
 1054         printf "TIMER"
 1055     end
 1056     if ($kgm_kotype == 9)
 1057         printf "PAGER_REQ"
 1058     end
 1059     if ($kgm_kotype == 10)
 1060         printf "DEVICE"
 1061     end
 1062     if ($kgm_kotype == 11)
 1063         printf "XMM_OBJECT"
 1064     end
 1065     if ($kgm_kotype == 12)
 1066         printf "XMM_PAGER"
 1067     end
 1068     if ($kgm_kotype == 13)
 1069         printf "XMM_KERNEL"
 1070     end
 1071     if ($kgm_kotype == 14)
 1072         printf "XMM_REPLY"
 1073     end
 1074     if ($kgm_kotype == 15)
 1075         printf "NOTDEF 15"
 1076     end
 1077     if ($kgm_kotype == 16)
 1078         printf "NOTDEF 16"
 1079     end
 1080     if ($kgm_kotype == 17)
 1081         printf "HOST_SEC"
 1082     end
 1083     if ($kgm_kotype == 18)
 1084         printf "LEDGER"
 1085     end
 1086     if ($kgm_kotype == 19)
 1087         printf "MASTER_DEV"
 1088     end
 1089     if ($kgm_kotype == 20)
 1090         printf "ACTIVATION"
 1091     end
 1092     if ($kgm_kotype == 21)
 1093         printf "SUBSYSTEM"
 1094     end
 1095     if ($kgm_kotype == 22)
 1096         printf "IO_DONE_QUE"
 1097     end
 1098     if ($kgm_kotype == 23)
 1099         printf "SEMAPHORE"
 1100     end
 1101     if ($kgm_kotype == 24)
 1102         printf "LOCK_SET"
 1103     end
 1104     if ($kgm_kotype == 25)
 1105         printf "CLOCK"
 1106     end
 1107     if ($kgm_kotype == 26)
 1108         printf "CLOCK_CTRL"
 1109     end
 1110     if ($kgm_kotype == 27)
 1111         printf "IOKIT_SPARE"
 1112     end
 1113     if ($kgm_kotype == 28)
 1114         printf "NAMED_MEM"
 1115     end
 1116     if ($kgm_kotype == 29)
 1117         printf "IOKIT_CON"
 1118     end
 1119     if ($kgm_kotype == 30)
 1120         printf "IOKIT_OBJ"
 1121     end
 1122     if ($kgm_kotype == 31)
 1123         printf "UPL"
 1124     end
 1125     printf ")\n"
 1126 end
 1127 
 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
 1140             else
 1141                set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
 1142             end
 1143         end
 1144     end
 1145     if $kgm_destprocp != 0
 1146        printf "%s(%d)\n", $kgm_destprocp->p_comm, $kgm_destprocp->p_pid
 1147     else
 1148        printf "task 0x%08x\n", $kgm_taskp
 1149     end
 1150 end
 1151 
 1152 define showportdest
 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
 1157     else
 1158         if ($kgm_portp->ip_object.io_bits & 0x80000000)
 1159             printf "0x%08x  ", $kgm_portp->ip_object.io_receiver_name
 1160             showportdestproc $kgm_portp
 1161         else
 1162             printf "0x%08x  inactive-port\n", $kgm_portp
 1163         end
 1164     end
 1165 end
 1166 
 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)
 1172         printf "A"
 1173     else
 1174         printf " "
 1175     end
 1176     if ($kgm_portp->ip_object.io_bits & 0x7fff0000)
 1177         printf "Set "
 1178     else
 1179         printf "Port"
 1180     end
 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
 1184 end
 1185 
 1186 define showportint
 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)
 1192         printf "A"
 1193     else
 1194         printf "D"
 1195     end
 1196     printf "Port"
 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
 1202         showkmsgheader
 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
 1209         end
 1210     end
 1211 end
 1212 
 1213 define showpsetint
 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)
 1219         printf "A"
 1220     else
 1221         printf "D"
 1222     end
 1223     printf "Set "
 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
 1228     set $kgm_found = 0
 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))
 1231         if !$kgm_found  
 1232             set $kgm_destspacep = (struct ipc_space *)0
 1233             showportdestproc $kgm_portp
 1234             showportmemberheader
 1235             set $kgm_found = 1
 1236         end
 1237         showportmember $kgm_portp 0
 1238         set $kgm_wql = (struct wait_queue_link *)$kgm_wql->wql_setlinks.next
 1239     end
 1240     if !$kgm_found
 1241         printf "--n/e--\n"
 1242     end
 1243 end
 1244 
 1245 define showpset
 1246     showpsetheader
 1247     showpsetint $arg0 1
 1248 end
 1249 
 1250 define showport
 1251     showportheader
 1252     showportint $arg0 1
 1253 end
 1254 
 1255 define showipcobject
 1256     set $kgm_object = (ipc_object_t)$arg0
 1257     if ($kgm_objectp->io_bits & 0x7fff0000)
 1258         showpset $kgm_objectp
 1259     else
 1260         showport $kgm_objectp
 1261     end
 1262 end
 1263 
 1264 define showmqueue
 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))
 1270         showpsetheader
 1271         showpsetint $kgm_pset 1
 1272     end
 1273     if ($kgm_mqueue.data.set_queue.wqs_wait_queue.wq_type == 0xf1d0)
 1274         showportheader
 1275         set $kgm_port = (((int)$arg0) - ((int)$kgm_portoff))
 1276         showportint $kgm_port 1
 1277     end
 1278 end
 1279 
 1280 define zprint_one
 1281 set $kgm_zone = (struct zone *)$arg0
 1282 
 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
 1290 
 1291 if ($kgm_zone->exhaustible)
 1292         printf "H"
 1293 end
 1294 if ($kgm_zone->collectable)
 1295         printf "C"
 1296 end
 1297 if ($kgm_zone->expandable)
 1298         printf "X"
 1299 end
 1300 printf "\n"
 1301 end
 1302 
 1303 
 1304 define zprint
 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
 1310 end
 1311 printf "\n"
 1312 end
 1313 document zprint
 1314 | Routine to print a summary listing of all the kernel zones
 1315 | The following is the syntax:
 1316 |     (gdb) zprint
 1317 end
 1318 
 1319 set $kdp_act_counter = 0
 1320 
 1321 define switchtoact
 1322         if (machine_slot[0].cpu_type == 18)
 1323                 if ($kdp_act_counter == 0)
 1324                 set $kdpstate = (struct savearea *) kdp.saved_state
 1325                 end
 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
 1330                 echo continuation:
 1331                 output/a $newact.thread.continuation
 1332                 echo \n
 1333                 end
 1334                 set (struct savearea *) kdp.saved_state=$newact->mact->pcb
 1335                 flush
 1336                 set $pc=$newact->mact->pcb.save_srr0
 1337                 update
 1338         else
 1339                 echo switchtoact not implemented for this architecture.\n
 1340         end
 1341 end
 1342 
 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.
 1350 end     
 1351 
 1352 define switchtoctx
 1353         if (machine_slot[0].cpu_type == 18)
 1354                 if ($kdp_act_counter == 0)
 1355                 set $kdpstate = (struct savearea *) kdp.saved_state
 1356                 end
 1357                 set $kdp_act_counter = $kdp_act_counter + 1
 1358                 set (struct savearea *) kdp.saved_state=(struct savearea *) $arg0
 1359                 flush
 1360                 set $pc=((struct savearea *) $arg0)->save_srr0
 1361                 update
 1362         else
 1363                 echo switchtoctx not implemented for this architecture.\n
 1364         end
 1365 end
 1366 
 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.
 1373 end     
 1374 
 1375 define resetctx
 1376         if (machine_slot[0].cpu_type == 18)
 1377                 set (struct savearea *)kdp.saved_state=$kdpstate
 1378                 flush
 1379                 set $pc=((struct savearea *) kdp.saved_state)->save_srr0
 1380                 update
 1381                 set $kdp_act_counter = 0
 1382         else
 1383                 echo resetctx not implemented for this architecture.\n
 1384         end
 1385 end     
 1386         
 1387 document resetctx
 1388 | Syntax: resetctx
 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.
 1392 end     
 1393 
 1394 define resume_on
 1395         set noresume_on_disconnect = 0
 1396 end
 1397 
 1398 document resume_on
 1399 | Syntax: resume_on
 1400 | The target system will resume when detaching  or exiting from gdb. 
 1401 | This is the default behavior.
 1402 end
 1403 
 1404 define resume_off
 1405         set noresume_on_disconnect = 1
 1406 end
 1407 
 1408 document resume_off
 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
 1412 end
 1413 
 1414 define paniclog
 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
 1419                         printf "\n"
 1420                 else
 1421                         printf "%c", *$kgm_panic_bufptr
 1422                 end
 1423                 set $kgm_panic_bufptr= (char *)$kgm_panic_bufptr + 1
 1424         end
 1425 end
 1426 
 1427 document paniclog
 1428 | Syntax: paniclog
 1429 | Display the panic log information
 1430 |
 1431 end
 1432 
 1433 define dumpcallqueue
 1434         set $kgm_callhead = (queue_t)&$arg0
 1435         set $kgm_call = (struct call_entry *)$kgm_callhead.next
 1436         set $kgm_i = 0
 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
 1441                 printf "\t"
 1442                 output $kgm_call->deadline
 1443                 printf "\t"
 1444                 output $kgm_call->func
 1445                 printf "\n"
 1446                 set $kgm_i = $kgm_i + 1
 1447                 set $kgm_call = (struct call_entry *)$kgm_call->q_link.next
 1448         end
 1449         printf "%d entries\n", $kgm_i
 1450 end
 1451 
 1452 document dumpcallqueue
 1453 | Syntax: dumpcallqueue <queue head>
 1454 | Displays the contents of the specified call_entry queue.
 1455 end
 1456 
 1457 define showtaskacts
 1458 showtaskthreads $arg0
 1459 end
 1460 document showtaskacts
 1461 | See help showtaskthreads.
 1462 end
 1463 
 1464 define showallacts
 1465 showallthreads
 1466 end
 1467 document showallacts
 1468 | See help showallthreads.
 1469 end

Cache object: 16d6d0817f27518d52e1b177f5d9744e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.