Loading...
--- xnu/xnu-792.13.8/kgmacros
+++ xnu/xnu-1504.3.12/kgmacros
@@ -1,4 +1,3 @@
-#
# Kernel gdb macros
#
# These gdb macros should be useful during kernel development in
@@ -9,6 +8,11 @@
set print asm-demangle on
set cp-abi gnu-v2
+# 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.
+set backtrace sanity-checks off
+
echo Loading Kernel GDB Macros package. Type "help kgm" for more info.\n
define kgm
@@ -20,8 +24,8 @@
| 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>
+| (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
@@ -36,6 +40,7 @@
| 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
+| showallbusyports Display a listing of all ports with unread messages
|
| 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.
@@ -44,6 +49,14 @@
| 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)
|
+| setfindregistrystr Set the encoded string for matching with
+| findregistryentry or findregistryprop (created from
+| strcmp_arg_pack64)
+| findregistryentry Find a registry entry that matches the encoded string
+| findregistryentries Find all the registry entries that match the encoded string
+| findregistryprop Search the registry entry for a property that matches
+| the encoded string
+|
| 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
@@ -51,6 +64,8 @@
| 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
+| showtaskrightsbt Display info about the task's ipc space entries with back traces
+| showtaskbusyports Display all of the task's ports with unread messages
|
| showact Display info about a thread specified by activation
| showactstack Display the stack for a thread specified by activation
@@ -63,6 +78,14 @@
|
| 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
@@ -89,15 +112,146 @@
| resume_off Don't resume when detaching from gdb
|
| sendcore Configure kernel to send a coredump to the specified IP
+| sendsyslog Configure kernel to send a system log to the specified IP
+| sendpaniclog Configure kernel to send a panic log to the specified IP
| disablecore Configure the kernel to disable coredump transmission
+| getdumpinfo Retrieve the current remote dump parameters
+| setdumpinfo Configure the remote dump parameters
+|
| switchtocorethread Corefile version of "switchtoact"
| resetcorectx Corefile version of "resetctx"
|
-| readphys Reads the specified untranslated address
-| readphys64 Reads the specified untranslated 64-bit address
+| readphys8 Reads the specified untranslated address (8-bit read)
+| readphys16 Reads the specified untranslated address (16-bit read)
+| readphys32 Reads the specified untranslated address (32-bit read)
+| readphys64 Reads the specified untranslated address (64-bit read)
+| writephys8 Writes to the specified untranslated address (8-bit write)
+| writephys16 Writes to the specified untranslated address (16-bit write)
+| writephys32 Writes to the specified untranslated address (32-bit write)
+| writephys64 Writes to the specified untranslated address (64-bit write)
|
-| kdp-reboot Restart remote target
-|
+| readioport8 Read 8-bits from the specified I/O Port
+| readioport16 Read 16-bits from the specified I/O Port
+| readioport32 Read 32-bits from the specified I/O Port
+| writeioport8 Write 8-bits into the specified I/O Port
+| writeioport16 Write 16-bits into the specified I/O Port
+| writeioport32 Write 32-bits into the specified I/O Port
+|
+| readmsr64 Read 64-bits from the specified MSR
+| writemsr64 Write 64-bits into the specified MSR
+|
+| rtentry_showdbg Print the debug information of a route entry
+| rtentry_trash Walk the list of trash route entries
+|
+| inifa_showdbg Print the debug information of an IPv4 interface address
+| in6ifa_showdbg Print the debug information of an IPv6 interface address
+|
+| 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
+|
+| showbootargs Display boot arguments passed to the target kernel
+| showbootermemorymap Dump phys memory map from EFI
+|
+| systemlog Display the kernel's printf ring buffer
+|
+| hexdump Show the contents of memory as a hex/ASCII dump
+|
+| showvnodepath Print the path for a vnode
+| showvnodelocks Display list of advisory locks held/blocked on a vnode
+| showvnodedev Display information about a device vnode
+| showtty Display information about a struct tty
+| 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
+|
+| showsocket Display information about a socket
+| showprocsockets Given a proc_t pointer, display information about its sockets
+| showallprocsockets Display information about the sockets of all the processes
+|
+| show_tcp_pcbinfo Display the list of the TCP protocol control blocks
+| show_tcp_timewaitslots Display the list of the TCP protocol control blocks in TIMEWAIT
+| show_udp_pcbinfo Display the list of UDP protocol control blocks
+|
+| show_rt_inet Display the IPv4 routing table
+| show_rt_inet6 Display the IPv6 routing table
+|
+| 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
+| kdp-version Get KDP version number
+| kdp-connect "shorthand" connection macro
+|
+| zstack Print zalloc caller stack (zone leak debugging)
+| findoldest Find oldest zone leak debugging record
+| countpcs Print how often a pc occurs in the zone leak log
+|
+| pmap_walk Perform a page-table walk
+| pmap_vtop Translate a virtual address to physical address
+|
+| showuserlibraries Show binary images known by dyld in the target task
+|
+| showthreadfortid Displays the address of the thread structure for a given thread_id value.
+|
+| strcmp_nomalloc A version of strcmp that avoids the use of malloc
+| through the use of encoded strings created via
+| strcmp_arg_pack64.
+| strcmp_arg_pack64 Pack a string into a 64-bit quantity for use by
+| strcmp_nomalloc
+|
+| pci_cfg_read8 Read 8-bits from a PCI config space register
+| pci_cfg_read16 Read 16-bits from a PCI config space register
+| pci_cfg_read32 Read 32-bits from a PCI config space register
+| pci_cfg_write8 Write 8-bits into a PCI config space register
+| pci_cfg_write16 Write 16-bits into a PCI config space register
+| pci_cfg_write32 Write 32-bits into a PCI config space register
+| pci_cfg_dump Dump entire config space for a PCI device
+| pci_cfg_scan Perform a scan for PCI devices
+| pci_cfg_dump_all Dump config spaces for all detected PCI devices
+|
+| lapic_read32 Read APIC entry
+| lapic_write32 Write APIC entry
+| lapic_dump Dump APIC entries
+|
+| ioapic_read32 Read IOAPIC entry
+| ioapic_write32 Write IOAPIC entry
+| ioapic_dump Dump IOAPIC entries
+|
| Type "help <macro>" for more specific help on a particular macro.
| Type "show user <macro>" to see what the macro is really doing.
end
@@ -105,7 +259,7 @@
# 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
+ kdp-kernelversion
end
document showversion
@@ -119,72 +273,149 @@
| correctly.
end
-set $kgm_dummy = &proc0
-set $kgm_dummy = &kmod
-set $kgm_mtype = ((struct mach_header)_mh_execute_header).cputype
+set $kgm_mtype_ppc = 0x00000012
+set $kgm_mtype_arm = 0x0000000C
+
+set $kgm_mtype_i386 = 0x00000007
+set $kgm_mtype_x86_64 = 0x01000007
+set $kgm_mtype_x86_any = $kgm_mtype_i386
+set $kgm_mtype_x86_mask = 0xFEFFFFFF
+
+set $kgm_mtype = ((unsigned int *)&_mh_execute_header)[1]
+set $kgm_lp64 = $kgm_mtype & 0x01000000
+
+set $kgm_manual_pkt_ppc = 0x549C
+set $kgm_manual_pkt_i386 = 0x249C
+set $kgm_manual_pkt_x86_64 = 0xFFFFFF8000002930
+set $kgm_manual_pkt_arm = 0xFFFF04A0
+
+set $kgm_kdp_pkt_data_len = 128
+
+# part of data packet
+set $kgm_kdp_pkt_hdr_req_off = 0
+set $kgm_kdp_pkt_hdr_seq_off = 1
+set $kgm_kdp_pkt_hdr_len_off = 2
+set $kgm_kdp_pkt_hdr_key_off = 4
+
+# after data packet
+set $kgm_kdp_pkt_len_off = $kgm_kdp_pkt_data_len
+set $kgm_kdp_pkt_input_off = $kgm_kdp_pkt_data_len + 4
+
+set $kgm_kdp_pkt_hostreboot = 0x13
+set $kgm_kdp_pkt_hdr_size = 8
+
+set $kgm_lcpu_self = 0xFFFE
set $kgm_reg_depth = 0
-set $kgm_reg_plane = (void **) gIOServicePlane
+set $kgm_reg_depth_max = 0xFFFF
+set $kgm_reg_plane = (IORegistryPlane *) 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_data_alwaysbytes = 0
+
+set $kgm_show_kmod_syms = 0
+
+# send a manual packet header that doesn't require knowing the location
+# of everything.
+define manualhdrint
+ set $req = $arg0
+
+ set $hdrp = (uint32_t *) $kgm_manual_pkt_i386
+ if ($kgm_mtype == $kgm_mtype_ppc)
+ set $hdrp = (uint32_t *) $kgm_manual_pkt_ppc
+ set $req = $req << 1 # shift to deal with endiannness
+ end
+ if ($kgm_mtype == $kgm_mtype_x86_64)
+ set $hdrp = (uint64_t *) $kgm_manual_pkt_x86_64
+ end
+ if ($kgm_mtype == $kgm_mtype_arm)
+ set $hdrp = (uint32_t *) $kgm_manual_pkt_arm
+ end
+
+ set $pkt_hdr = *$hdrp
+ set *((uint8_t *) ($pkt_hdr + $kgm_kdp_pkt_input_off)) = 0
+ set *((uint32_t *) ($pkt_hdr + $kgm_kdp_pkt_len_off)) = $kgm_kdp_pkt_hdr_size
+
+ set *((uint8_t *) ($pkt_hdr + $kgm_kdp_pkt_hdr_req_off)) = $req
+ set *((uint8_t *) ($pkt_hdr + $kgm_kdp_pkt_hdr_seq_off)) = 0
+ set *((uint16_t *) ($pkt_hdr + $kgm_kdp_pkt_hdr_len_off)) = $kgm_kdp_pkt_hdr_size
+ set *((uint32_t *) ($pkt_hdr + $kgm_kdp_pkt_hdr_key_off)) = 0
+ set *((uint8_t *) ($pkt_hdr + $kgm_kdp_pkt_input_off)) = 1
+
+ # dummy to make sure manual packet is executed
+ set $kgm_dummy = &_mh_execute_header
+end
+
+# Print a pointer
+define showptr
+ if $kgm_lp64
+ printf "0x%016llx", $arg0
+ else
+ printf "0x%08x", $arg0
+ end
+end
+
+# for headers, leave 8 chars for LP64 pointers
+define showptrhdrpad
+ if $kgm_lp64
+ printf " "
+ end
+end
define showkmodheader
- printf "kmod address size "
- printf "id refs version name\n"
+ printf "kmod "
+ showptrhdrpad
+ printf " address "
+ showptrhdrpad
+ printf " size "
+ showptrhdrpad
+ 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
+ showptr $kgm_kmodp
+ printf " "
+ showptr $kgm_kmodp->address
+ printf " "
+ showptr $kgm_kmodp->size
+ printf " "
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
+ printf "%10s ", $kgm_kmodp->version
+ printf "%s\n", $kgm_kmodp->name
+end
+
+# cached info of the last kext found, to speed up subsequent lookups
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)
+ showptr $arg0
+ if ((unsigned long)$arg0 >= (unsigned long)$kgm_pkmodst) && ((unsigned long)$arg0 < (unsigned long)$kgm_pkmoden)
+ set $kgm_off = ((unsigned long)$arg0 - (unsigned long)$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
+ set $kgm_kmodp = (struct kmod_info *)kmod
+ if ($kgm_mtype == $kgm_mtype_x86_64) && ($arg0 >= (unsigned long)&_mh_execute_header)
+ # kexts are loaded below the kernel for x86_64
+ set $kgm_kmodp = 0
+ end
+ while $kgm_kmodp
+ set $kgm_off = ((unsigned long)$arg0 - (unsigned long)$kgm_kmodp->address)
+ if ($kgm_kmodp->address <= $arg0) && ($kgm_off < $kgm_kmodp->size)
+ printf " <%s + 0x%x>", $kgm_kmodp->name, $kgm_off
+ set $kgm_pkmod = $kgm_kmodp
+ set $kgm_pkmodst = $kgm_kmodp->address
+ set $kgm_pkmoden = $kgm_pkmodst + $kgm_kmodp->size
+ set $kgm_kmodp = 0
+ else
+ set $kgm_kmodp = $kgm_kmodp->next
end
end
end
@@ -192,13 +423,11 @@
define showkmodaddr
showkmodaddrint $arg0
- printf "\n"
end
document showkmodaddr
+Syntax: (gdb) showkmodaddr <addr>
| Given an address, print the offset and name for the kmod containing it
-| The following is the syntax:
-| (gdb) showkmodaddr <addr>
end
define showkmod
@@ -206,9 +435,8 @@
showkmodint $arg0
end
document showkmod
+Syntax: (gdb) showkmod <kmod>
| Routine to print info about a kernel module
-| The following is the syntax:
-| (gdb) showkmod <kmod>
end
define showallkmods
@@ -220,22 +448,62 @@
end
end
document showallkmods
+Syntax: (gdb) showallkmods
| Routine to print a summary listing of all the kernel modules
-| The following is the syntax:
-| (gdb) showallkmods
end
define showactheader
- printf " activation "
- printf "thread pri state wait_queue wait_event\n"
+ printf " "
+ showptrhdrpad
+ printf " thread "
+ showptrhdrpad
+ printf " thread_id "
+ showptrhdrpad
+ printf " processor "
+ showptrhdrpad
+ printf " pri io_policy state wait_queue"
+ showptrhdrpad
+ printf " wait_event\n"
end
define showactint
- printf " 0x%08x ", $arg0
+ printf " "
+ showptrhdrpad
set $kgm_thread = *(struct thread *)$arg0
- printf "0x%08x ", $arg0
- printf "%3d ", $kgm_thread.sched_pri
+ showptr $arg0
+ if ($kgm_thread.static_param)
+ printf "[WQ]"
+ else
+ printf " "
+ end
+ printf " %7ld ", $kgm_thread.thread_id
+ showptr $kgm_thread.last_processor
+ printf " %3d ", $kgm_thread.sched_pri
+ if ($kgm_thread.uthread != 0)
+ set $kgm_printed = 0
+ set $kgm_uthread = (struct uthread *)$kgm_thread.uthread
+ if ($kgm_uthread->uu_flag & 0x400)
+ printf "RAGE "
+ else
+ printf " "
+ end
+ if ($kgm_uthread->uu_iopol_disk == 1)
+ printf "NORM "
+ set $kgm_printed = 1
+ end
+ if ($kgm_uthread->uu_iopol_disk == 2)
+ printf "PASS "
+ set $kgm_printed = 1
+ end
+ if ($kgm_uthread->uu_iopol_disk == 3)
+ printf "THROT "
+ set $kgm_printed = 1
+ end
+ if ($kgm_printed == 0)
+ printf " "
+ end
+ end
set $kgm_state = $kgm_thread.state
if $kgm_state & 0x80
printf "I"
@@ -259,32 +527,63 @@
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))
+ printf "W"
+ printf "\t "
+ showptr $kgm_thread.wait_queue
+ printf " "
+ if (((unsigned long)$kgm_thread.wait_event > (unsigned long)&last_kernel_symbol) \
+ && ($arg1 != 2) && ($kgm_show_kmod_syms == 0))
showkmodaddr $kgm_thread.wait_event
else
- output /a (unsigned) $kgm_thread.wait_event
+ output /a $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 "\t \"%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)
+ printf "\n "
+ showptrhdrpad
+ printf " reserved_stack="
+ showptr $kgm_thread.reserved_stack
+ end
+ printf "\n "
+ showptrhdrpad
+ printf " kernel_stack="
+ showptr $kgm_thread.kernel_stack
+ if ($kgm_mtype == $kgm_mtype_ppc)
set $mysp = $kgm_thread.machine.pcb->save_r1
- else
- 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 & $kgm_mtype_x86_mask) == $kgm_mtype_x86_any)
+ set $kgm_statep = (struct x86_kernel_state *) \
+ ($kgm_thread->kernel_stack + kernel_stack_size \
+ - sizeof(struct x86_kernel_state))
+ if ($kgm_mtype == $kgm_mtype_i386)
+ set $mysp = $kgm_statep->k_ebp
+ else
+ set $mysp = $kgm_statep->k_rbp
+ end
+ end
+ if ($kgm_mtype == $kgm_mtype_arm)
+ if (((unsigned long)$r7 < ((unsigned long) ($kgm_thread->kernel_stack+kernel_stack_size))) \
+ && ((unsigned long)$r7 > (unsigned long) ($kgm_thread->kernel_stack)))
+ 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)
+ printf "\n "
+ showptrhdrpad
+ printf " stacktop="
+ showptr $mysp
+ if ($kgm_mtype == $kgm_mtype_ppc)
set $stkmask = 0xf
else
set $stkmask = 0x3
@@ -292,34 +591,46 @@
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))))
-
- if ((unsigned) $kgm_return > (unsigned) sectPRELINKB)
- showkmodaddr $kgm_return
- else
- if ((unsigned) $kgm_return > 0)
- output /a (unsigned) $kgm_return
- end
+ && ((((unsigned long) $mysp ^ (unsigned long) $prevsp) < 0x2000) \
+ || (((unsigned long)$mysp < ((unsigned long) ($kgm_thread->kernel_stack+kernel_stack_size))) \
+ && ((unsigned long)$mysp > (unsigned long) ($kgm_thread->kernel_stack))))
+ printf "\n "
+ showptrhdrpad
+ printf " "
+ showptr $mysp
+ printf " "
+ if ($kgm_mtype == $kgm_mtype_ppc)
+ set $kgm_return = *($mysp + 8)
end
- printf "\n\t\t0x%08x ", $mysp
- if ($kgm_mtype == 18)
- set $kgm_return = *($mysp + 8)
- else
+ if ($kgm_mtype == $kgm_mtype_i386)
set $kgm_return = *($mysp + 4)
end
+ if ($kgm_mtype == $kgm_mtype_x86_64)
+ set $kgm_return = *(unsigned long *)($mysp + 8)
+ end
+ if ($kgm_mtype == $kgm_mtype_arm)
+ set $kgm_return = *($mysp + 4)
+ end
+ if (((unsigned long) $kgm_return < (unsigned long) &_mh_execute_header || \
+ (unsigned long) $kgm_return >= (unsigned long) &last_kernel_symbol ) \
+ && ($kgm_show_kmod_syms == 0))
+ showkmodaddr $kgm_return
+ else
+ output /a $kgm_return
+ end
set $prevsp = $mysp
- set $mysp = * $mysp
- end
- if ((unsigned) $kgm_return > 0)
- output/a $kgm_return
+ set $mysp = *(unsigned long *)$mysp
end
set $kgm_return = 0
- printf "\n\t\tstackbottom=0x%08x", $prevsp
+ printf "\n "
+ showptrhdrpad
+ printf " stackbottom="
+ showptr $prevsp
else
- printf "\n\t\t\tcontinuation="
- output /a (unsigned) $kgm_thread.continuation
+ printf "\n "
+ showptrhdrpad
+ printf " continuation="
+ output /a $kgm_thread.continuation
end
printf "\n"
else
@@ -332,9 +643,8 @@
showactint $arg0 0
end
document showact
+Syntax: (gdb) showact <activation>
| Routine to print out the state of a specific thread.
-| The following is the syntax:
-| (gdb) showact <activation>
end
@@ -343,14 +653,13 @@
showactint $arg0 1
end
document showactstack
+Syntax: (gdb) showactstack <activation>
| Routine to print out the stack of a specific thread.
-| The following is the syntax:
-| (gdb) showactstack <activation>
end
define showallthreads
- set $kgm_head_taskp = &default_pset.tasks
+ set $kgm_head_taskp = &tasks
set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_taskp != $kgm_head_taskp
showtaskheader
@@ -363,18 +672,18 @@
set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
end
printf "\n"
- set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
+ 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.
-| The following is the syntax:
-| (gdb) showallthreads
end
define showcurrentthreads
-set $kgm_prp = processor_list
+set $kgm_prp = (struct processor *)processor_list
while $kgm_prp != 0
+ printf "Processor 0x%08x State %d (cpu_id %x)\n", $kgm_prp, ($kgm_prp)->state, ($kgm_prp)->cpu_id
if ($kgm_prp)->active_thread != 0
set $kgm_actp = ($kgm_prp)->active_thread
showtaskheader
@@ -387,14 +696,13 @@
end
end
document showcurrentthreads
+Syntax: (gdb) showcurrentthreads
| Routine to print out info about the thread running on each cpu.
-| The following is the syntax:
-| (gdb) showcurrentthreads
end
set $decode_wait_events = 0
define showallstacks
- set $kgm_head_taskp = &default_pset.tasks
+ set $kgm_head_taskp = &tasks
set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_taskp != $kgm_head_taskp
showtaskheader
@@ -411,14 +719,13 @@
set $kgm_actp = (struct thread *)($kgm_actp->task_threads.next)
end
printf "\n"
- set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
+ 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.
-| The following is the syntax:
-| (gdb) showallstacks
| 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.
@@ -427,6 +734,7 @@
define showcurrentstacks
set $kgm_prp = processor_list
while $kgm_prp != 0
+ printf "Processor 0x%08x State %d (cpu_id %x)\n", $kgm_prp, ($kgm_prp)->state, ($kgm_prp)->cpu_id
if ($kgm_prp)->active_thread != 0
set $kgm_actp = ($kgm_prp)->active_thread
showtaskheader
@@ -440,20 +748,19 @@
end
document showcurrentstacks
+Syntax: (gdb) showcurrentstacks
| Routine to print out the thread running on each cpu (incl. its stack)
-| The following is the syntax:
-| (gdb) showcurrentstacks
end
define showwaiterheader
- printf "waiters activation "
- printf "thread pri state wait_queue wait_event\n"
+ printf "waiters thread "
+ printf "processor pri state wait_queue wait_event\n"
end
define showwaitqwaiters
- set $kgm_w_waitqp = (struct wait_queue *)$arg0
+ set $kgm_w_waitqp = (WaitQueue*)$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_wqe = (WaitQueueElement *)$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)
@@ -464,32 +771,32 @@
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
+ set $kgm_w_wqe = (WaitQueueElement *)$kgm_w_wqe->wqe_links.next
end
end
define showwaitqwaitercount
- set $kgm_wc_waitqp = (struct wait_queue *)$arg0
+ set $kgm_wc_waitqp = (WaitQueue*)$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_wqe = (WaitQueueElement *)$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
+ set $kgm_wc_wqe = (WaitQueueElement *)$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_waitqsetp = (WaitQueueSet*)$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_wql = (WaitQueueLink *)$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
+ set $kgm_mc_wql = (WaitQueueLink *)$kgm_mc_wql->wql_setlinks.next
end
printf "0x%08x ", $kgm_mc_count
end
@@ -501,7 +808,7 @@
end
define showwaitqmemberint
- set $kgm_m_waitqp = (struct wait_queue *)$arg0
+ set $kgm_m_waitqp = (WaitQueue*)$arg0
printf " 0x%08x ", $kgm_m_waitqp
printf "0x%08x ", $kgm_m_waitqp->wq_interlock.lock_data
if ($kgm_m_waitqp->wq_fifo)
@@ -526,9 +833,9 @@
end
define showwaitqmemberof
- set $kgm_mo_waitqp = (struct wait_queue *)$arg0
+ set $kgm_mo_waitqp = (WaitQueue*)$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_wqe = (WaitQueueElement *)$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)
@@ -536,18 +843,18 @@
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)
+ set $kgm_mo_wqlp = (WaitQueueLink *)$kgm_mo_wqe
+ set $kgm_mo_wqsetp = (WaitQueue*)($kgm_mo_wqlp->wql_setqueue)
showwaitqmemberint $kgm_mo_wqsetp
end
- set $kgm_mo_wqe = (struct wait_queue_element *)$kgm_mo_wqe->wqe_links.next
+ set $kgm_mo_wqe = (WaitQueueElement *)$kgm_mo_wqe->wqe_links.next
end
end
define showwaitqmembers
- set $kgm_ms_waitqsetp = (struct wait_queue_set *)$arg0
+ set $kgm_ms_waitqsetp = (WaitQueueSet*)$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_wql = (WaitQueueLink *)$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
@@ -556,7 +863,7 @@
set $kgm_ms_found = 1
end
showwaitqmemberint $kgm_ms_waitqp
- set $kgm_ms_wql = (struct wait_queue_link *)$kgm_ms_wql->wql_setlinks.next
+ set $kgm_ms_wql = (WaitQueueLink *)$kgm_ms_wql->wql_setlinks.next
end
end
@@ -566,10 +873,10 @@
end
define showwaitqint
- set $kgm_waitqp = (struct wait_queue *)$arg0
+ set $kgm_waitqp = (WaitQueue*)$arg0
printf "0x%08x ", $kgm_waitqp
if ($kgm_waitqp->wq_type == 0xf1d1)
- printf "0x%08x ", ((struct wait_queue_set *)$kgm_waitqp)->wqs_refcount
+ printf "0x%08x ", ((WaitQueueSet*)$kgm_waitqp)->wqs_refcount
else
printf "0x00000000 "
end
@@ -590,7 +897,7 @@
end
define showwaitq
- set $kgm_waitq1p = (wait_queue_t)$arg0
+ set $kgm_waitq1p = (WaitQueue*)$arg0
showwaitqheader
showwaitqint $kgm_waitq1p
if ($kgm_waitq1p->wq_type == 0xf1d1)
@@ -602,64 +909,79 @@
end
define showmapheader
- printf "vm_map pmap vm_size "
- printf "#ents rpage hint first_free\n"
+ printf "vm_map "
+ showptrhdrpad
+ printf " pmap "
+ showptrhdrpad
+ printf " vm_size "
+ showptrhdrpad
+ printf " #ents rpage hint "
+ showptrhdrpad
+ printf " first_free\n"
end
define showvmeheader
- printf " entry start "
- printf " prot #page object offset\n"
+ printf " entry "
+ showptrhdrpad
+ printf " start prot #page object "
+ showptrhdrpad
+ printf " 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
+ showptr $arg0
+ printf " "
+ showptr $kgm_map.pmap
+ printf " "
+ showptr $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
+ showptr $kgm_map.hint
+ printf " "
+ showptr $kgm_map.first_free
+ printf "\n"
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
+ 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 " "
+ showptr $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 "%6d ",($kgm_vme.links.end - $kgm_vme.links.start) >> 12
+ showptr $kgm_vme.object.vm_object
+ printf " 0x%016llx\n", $kgm_vme.offset
+ set $kgm_vmep = $kgm_vme.links.next
end
end
printf "\n"
@@ -671,9 +993,8 @@
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
-| The following is the syntax:
-| (gdb) showmapvme <vm_map>
end
@@ -682,92 +1003,96 @@
showvmint $arg0 0
end
document showmap
+Syntax: (gdb) showmap <vm_map>
| Routine to print out info about the specified vm_map
-| The following is the syntax:
-| (gdb) showmap <vm_map>
end
define showallvm
- set $kgm_head_taskp = &default_pset.tasks
+ 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->pset_tasks.next)
+ 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
-| The following is the syntax:
-| (gdb) showallvm
end
define showallvme
- set $kgm_head_taskp = &default_pset.tasks
+ 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->pset_tasks.next)
+ 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
-| The following is the syntax:
-| (gdb) showallvme
end
define showipcheader
- printf "ipc_space is_table table_next "
- printf "flags tsize splaytree splaybase\n"
+ printf "ipc_space "
+ showptrhdrpad
+ printf " is_table "
+ showptrhdrpad
+ printf " table_next"
+ showptrhdrpad
+ printf " flags tsize splaytree splaybase\n"
end
define showipceheader
- printf " name object "
- printf "rite urefs destname destination\n"
+ printf " name object "
+ showptrhdrpad
+ 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
+ showptr $kgm_ie.ie_object
+ printf " "
if $kgm_ie.ie_bits & 0x00100000
- printf "Dead "
+ printf "Dead "
printf "%5d\n", $kgm_ie.ie_bits & 0xffff
else
if $kgm_ie.ie_bits & 0x00080000
- printf "SET "
+ 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
+ if $kgm_ie.ie_bits & 0x00020000
+ printf " SR"
+ else
+ printf " S"
+ end
else
- if $kgm_ie.ie_bits & 0x00020000
- printf " R"
- end
+ if $kgm_ie.ie_bits & 0x00020000
+ printf " R"
+ end
end
if $kgm_ie.ie_bits & 0x00040000
- printf " O"
+ printf " O"
end
if $kgm_ie.index.request
- printf "n"
+ printf "n"
else
printf " "
end
if $kgm_ie.ie_bits & 0x00800000
- printf "c"
+ printf "c"
else
- printf " "
+ printf " "
end
printf "%5d ", $kgm_ie.ie_bits & 0xffff
showportdest $kgm_ie.ie_object
@@ -778,69 +1103,75 @@
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
+ showptr $arg0
+ printf " "
+ showptr $kgm_is.is_table
+ printf " "
+ showptr $kgm_is.is_table_next
+ printf " "
if $kgm_is.is_growing != 0
- printf "G"
+ printf "G"
else
- printf " "
+ printf " "
end
if $kgm_is.is_fast != 0
- printf "F"
+ printf "F"
else
- printf " "
+ printf " "
end
if $kgm_is.is_active != 0
- printf "A "
+ printf "A "
else
- printf " "
+ 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
+ showptr &$kgm_isp->is_tree
+ printf "\n"
if $arg1 != 0
- showipceheader
- set $kgm_iindex = 0
- set $kgm_iep = $kgm_is.is_table
- set $kgm_destspacep = (ipc_space_t)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
+ 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
+ if $arg2 != 0 && $kgm_ie.ie_object != 0 && ($kgm_ie.ie_bits & 0x00070000) && ((ipc_port_t) $kgm_ie.ie_object)->ip_callstack[0] != 0
+ printf " user bt: "
+ showportbt $kgm_ie.ie_object $kgm_is.is_task
+ end
+ 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
+ set $kgm_isp = (ipc_space_t)$arg0
+ showipcheader
+ showipcint $kgm_isp 0 0
end
document showipc
+Syntax: (gdb) showipc <ipc_space>
| Routine to print the status of the specified ipc space
-| The following is the syntax:
-| (gdb) showipc <ipc_space>
end
define showrights
set $kgm_isp = (ipc_space_t)$arg0
- showipcheader
- showipcint $kgm_isp 1
+ showipcheader
+ showipcint $kgm_isp 1 0
end
document showrights
+Syntax: (gdb) showrights <ipc_space>
| Routine to print a summary list of all the rights in a specified ipc space
-| The following is the syntax:
-| (gdb) showrights <ipc_space>
end
@@ -849,61 +1180,69 @@
showtaskheader
showipcheader
showtaskint $kgm_taskp
- showipcint $kgm_taskp->itk_space 0
+ showipcint $kgm_taskp->itk_space 0 0
end
document showtaskipc
+Syntax: (gdb) showtaskipc <task>
| Routine to print info about the ipc space for a task
-| The following is the syntax:
-| (gdb) showtaskipc <task>
end
define showtaskrights
set $kgm_taskp = (task_t)$arg0
showtaskheader
- showipcheader
+ showipcheader
showtaskint $kgm_taskp
- showipcint $kgm_taskp->itk_space 1
+ showipcint $kgm_taskp->itk_space 1 0
end
document showtaskrights
+Syntax: (gdb) showtaskrights <task>
| Routine to print info about the ipc rights for a task
-| The following is the syntax:
-| (gdb) showtaskrights <task>
+end
+
+define showtaskrightsbt
+ set $kgm_taskp = (task_t)$arg0
+ showtaskheader
+ showipcheader
+ showtaskint $kgm_taskp
+ showipcint $kgm_taskp->itk_space 1 1
+end
+document showtaskrightsbt
+Syntax: (gdb) showtaskrightsbt <task>
+| Routine to print info about the ipc rights for a task with backtraces
end
define showallipc
- set $kgm_head_taskp = &default_pset.tasks
+ 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->pset_tasks.next)
+ showtaskint $kgm_cur_taskp
+ showipcint $kgm_cur_taskp->itk_space 0 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
-| The following is the syntax:
-| (gdb) showallipc
end
define showallrights
- set $kgm_head_taskp = &default_pset.tasks
+ 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->pset_tasks.next)
+ showtaskint $kgm_cur_taskp
+ showipcint $kgm_cur_taskp->itk_space 1 0
+ 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
-| The following is the syntax:
-| (gdb) showallrights
end
@@ -915,9 +1254,8 @@
showvmint $kgm_taskp->map 0
end
document showtaskvm
+Syntax: (gdb) showtaskvm <task>
| Routine to print out info about a task's vm_map
-| The following is the syntax:
-| (gdb) showtaskvm <task>
end
define showtaskvme
@@ -928,25 +1266,32 @@
showvmint $kgm_taskp->map 1
end
document showtaskvme
+Syntax: (gdb) showtaskvme <task>
| Routine to print out info about a task's vm_map_entries
-| The following is the syntax:
-| (gdb) showtaskvme <task>
end
define showtaskheader
- printf "task vm_map ipc_space #acts "
+ printf "task "
+ showptrhdrpad
+ printf " vm_map "
+ showptrhdrpad
+ printf " ipc_space "
+ showptrhdrpad
+ printf " #acts "
showprocheader
end
define showtaskint
- set $kgm_task = *(struct task *)$arg0
- printf "0x%08x ", $arg0
- printf "0x%08x ", $kgm_task.map
- printf "0x%08x ", $kgm_task.itk_space
- printf "%3d ", $kgm_task.thread_count
- showprocint $kgm_task.bsd_info
+ set $kgm_taskp = (struct task *)$arg0
+ showptr $arg0
+ printf " "
+ showptr $kgm_taskp->map
+ printf " "
+ showptr $kgm_taskp->itk_space
+ printf " %5d ", $kgm_taskp->thread_count
+ showprocint $kgm_taskp->bsd_info
end
define showtask
@@ -954,9 +1299,8 @@
showtaskint $arg0
end
document showtask
+Syntax (gdb) showtask <task>
| Routine to print out info about a task.
-| The following is the syntax:
-| (gdb) showtask <task>
end
@@ -973,9 +1317,8 @@
end
end
document showtaskthreads
+Syntax: (gdb) showtaskthreads <task>
| Routine to print info about the threads in a task.
-| The following is the syntax:
-| (gdb) showtaskthreads <task>
end
@@ -992,46 +1335,80 @@
end
end
document showtaskstacks
+Syntax: (gdb) showtaskstacks <task>
| Routine to print out the stack for each thread in a task.
-| The following is the syntax:
-| (gdb) showtaskstacks <task>
end
define showalltasks
showtaskheader
- set $kgm_head_taskp = &default_pset.tasks
+ set $kgm_head_taskp = &tasks
set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_taskp != $kgm_head_taskp
showtaskint $kgm_taskp
- set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
+ set $kgm_taskp = (struct task *)($kgm_taskp->tasks.next)
end
end
document showalltasks
+Syntax: (gdb) showalltasks
| Routine to print a summary listing of all the tasks
-| The following is the syntax:
-| (gdb) showalltasks
-end
-
+| wq_state -> reports "number of workq threads", "number of scheduled workq threads", "number of pending work items"
+| if "number of pending work items" seems stuck at non-zero, it may indicate that the workqueue mechanism is hung
+| io_policy -> RAGE - rapid aging of vnodes requested
+| NORM - normal I/O explicitly requested (this is the default)
+| PASS - passive I/O requested (i.e. I/Os do not affect throttling decisions)
+| THROT - throttled I/O requested (i.e. thread/task may be throttled after each I/O completes)
+end
define showprocheader
- printf " pid proc command\n"
+ printf " pid process io_policy wq_state"
+ showptrhdrpad
+ printf " command\n"
end
define showprocint
set $kgm_procp = (struct proc *)$arg0
if $kgm_procp != 0
+ set $kgm_printed = 0
printf "%5d ", $kgm_procp->p_pid
- printf "0x%08x ", $kgm_procp
- printf "%s\n", $kgm_procp->p_comm
+ showptr $kgm_procp
+ if ($kgm_procp->p_lflag & 0x400000)
+ printf " RAGE "
+ else
+ printf " "
+ end
+ if ($kgm_procp->p_iopol_disk == 1)
+ printf "NORM "
+ set $kgm_printed = 1
+ end
+ if ($kgm_procp->p_iopol_disk == 2)
+ printf "PASS "
+ set $kgm_printed = 1
+ end
+ if ($kgm_procp->p_iopol_disk == 3)
+ printf "THROT "
+ set $kgm_printed = 1
+ end
+ if ($kgm_printed == 0)
+ printf " "
+ end
+ set $kgm_wqp = (struct workqueue *)$kgm_procp->p_wqptr
+ if $kgm_wqp != 0
+ printf " %2d %2d %2d ", $kgm_wqp->wq_nthreads, $kgm_wqp->wq_thidlecount, $kgm_wqp->wq_itemcount
+ else
+ printf " "
+ end
+ printf " %s\n", $kgm_procp->p_comm
else
- printf " *0* 0x00000000 --\n"
+ printf " *0* "
+ showptr 0
+ printf " --\n"
end
end
define showpid
showtaskheader
- set $kgm_head_taskp = &default_pset.tasks
+ set $kgm_head_taskp = &tasks
set $kgm_taskp = (struct task *)($kgm_head_taskp->next)
while $kgm_taskp != $kgm_head_taskp
set $kgm_procp = (struct proc *)$kgm_taskp->bsd_info
@@ -1039,20 +1416,19 @@
showtaskint $kgm_taskp
set $kgm_taskp = $kgm_head_taskp
else
- set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next)
+ set $kgm_taskp = (struct task *)($kgm_taskp->tasks.next)
end
end
end
document showpid
+Syntax: (gdb) showpid <pid>
| Routine to print a single process by pid
-| The following is the syntax:
-| (gdb) showpid <pid>
end
define showproc
showtaskheader
set $kgm_procp = (struct proc *)$arg0
- showtaskint $kgm_procp->task $arg1 $arg2
+ showtaskint $kgm_procp->task
end
@@ -1097,7 +1473,7 @@
else
printf "rM"
end
- if (($kgm_kmsgh.msgh_bits & 0xff00) == (19 < 8))
+ if (($kgm_kmsgh.msgh_bits & 0xff00) == (19 << 8))
printf "lC"
else
printf "lM"
@@ -1116,7 +1492,8 @@
define showkobject
set $kgm_portp = (struct ipc_port *)$arg0
- printf "0x%08x kobject(", $kgm_portp->ip_kobject
+ showptr $kgm_portp->ip_kobject
+ printf " kobject("
set $kgm_kotype = ($kgm_portp->ip_object.io_bits & 0x00000fff)
if ($kgm_kotype == 1)
printf "THREAD"
@@ -1220,21 +1597,23 @@
# check against the previous cached value - this is slow
if ($kgm_spacep != $kgm_destspacep)
set $kgm_destprocp = (struct proc *)0
- set $kgm_head_taskp = &default_pset.tasks
+ set $kgm_head_taskp = &tasks
set $kgm_desttaskp = (struct task *)($kgm_head_taskp->next)
while (($kgm_destprocp == 0) && ($kgm_desttaskp != $kgm_head_taskp))
set $kgm_destspacep = $kgm_desttaskp->itk_space
if ($kgm_destspacep == $kgm_spacep)
set $kgm_destprocp = (struct proc *)$kgm_desttaskp->bsd_info
else
- set $kgm_desttaskp = (struct task *)($kgm_desttaskp->pset_tasks.next)
+ set $kgm_desttaskp = (struct task *)($kgm_desttaskp->tasks.next)
end
end
end
if $kgm_destprocp != 0
printf "%s(%d)\n", $kgm_destprocp->p_comm, $kgm_destprocp->p_pid
else
- printf "task 0x%08x\n", $kgm_desttaskp
+ printf "task "
+ showptr $kgm_desttaskp
+ printf "\n"
end
end
@@ -1245,10 +1624,12 @@
showkobject $kgm_portp
else
if ($kgm_portp->ip_object.io_bits & 0x80000000)
- printf "0x%08x ", $kgm_portp->ip_object.io_receiver_name
+ showptr $kgm_portp->ip_messages.data.port.receiver_name
+ printf " "
showportdestproc $kgm_portp
else
- printf "0x%08x inactive-port\n", $kgm_portp
+ showptr $kgm_portp
+ printf " inactive-port\n"
end
end
end
@@ -1256,27 +1637,42 @@
define showportmember
printf " 0x%08x ", $arg0
set $kgm_portp = (struct ipc_port *)$arg0
- printf "0x%08x ", $kgm_portp->ip_object.io_receiver_name
+ printf "0x%08x ", $kgm_portp->ip_messages.data.port.receiver_name
if ($kgm_portp->ip_object.io_bits & 0x80000000)
printf "A"
else
printf " "
end
- if ($kgm_portp->ip_object.io_bits & 0x7fff0000)
- printf "Set "
- else
- printf "Port"
- end
+ printf "Port"
printf "%5d ", $kgm_portp->ip_object.io_references
printf "0x%08x ", &($kgm_portp->ip_messages)
printf "0x%08x\n", $kgm_portp->ip_messages.data.port.msgcount
+end
+
+define showportbt
+ set $kgm_iebt = ((ipc_port_t) $arg0)->ip_callstack
+ set $kgm_iepid = ((ipc_port_t) $arg0)->ip_spares[0]
+ set $kgm_procpid = ((proc_t) (((task_t) $arg1)->bsd_info))->p_pid
+ if $kgm_iebt[0] != 0
+ showptr $kgm_iebt[0]
+ set $kgm_iebt_loop_ctr = 1
+ while ($kgm_iebt_loop_ctr < 16 && $kgm_iebt[$kgm_iebt_loop_ctr])
+ printf " "
+ showptr $kgm_iebt[$kgm_iebt_loop_ctr]
+ set $kgm_iebt_loop_ctr = $kgm_iebt_loop_ctr + 1
+ end
+ if $kgm_iepid != $kgm_procpid
+ printf " (%d)", $kgm_iepid
+ end
+ printf "\n"
+ end
end
define showportint
printf "0x%08x ", $arg0
set $kgm_portp = (struct ipc_port *)$arg0
printf "0x%08x ", &($kgm_portp->ip_messages)
- printf "0x%08x ", $kgm_portp->ip_object.io_receiver_name
+ printf "0x%08x ", $kgm_portp->ip_messages.data.port.receiver_name
if ($kgm_portp->ip_object.io_bits & 0x80000000)
printf "A"
else
@@ -1303,7 +1699,7 @@
printf "0x%08x ", $arg0
set $kgm_psetp = (struct ipc_pset *)$arg0
printf "0x%08x ", &($kgm_psetp->ips_messages)
- printf "0x%08x ", $kgm_psetp->ips_object.io_receiver_name
+ printf "0x%08x ", $kgm_psetp->ips_messages.data.pset.local_name
if ($kgm_psetp->ips_object.io_bits & 0x80000000)
printf "A"
else
@@ -1311,9 +1707,9 @@
end
printf "Set "
printf "%5d ", $kgm_psetp->ips_object.io_references
- printf "0x%08x ", $kgm_psetp->ips_object.io_receiver_name
+ printf "0x%08x ", $kgm_psetp->ips_messages.data.pset.local_name
set $kgm_setlinksp = &($kgm_psetp->ips_messages.data.set_queue.wqs_setlinks)
- set $kgm_wql = (struct wait_queue_link *)$kgm_setlinksp->next
+ set $kgm_wql = (WaitQueueLink *)$kgm_setlinksp->next
set $kgm_found = 0
while ( (queue_entry_t)$kgm_wql != (queue_entry_t)$kgm_setlinksp)
set $kgm_portp = (struct ipc_port *)((int)($kgm_wql->wql_element->wqe_queue) - ((int)$kgm_portoff))
@@ -1324,7 +1720,7 @@
set $kgm_found = 1
end
showportmember $kgm_portp 0
- set $kgm_wql = (struct wait_queue_link *)$kgm_wql->wql_setlinks.next
+ set $kgm_wql = (WaitQueueLink *)$kgm_wql->wql_setlinks.next
end
if !$kgm_found
printf "--n/e--\n"
@@ -1352,163 +1748,251 @@
define showmqueue
set $kgm_mqueue = *(struct ipc_mqueue *)$arg0
- set $kgm_psetoff = &(((struct ipc_pset *)0)->ips_messages)
- set $kgm_portoff = &(((struct ipc_port *)0)->ip_messages)
- if ($kgm_mqueue.data.set_queue.wqs_wait_queue.wq_type == 0xf1d1)
- set $kgm_pset = (((int)$arg0) - ((int)$kgm_psetoff))
+ if ($kgm_mqueue.data.pset.set_queue.wqs_wait_queue.wq_type == 0xf1d1)
+ set $kgm_psetoff = &(((struct ipc_pset *)0)->ips_messages)
+ set $kgm_pset = (((long)$arg0) - ((long)$kgm_psetoff))
showpsetheader
showpsetint $kgm_pset 1
end
- if ($kgm_mqueue.data.set_queue.wqs_wait_queue.wq_type == 0xf1d0)
+ if ($kgm_mqueue.data.pset.set_queue.wqs_wait_queue.wq_type == 0xf1d0)
+ set $kgm_portoff = &(((struct ipc_port *)0)->ip_messages)
+ set $kgm_port = (((long)$arg0) - ((long)$kgm_portoff))
showportheader
- set $kgm_port = (((int)$arg0) - ((int)$kgm_portoff))
showportint $kgm_port 1
end
end
define zprint_one
-set $kgm_zone = (struct zone *)$arg0
-
-printf "0x%08x ", $kgm_zone
-printf "%8d ",$kgm_zone->count
-printf "%8x ",$kgm_zone->cur_size
-printf "%8x ",$kgm_zone->max_size
-printf "%6d ",$kgm_zone->elem_size
-printf "%8x ",$kgm_zone->alloc_size
-printf "%s ",$kgm_zone->zone_name
-
-if ($kgm_zone->exhaustible)
- printf "H"
-end
-if ($kgm_zone->collectable)
- printf "C"
-end
-if ($kgm_zone->expandable)
- printf "X"
-end
-printf "\n"
+ set $kgm_zone = (struct zone *)$arg0
+
+ showptr $kgm_zone
+ printf " %6d ",$kgm_zone->count
+ printf "%8x ",$kgm_zone->cur_size
+ printf "%8x ",$kgm_zone->max_size
+ printf "%6d ",$kgm_zone->elem_size
+ printf "%8x ",$kgm_zone->alloc_size
+ printf "%s ",$kgm_zone->zone_name
+
+ if ($kgm_zone->exhaustible)
+ printf "H"
+ end
+ if ($kgm_zone->collectable)
+ printf "C"
+ end
+ if ($kgm_zone->expandable)
+ printf "X"
+ end
+ printf "\n"
end
define zprint
-printf "ZONE COUNT TOT_SZ MAX_SZ ELT_SZ ALLOC_SZ NAME\n"
-set $kgm_zone_ptr = (struct zone *)first_zone
-while ($kgm_zone_ptr != 0)
- zprint_one $kgm_zone_ptr
- set $kgm_zone_ptr = $kgm_zone_ptr->next_zone
-end
-printf "\n"
+ printf "ZONE "
+ showptrhdrpad
+ printf " COUNT TOT_SZ MAX_SZ ELT_SZ ALLOC_SZ NAME\n"
+ set $kgm_zone_ptr = (struct zone *)first_zone
+ while ($kgm_zone_ptr != 0)
+ zprint_one $kgm_zone_ptr
+ set $kgm_zone_ptr = $kgm_zone_ptr->next_zone
+ end
+ printf "\n"
end
document zprint
+Syntax: (gdb) zprint
| Routine to print a summary listing of all the kernel zones
-| The following is the syntax:
-| (gdb) zprint
end
define showmtxgrp
-set $kgm_mtxgrp = (lck_grp_t *)$arg0
-
-if ($kgm_mtxgrp->lck_grp_mtxcnt)
-printf "0x%08x ", $kgm_mtxgrp
-printf "%8d ",$kgm_mtxgrp->lck_grp_mtxcnt
-printf "%12u ",$kgm_mtxgrp->lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_util_cnt
-printf "%8u ",$kgm_mtxgrp->lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_miss_cnt
-printf "%8u ",$kgm_mtxgrp->lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_wait_cnt
-printf "%s ",&$kgm_mtxgrp->lck_grp_name
-printf "\n"
-end
+ set $kgm_mtxgrp = (struct _lck_grp_ *)$arg0
+
+ if ($kgm_mtxgrp->lck_grp_mtxcnt)
+ showptr $kgm_mtxgrp
+ printf " %8d ",$kgm_mtxgrp->lck_grp_mtxcnt
+ printf "%12u ",$kgm_mtxgrp->lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_util_cnt
+ printf "%8u ",$kgm_mtxgrp->lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_miss_cnt
+ printf "%8u ",$kgm_mtxgrp->lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_wait_cnt
+ printf "%s ",&$kgm_mtxgrp->lck_grp_name
+ printf "\n"
+ end
end
define showallmtx
-printf "LCK GROUP CNT UTIL MISS WAIT NAME\n"
-set $kgm_mtxgrp_ptr = (lck_grp_t *)&lck_grp_queue
-set $kgm_mtxgrp_ptr = (lck_grp_t *)$kgm_mtxgrp_ptr->lck_grp_link.next
-while ($kgm_mtxgrp_ptr != (lck_grp_t *)&lck_grp_queue)
- showmtxgrp $kgm_mtxgrp_ptr
- set $kgm_mtxgrp_ptr = (lck_grp_t *)$kgm_mtxgrp_ptr->lck_grp_link.next
-end
-printf "\n"
+ printf "LCK GROUP "
+ showptrhdrpad
+ printf " CNT UTIL MISS WAIT NAME\n"
+ set $kgm_mtxgrp_ptr = (struct _lck_grp_ *)&lck_grp_queue
+ set $kgm_mtxgrp_ptr = (struct _lck_grp_ *)$kgm_mtxgrp_ptr->lck_grp_link.next
+ while ($kgm_mtxgrp_ptr != (struct _lck_grp_ *)&lck_grp_queue)
+ showmtxgrp $kgm_mtxgrp_ptr
+ set $kgm_mtxgrp_ptr = (struct _lck_grp_ *)$kgm_mtxgrp_ptr->lck_grp_link.next
+ end
+ printf "\n"
end
document showallmtx
+Syntax: (gdb) showallmtx
| Routine to print a summary listing of all mutexes
-| The following is the syntax:
-| (gdb) showallmtx
end
define showrwlckgrp
-set $kgm_rwlckgrp = (lck_grp_t *)$arg0
-
-if ($kgm_rwlckgrp->lck_grp_rwcnt)
-printf "0x%08x ", $kgm_rwlckgrp
-printf "%8d ",$kgm_rwlckgrp->lck_grp_rwcnt
-printf "%12u ",$kgm_rwlckgrp->lck_grp_stat.lck_grp_rw_stat.lck_grp_rw_util_cnt
-printf "%8u ",$kgm_rwlckgrp->lck_grp_stat.lck_grp_rw_stat.lck_grp_rw_miss_cnt
-printf "%8u ",$kgm_rwlckgrp->lck_grp_stat.lck_grp_rw_stat.lck_grp_rw_wait_cnt
-printf "%s ",&$kgm_rwlckgrp->lck_grp_name
-printf "\n"
-end
+ set $kgm_rwlckgrp = (struct _lck_grp_ *)$arg0
+
+ if ($kgm_rwlckgrp->lck_grp_rwcnt)
+ showptr $kgm_rwlckgrp
+ printf " %8d ",$kgm_rwlckgrp->lck_grp_rwcnt
+ printf "%12u ",$kgm_rwlckgrp->lck_grp_stat.lck_grp_rw_stat.lck_grp_rw_util_cnt
+ printf "%8u ",$kgm_rwlckgrp->lck_grp_stat.lck_grp_rw_stat.lck_grp_rw_miss_cnt
+ printf "%8u ",$kgm_rwlckgrp->lck_grp_stat.lck_grp_rw_stat.lck_grp_rw_wait_cnt
+ printf "%s ",&$kgm_rwlckgrp->lck_grp_name
+ printf "\n"
+ end
end
define showallrwlck
-printf "LCK GROUP CNT UTIL MISS WAIT NAME\n"
-set $kgm_rwlckgrp_ptr = (lck_grp_t *)&lck_grp_queue
-set $kgm_rwlckgrp_ptr = (lck_grp_t *)$kgm_rwlckgrp_ptr->lck_grp_link.next
-while ($kgm_rwlckgrp_ptr != (lck_grp_t *)&lck_grp_queue)
- showrwlckgrp $kgm_rwlckgrp_ptr
- set $kgm_rwlckgrp_ptr = (lck_grp_t *)$kgm_rwlckgrp_ptr->lck_grp_link.next
-end
-printf "\n"
+ printf "LCK GROUP "
+ showptrhdrpad
+ printf " CNT UTIL MISS WAIT NAME\n"
+ set $kgm_rwlckgrp_ptr = (struct _lck_grp_ *)&lck_grp_queue
+ set $kgm_rwlckgrp_ptr = (struct _lck_grp_ *)$kgm_rwlckgrp_ptr->lck_grp_link.next
+ while ($kgm_rwlckgrp_ptr != (struct _lck_grp_ *)&lck_grp_queue)
+ showrwlckgrp $kgm_rwlckgrp_ptr
+ set $kgm_rwlckgrp_ptr = (struct _lck_grp_ *)$kgm_rwlckgrp_ptr->lck_grp_link.next
+ end
+ printf "\n"
end
document showallrwlck
+Syntax: (gdb) showallrwlck
| Routine to print a summary listing of all read/writer locks
-| The following is the syntax:
-| (gdb) showallrwlck
end
set $kdp_act_counter = 0
+
+set $r0_save = 0
+set $r1_save = 0
+set $r2_save = 0
+set $r3_save = 0
+set $r4_save = 0
+set $r5_save = 0
+set $r6_save = 0
+set $r7_save = 0
+set $r8_save = 0
+set $r9_save = 0
+set $r10_save = 0
+set $r11_save = 0
+set $r12_save = 0
+set $sp_save = 0
+set $lr_save = 0
+set $pc_save = 0
+
+define showcontext_int
+ echo Context switched, current instruction pointer:
+ output/a $pc
+ echo \n
+end
define switchtoact
set $newact = (struct thread *) $arg0
+ select 0
if ($newact->kernel_stack == 0)
echo This activation does not have a stack.\n
echo continuation:
output/a (unsigned) $newact.continuation
echo \n
else
- if ($kgm_mtype == 18)
+ if ($kgm_mtype == $kgm_mtype_ppc)
if ($kdp_act_counter == 0)
set $kdpstate = (struct savearea *) kdp.saved_state
end
set $kdp_act_counter = $kdp_act_counter + 1
- set $newact = (struct thread *) $arg0
set (struct savearea *) kdp.saved_state=$newact->machine->pcb
flushregs
flushstack
set $pc=$newact->machine->pcb.save_srr0
update
- else
+ end
+ if ($kgm_mtype == $kgm_mtype_i386)
set $kdpstatep = (struct x86_saved_state32 *) kdp.saved_state
if ($kdp_act_counter == 0)
- set $kdpstate = *($kdpstatep)
+ set $kdpstate = *($kdpstatep)
end
set $kdp_act_counter = $kdp_act_counter + 1
- set $kgm_statep = (struct x86_kernel_state32 *) \
- ($newact->kernel_stack + 0x4000 \
- - sizeof(struct x86_kernel_state32))
- set $kdpstatep->ebx = $kgm_statep->k_ebx
+ set $kgm_statep = (struct x86_kernel_state *) \
+ ($newact->kernel_stack + kernel_stack_size \
+ - sizeof(struct x86_kernel_state))
+ set $kdpstatep->ebx = $kgm_statep->k_ebx
set $kdpstatep->ebp = $kgm_statep->k_ebp
set $kdpstatep->edi = $kgm_statep->k_edi
set $kdpstatep->esi = $kgm_statep->k_esi
- set $kdpstatep->eip = $kgm_statep->k_eip
+ set $kdpstatep->eip = $kgm_statep->k_eip
flushregs
flushstack
set $pc = $kgm_statep->k_eip
update
end
- end
+ if ($kgm_mtype == $kgm_mtype_x86_64)
+ set $kdpstatep = (struct x86_saved_state64 *) kdp.saved_state
+ if ($kdp_act_counter == 0)
+ set $kdpstate = *($kdpstatep)
+ end
+ set $kdp_act_counter = $kdp_act_counter + 1
+
+ set $kgm_statep = (struct x86_kernel_state *) \
+ ($newact->kernel_stack + kernel_stack_size \
+ - sizeof(struct x86_kernel_state))
+ set $kdpstatep->rbx = $kgm_statep->k_rbx
+ set $kdpstatep->rbp = $kgm_statep->k_rbp
+ set $kdpstatep->r12 = $kgm_statep->k_r12
+ set $kdpstatep->r13 = $kgm_statep->k_r13
+ set $kdpstatep->r14 = $kgm_statep->k_r14
+ set $kdpstatep->r15 = $kgm_statep->k_r15
+ set $kdpstatep->isf.rsp = $kgm_statep->k_rsp
+ flushregs
+ flushstack
+ set $pc = $kgm_statep->k_rip
+ update
+ end
+ if ($kgm_mtype == $kgm_mtype_arm)
+ set $r0_save = $r0
+ set $r1_save = $r1
+ set $r2_save = $r2
+ set $r3_save = $r3
+ set $r4_save = $r4
+ set $r5_save = $r5
+ set $r6_save = $r6
+ set $r7_save = $r7
+ set $r8_save = $r8
+ set $r9_save = $r9
+ set $r10_save = $r10
+ set $r11_save = $r11
+ set $r12_save = $r12
+ set $sp_save = $sp
+ set $lr_save = $lr
+ set $pc_save = $pc
+ set $pc_ctx = load_reg+8
+ set $kgm_statep = (struct arm_saved_state *)((struct thread*)$arg0)->machine.kstackptr
+ set $r0 = $kgm_statep->r[0]
+ set $r1 = $kgm_statep->r[1]
+ set $r2 = $kgm_statep->r[2]
+ set $r3 = $kgm_statep->r[3]
+ set $r4 = $kgm_statep->r[4]
+ set $r5 = $kgm_statep->r[5]
+ set $r6 = $kgm_statep->r[6]
+ set $r8 = $kgm_statep->r[8]
+ set $r9 = $kgm_statep->r[9]
+ set $r10 = $kgm_statep->r[10]
+ set $r11 = $kgm_statep->r[11]
+ set $r12 = $kgm_statep->r[12]
+ set $sp = $kgm_statep->sp
+ set $lr = $kgm_statep->lr
+ set $pc = $pc_ctx
+ set $r7 = $kgm_statep->r[7]
+ flushregs
+ flushstack
+ end
+ end
+ showcontext_int
end
document switchtoact
@@ -1521,9 +2005,10 @@
end
define switchtoctx
- if ($kgm_mtype == 18)
+ select 0
+ if ($kgm_mtype == $kgm_mtype_ppc)
if ($kdp_act_counter == 0)
- set $kdpstate = (struct savearea *) kdp.saved_state
+ set $kdpstate = (struct savearea *) kdp.saved_state
end
set $kdp_act_counter = $kdp_act_counter + 1
set (struct savearea *) kdp.saved_state=(struct savearea *) $arg0
@@ -1532,6 +2017,46 @@
set $pc=((struct savearea *) $arg0)->save_srr0
update
else
+ if ($kgm_mtype == $kgm_mtype_arm)
+ set arm disassembler std
+ select-frame 0
+ set $r0_save = $r0
+ set $r1_save = $r1
+ set $r2_save = $r2
+ set $r3_save = $r3
+ set $r4_save = $r4
+ set $r5_save = $r5
+ set $r6_save = $r6
+ set $r7_save = $r7
+ set $r8_save = $r8
+ set $r9_save = $r9
+ set $r10_save = $r10
+ set $r11_save = $r11
+ set $r12_save = $r12
+ set $sp_save = $sp
+ set $lr_save = $lr
+ set $pc_save = $pc
+ set $kgm_statep = (struct arm_saved_state *)$arg0
+ set $r0 = $kgm_statep->r[0]
+ set $r1 = $kgm_statep->r[1]
+ set $r2 = $kgm_statep->r[2]
+ set $r3 = $kgm_statep->r[3]
+ set $r4 = $kgm_statep->r[4]
+ set $r5 = $kgm_statep->r[5]
+ set $r6 = $kgm_statep->r[6]
+ set $r8 = $kgm_statep->r[8]
+ set $r9 = $kgm_statep->r[9]
+ set $r10 = $kgm_statep->r[10]
+ set $r11 = $kgm_statep->r[11]
+ set $r12 = $kgm_statep->r[12]
+ set $sp = $kgm_statep->sp
+ set $lr = $kgm_statep->lr
+ set $r7 = $kgm_statep->r[7]
+ set $pc = $kgm_statep->pc
+ flushregs
+ flushstack
+ update
+ else
echo switchtoctx not implemented for this architecture.\n
end
end
@@ -1545,14 +2070,17 @@
end
define resetctx
- if ($kgm_mtype == 18)
+ select 0
+ if ($kdp_act_counter != 0)
+ if ($kgm_mtype == $kgm_mtype_ppc)
set (struct savearea *)kdp.saved_state=$kdpstate
flushregs
flushstack
set $pc=((struct savearea *) kdp.saved_state)->save_srr0
update
set $kdp_act_counter = 0
- else
+ end
+ if ($kgm_mtype == $kgm_mtype_i386)
set $kdpstatep = (struct x86_saved_state32 *) kdp.saved_state
set *($kdpstatep)=$kdpstate
flushregs
@@ -1560,6 +2088,51 @@
set $pc=$kdpstatep->eip
update
set $kdp_act_counter = 0
+ end
+ if ($kgm_mtype == $kgm_mtype_x86_64)
+ set $kdpstatep = (struct x86_saved_state64 *) kdp.saved_state
+ set *($kdpstatep)=$kdpstate
+ flushregs
+ flushstack
+ set $pc=$kdpstatep->isf.rip
+ update
+ set $kdp_act_counter = 0
+ end
+ if ($kgm_mtype == $kgm_mtype_arm)
+ set $r0