Loading...
--- xnu/xnu-792.13.8/kgmacros
+++ xnu/xnu-2050.22.13/kgmacros
@@ -1,4 +1,4 @@
-#
+
# Kernel gdb macros
#
# These gdb macros should be useful during kernel development in
@@ -9,6 +9,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 +25,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
@@ -34,8 +39,12 @@
| showallvm Display a summary listing of all the vm maps
| showallvme Display a summary listing of all the vm map entries
| showallipc Display a summary listing of all the ipc spaces
+| showipcsummary Display a summary listing of the ipc spaces of all tasks
| showallrights Display a summary listing of all the ipc rights
-| showallkmods Display a summary listing of all the kernel modules
+| showallkexts Display a summary listing of all loaded kexts (alias: showallkmods)
+| showallknownkexts Display a summary listing of all kexts, loaded or not
+| showallbusyports Display a listing of all ports with unread messages
+| showallprocessors Display a listing of all psets and processors
|
| 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 +53,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 +68,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,9 +82,18 @@
|
| 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
+| showproctree Show all the processes in a hierarchical tree form
+| allproc Print out all process in the system not in the zombie list
+| zombstacks Print out all stacks of tasks that are exiting
|
-| showkmod Display info about a kernel module
-| showkmodaddr Given an address, display the kernel module and offset
+| showinitchild Print out all processes in the system which are children of init process
+|
+| showkext Display info about a kext (alias: showkmod)
+| showkextaddr Given an address, display the kext and offset (alias: showkmodaddr)
|
| dumpcallqueue Dump out all the entries given a queue head
|
@@ -80,6 +108,9 @@
| switchtoctx Switch to different context
| showuserstack Display numeric backtrace of the user stack for an
| activation
+| showtaskuserstacks Display user stacks for a specified task
+| showuserregisters Display user registers for the specified thread
+| showtaskuserregisters Display user registers for the specified task
|
| switchtouserthread Switch to the user context of the specified thread
| resetstacks Return to the original kernel context
@@ -89,15 +120,196 @@
| 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
+| inm_showdbg Print the debug information of an IPv4 multicast address
+| ifma_showdbg Print the debug information of a link multicast address
+| ifpref_showdbg Print the debug information of an interface ref count
+|
+| ndpr_showdbg Print the debug information of a nd_prefix structure
+| nddr_showdbg Print the debug information of a nd_defrouter structure
+|
+| imo_showdbg Print the debug information of a ip_moptions structure
+| im6o_showdbg Print the debug information of a ip6_moptions structure
+|
+| inifa_trash Walk the list of trash in_ifaddr entries
+| in6ifa_trash Walk the list of trash in6_ifaddr entries
+| inm_trash Walk the list of trash in_multi entries
+| in6m_trash Walk the list of trash in6_multi entries
+| ifma_trash Walk the list of trash ifmultiaddr entries
+|
+| mbuf_walkpkt Walk the mbuf packet chain (m_nextpkt)
+| mbuf_walk Walk the mbuf chain (m_next)
+| mbuf_buf2slab Find the slab structure of the corresponding buffer
+| mbuf_buf2mca Find the mcache audit structure of the corresponding mbuf
+| mbuf_showmca Print the contents of an mbuf mcache audit structure
+| mbuf_showactive Print all active/in-use mbuf objects
+| mbuf_showinactive Print all freed/in-cache mbuf objects
+| mbuf_showall Print all mbuf objects
+| mbuf_slabs Print all slabs in the group
+| mbuf_slabstbl Print slabs table
+| mbuf_stat Print extended mbuf allocator statistics
+| mbuf_countchain Count the length of an mbuf chain
+| mbuf_topleak Print the top suspected mbuf leakers
+| mbuf_traceleak Print the leak information for a given leak address
+|
+| 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
+| showifnets show the list of attached and detached interfaces
+| showifaddrs show the list of addresses for the given ifp
+| showifmultiaddrs show the list of multicast addresses for the given ifp
+| showinmultiaddrs show the list of IPv4 multicast addresses records
+| showin6multiaddrs show the list of IPv6 multicast addresses records
+|
+| 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
+|
+| showpmworkqueue Display the IOPMWorkQueue object
+| 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
+|
+| 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
+|
+| showtopztrace Print the ztrace with the most outstanding allocated memory
+| showztrace Print a backtrace record given its index
+| showzalloc Print an allocation record + stacktrace at index
+| showztraceaddr Print a backtrace record given its address
+| showztracesabove Print all the backtrace records with a size bigger than X
+| showzstacktrace Symbolicate and print a stored OSBacktrace
+|
+| showztraces Finds all in-use traces in the ztraces table
+| showzallocs Finds all in-use allocations in the zallocs table
+| showzstats Shows the statistics gathered about the hash tables
+|
+| showzallocsfortrace Print all the allocations that refer to a trace
+| showztracehistogram Prints a histogram of the ztraces table
+| showzallochistogram Prints a histogram of the zallocs table
+|
+| pmap_walk Perform a page-table walk
+| pmap_vtop Translate a virtual address to physical address
+|
+| showuserdyldinfo Show dyld information and error messages
+| in the target task
+| showuserlibraries Show binary images known by dyld in the
+| target task
+| showallvmstats Prints a summary of vm statistics in a table format
+| memstats Displays memory statistics in a table format
+|
+| 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
+|
+| showallproviders Display summary listing of all dtrace_providers
+| showallmodctls Display summary listing of all dtrace modctls
+| showmodctl Display info about a dtrace modctl
+| showfbtprobe Display info about an fbt probe given an id (traverses fbt_probetab)
+| processortimers Display all processor timers, noting any inconsistencies
+|
+| maplocalcache Enable local caching in GDB for improved debug speeds
+| flushlocalcahe Disable local caching in GDB (deletes all memory regions)
+|
| 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 +317,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 +331,163 @@
| 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_readphys_force_kdp = 0
+set $kgm_readphys_force_physmap = 0
+
+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
+
+# Print a userspace pointer, using $kgm_tasp
+define showuserptr
+ set $kgm_userptr_task_64 = ( $kgm_taskp->taskFeatures[0] & 0x80000000)
+ if $kgm_userptr_task_64
+ printf "0x%016llx", $arg0
+ else
+ printf "0x%08x", $arg0
+ end
+end
define showkmodheader
- printf "kmod address size "
- printf "id refs version name\n"
+ printf "kmod_info "
+ 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 +495,10 @@
define showkmodaddr
showkmodaddrint $arg0
- printf "\n"
-end
-
+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 +506,16 @@
showkmodint $arg0
end
document showkmod
-| Routine to print info about a kernel module
-| The following is the syntax:
-| (gdb) showkmod <kmod>
+Syntax: (gdb) showkmod <kmod>
+| Routine to print info about a kext
+end
+
+define showkext
+ showkmod $arg0
+end
+document showkext
+Syntax: (gdb) showkext <kmod_info_address>
+| Routine to print info about a kext
end
define showallkmods
@@ -220,22 +527,181 @@
end
end
document showallkmods
-| Routine to print a summary listing of all the kernel modules
-| The following is the syntax:
-| (gdb) showallkmods
+Syntax: (gdb) showallkmods
+| Routine to print a summary listing of all loaded kexts
+end
+
+define showallkexts
+ showallkmods
+end
+document showallkexts
+Syntax: (gdb) showallkexts
+| Routine to print a summary listing of all loaded kexts
+end
+
+# See OSKextVersion.c for the C code this is based on
+#
+set $KGM_OSKEXT_VERS_MAJ_MULT = 100000000
+set $KGM_OSKEXT_VERS_MIN_MULT = 1000000
+set $KGM_OSKEXT_VERS_REV_MULT = 10000
+set $KGM_OSKEXT_VERS_STAGE_MULT = 1000
+
+define printoskextversion
+ set $vers_scratch = $arg0
+
+ if ($vers_scratch == -1)
+ printf "(invalid)"
+ else
+
+ set $vers_major = $vers_scratch / $KGM_OSKEXT_VERS_MAJ_MULT
+
+ set $vers_scratch = $vers_scratch - ($vers_major * $KGM_OSKEXT_VERS_MAJ_MULT)
+ set $vers_minor = $vers_scratch / $KGM_OSKEXT_VERS_MIN_MULT
+
+ set $vers_scratch = $vers_scratch - ( $vers_minor * $KGM_OSKEXT_VERS_MIN_MULT)
+ set $vers_revision = $vers_scratch / $KGM_OSKEXT_VERS_REV_MULT
+
+ set $vers_scratch = $vers_scratch - ( $vers_revision * $KGM_OSKEXT_VERS_REV_MULT)
+ set $vers_stage = $vers_scratch / $KGM_OSKEXT_VERS_STAGE_MULT
+
+ set $vers_scratch = $vers_scratch - ( $vers_stage * $KGM_OSKEXT_VERS_STAGE_MULT)
+ set $vers_stagelevel = $vers_scratch
+
+ printf "%d.%d", $vers_major, $vers_minor
+ if ($vers_revision > 0)
+ printf ".%d", $vers_revision
+ end
+
+ if ($vers_stage == 1)
+ printf "d"
+ end
+ if ($vers_stage == 3)
+ printf "a"
+ end
+ if ($vers_stage == 5)
+ printf "b"
+ end
+ if ($vers_stage == 7)
+ printf "fc"
+ end
+ if ($vers_stage == 1 || $vers_stage == 3 || $vers_stage == 5 || $vers_stage == 7)
+ printf "%d", $vers_stagelevel
+ end
+ end
+end
+
+define showallknownkexts
+ set $kext_count = sKextsByID->count
+ set $kext_index = 0
+ printf "%d kexts in sKextsByID:\n", $kext_count
+
+ printf "OSKext * "
+ showptrhdrpad
+ printf "load_addr "
+ showptrhdrpad
+
+ printf " id name (version)\n"
+
+ while $kext_index < $kext_count
+ set $kext_id = sKextsByID->dictionary[$kext_index].key->string
+ set $oskext = (OSKext *)sKextsByID->dictionary[$kext_index].value
+
+ showptr $oskext
+ printf " "
+
+ if ($oskext->flags.loaded)
+ showptr $oskext->kmod_info
+ printf " "
+ printf "%3d", $oskext->loadTag
+ else
+ showptrhdrpad
+ printf " -------- "
+ printf " "
+ printf " --"
+ end
+ printf " "
+
+ printf "%.64s (", $kext_id
+ printoskextversion (uint64_t)$oskext->