| 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
| 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"
|
| 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
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_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
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)
+ if ($kgm_wc_wqe->wqe_type != &_wait_queue_link) && ($kgm_wc_wqe->wqe_type != &_wait_queue_link_noalloc)
set $kgm_wc_count = $kgm_wc_count + 1
end
set $kgm_wc_wqe = (WaitQueueElement *)$kgm_wc_wqe->wqe_links.next
end
define showwaitqmembercount
- set $kgm_mc_waitqsetp = (WaitQueueSet*)$arg0
+ set $kgm_mc_waitqsetp = (struct wait_queue_set *)$arg0
set $kgm_mc_setlinksp = &($kgm_mc_waitqsetp->wqs_setlinks)
set $kgm_mc_wql = (WaitQueueLink *)$kgm_mc_setlinksp->next
set $kgm_mc_count = 0
end
define showwaitqmembers
- set $kgm_ms_waitqsetp = (WaitQueueSet*)$arg0
+ set $kgm_ms_waitqsetp = (struct wait_queue_set *)$arg0
set $kgm_ms_setlinksp = &($kgm_ms_waitqsetp->wqs_setlinks)
set $kgm_ms_wql = (WaitQueueLink *)$kgm_ms_setlinksp->next
set $kgm_ms_found = 0
end
define showwaitqheader
- printf "wait_queue ref_count interlock "
+ printf "wait_queue prepostq interlock "
printf "pol type member_cnt waiter_cnt\n"
end
define showwaitqint
- set $kgm_waitqp = (WaitQueue*)$arg0
+ set $kgm_waitqp = (WaitQueue *)$arg0
printf "0x%08x ", $kgm_waitqp
if ($kgm_waitqp->wq_type == 0xf1d1)
- printf "0x%08x ", ((WaitQueueSet*)$kgm_waitqp)->wqs_refcount
+ printf "0x%08x ", &((struct wait_queue_set *)$kgm_waitqp)->wqs_preposts
else
printf "0x00000000 "
end
end
+define showmapwiredp
+ set $kgm_mapp = (vm_map_t)$arg0
+ set $kgm_map = *$kgm_mapp
+ set $kgm_head_vmep = &($kgm_mapp->hdr.links)
+ set $kgm_vmep = $kgm_map.hdr.links.next
+ set $kgm_objp_prev = (struct vm_object *)0
+ if $arg1 == 0
+ set $kgm_saw_kernel_obj = 0
+ set $kgm_wired_count = 0
+ set $kgm_objp_print_space = 1
+ else
+ set $kgm_objp_print_space = 0
+ end
+ while (($kgm_vmep != 0) && ($kgm_vmep != $kgm_head_vmep))
+ set $kgm_vme = *$kgm_vmep
+ set $kgm_objp = $kgm_vme.object.vm_object
+ if $kgm_vme.is_sub_map
+ if $arg1 == 0
+ set $kgm_mapp_orig = $kgm_mapp
+ set $kgm_vmep_orig = $kgm_vmep
+ set $kgm_vme_orig = $kgm_vme
+ set $kgm_head_vmep_orig = $kgm_head_vmep
+ printf "\n****"
+ showptr $kgm_objp
+ showmapwiredp $kgm_objp 1
+ set $kgm_vme = $kgm_vme_orig
+ set $kgm_vmep = $kgm_vmep_orig
+ set $kgm_mapp = $kgm_mapp_orig
+ set $kgm_head_vmep = $kgm_head_vmep_orig
+ set $kgm_objp = (struct vm_object *)0
+ else
+ printf "\n????"
+ showptr $kgm_mapp
+ printf " "
+ showptr $kgm_vmep
+ set $kgm_objp = (struct vm_object *)0
+ printf "\n"
+ end
+ end
+ if ($kgm_objp == $kgm_objp_prev)
+ set $kgm_objp = (struct vm_object *)0
+ end
+ if $kgm_objp == kernel_object
+ if $kgm_saw_kernel_obj
+ set $kgm_objp = (struct vm_object *)0
+ end
+ set $kgm_saw_kernel_obj = 1
+ end
+ if $kgm_objp && $kgm_objp->wired_page_count
+ if $kgm_objp_print_space == 1
+ printf " "
+ showptr $kgm_mapp
+ end
+ set $kgm_objp_print_space = 1
+ printf " "
+ showptr $kgm_vmep
+ printf " 0x%016llx ", $kgm_vme.links.start
+ printf "%5d", $kgm_vme.alias
+ printf "%6d ",($kgm_vme.links.end - $kgm_vme.links.start) >> 12
+ showptr $kgm_objp
+ printf "[%3d]", $kgm_objp->ref_count
+ printf "%7d\n", $kgm_objp->wired_page_count
+ set $kgm_wired_count = $kgm_wired_count + $kgm_objp->wired_page_count
+ set $kgm_objp_prev = $kgm_objp
+ end
+ set $kgm_vmep = $kgm_vme.links.next
+ end
+ if $arg1 == 0
+ printf "total wired count = %d\n", $kgm_wired_count
+ end
+end
+
+define showmapwired
+ printf " map "
+ showptrhdrpad
+ printf " entry "
+ showptrhdrpad
+ printf " start alias #page object "
+ showptrhdrpad
+ printf " wired\n"
+ showmapwiredp $arg0 0
+end
+document showmapwired
+Syntax: (gdb) showmapwired <vm_map>
+| Routine to print out a summary listing of all the entries with wired pages in a vm_map
+end
+
define showmapvme
showmapheader
showvmint $arg0 1
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 && ipc_portbt != 0
+ if $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
end
set $kgm_iindex = $kgm_iindex + 1
set $kgm_iep = &($kgm_is.is_table[$kgm_iindex])
define showipc
set $kgm_isp = (ipc_space_t)$arg0
showipcheader
- showipcint $kgm_isp 0
+ showipcint $kgm_isp 0 0
end
document showipc
Syntax: (gdb) showipc <ipc_space>
define showrights
set $kgm_isp = (ipc_space_t)$arg0
showipcheader
- showipcint $kgm_isp 1
+ showipcint $kgm_isp 1 0
end
document showrights
Syntax: (gdb) showrights <ipc_space>
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>
showtaskheader
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
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 = &tasks
set $kgm_cur_taskp = (struct task *)($kgm_head_taskp->next)
showtaskheader
showipcheader
showtaskint $kgm_cur_taskp
- showipcint $kgm_cur_taskp->itk_space 0
+ showipcint $kgm_cur_taskp->itk_space 0 0
set $kgm_cur_taskp = (struct task *)($kgm_cur_taskp->tasks.next)
end
end
showtaskheader
showipcheader
showtaskint $kgm_cur_taskp
- showipcint $kgm_cur_taskp->itk_space 1
+ showipcint $kgm_cur_taskp->itk_space 1 0
set $kgm_cur_taskp = (struct task *)($kgm_cur_taskp->tasks.next)
end
end
if ($kgm_kotype == 31)
printf "UPL"
end
+ if ($kgm_kotype == 34)
+ printf "FD"
+ end
printf ")\n"
end
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 "Set "
printf "%5d ", $kgm_psetp->ips_object.io_references
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_setlinksp = &($kgm_psetp->ips_messages.data.pset.set_queue.wqs_setlinks)
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))
+ set $kgm_portp = (struct ipc_port *)((uintptr_t)$kgm_wql->wql_element.wqe_queue - $kgm_portoff)
if !$kgm_found
set $kgm_destspacep = (struct ipc_space *)0
showportdestproc $kgm_portp
define showmqueue
set $kgm_mqueue = *(struct ipc_mqueue *)$arg0
+ set $kgm_psetoff = (uintptr_t)&(((struct ipc_pset *)0)->ips_messages)
+ set $kgm_portoff = (uintptr_t)&(((struct ipc_port *)0)->ip_messages)
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))
+ set $kgm_psetp = (struct ipc_pset *)(((uintptr_t)$arg0) - $kgm_psetoff)
showpsetheader
- showpsetint $kgm_pset 1
+ showpsetint $kgm_psetp 1
end
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))
+ set $kgm_portp = (struct ipc_port *)(((uintptr_t)$arg0) - $kgm_portoff)
showportheader
- showportint $kgm_port 1
+ showportint $kgm_portp 1
end
end
if ($kgm_zone->expandable)
printf "X"
end
+ if ($kgm_zone->noencrypt)
+ printf "$"
+ end
printf "\n"
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_state *) \
($newact->kernel_stack + kernel_stack_size \
- sizeof(struct x86_kernel_state))
- set $kdpstatep->ebx = $kgm_statep->k_ebx
+ 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
if ($kgm_mtype == $kgm_mtype_x86_64)
set $kdpstatep = (struct x86_saved_state64 *) 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_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
+ 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
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
end
define resume_on
- set noresume_on_disconnect = 0
+ set $resume = KDP_DUMPINFO_SETINFO | KDP_DUMPINFO_RESUME
+ dumpinfoint $resume
end
document resume_on
end
define resume_off
- set noresume_on_disconnect = 1
+ set $noresume = KDP_DUMPINFO_SETINFO | KDP_DUMPINFO_NORESUME
+ dumpinfoint $noresume
end
document resume_off
|macro in some cases.
end
-#Stopgap until gdb can generate the HOSTREBOOT packet
define kdp-reboot
-#Alternatively, set *(*(unsigned **) 0x2498) = 1 (or 0x5498 on PPC)
- set flag_kdp_trigger_reboot = 1
+# Alternatively, set *(*(unsigned **) 0x2498) = 1
+# (or 0x5498 on PPC, 0xffffff8000002928 on x86_64, 0xffff049c on arm)
+ manualhdrint $kgm_kdp_pkt_hostreboot
continue
end
document kdp-reboot
Syntax: kdp-reboot
-|Reboot the remote target machine; not guaranteed to succeed. Requires symbols
-|until gdb support for the HOSTREBOOT packet is implemented.
+|Reboot the remote target machine; not guaranteed to succeed.
+end
+
+define kdpversionint
+ # set up the manual KDP packet
+ set manual_pkt.input = 0
+ set manual_pkt.len = sizeof(kdp_version_req_t)
+ set $kgm_pkt = (kdp_version_req_t *)&manual_pkt.data
+ set $kgm_pkt->hdr.request = KDP_VERSION
+ set $kgm_pkt->hdr.len = sizeof(kdp_version_req_t)
+ set $kgm_pkt->hdr.is_reply = 0
+ set $kgm_pkt->hdr.seq = 0
+ set $kgm_pkt->hdr.key = 0
+ set manual_pkt.input = 1
+ # dummy to make sure manual packet is executed
+ set $kgm_dummy = &_mh_execute_header
+ set $kgm_pkt = (kdp_version_reply_t *)&manual_pkt.data
+ set $kgm_kdp_version = $kgm_pkt->version
+ set $kgm_kdp_feature = $kgm_pkt->feature
+end
+
+define kdp-version
+ kdpversionint
+ printf "KDP VERSION = %d, FEATURE = 0x%x\n", $kgm_kdp_version, $kgm_kdp_feature
+end
+
+document kdp-version
+Syntax: kdp-version
+|Get the KDP protocol version being used by the kernel.
+end
+
+define dumpinfoint
+ # set up the manual KDP packet
+ set manual_pkt.input = 0
+
+ set manual_pkt.len = sizeof(kdp_dumpinfo_req_t)
+ set $kgm_pkt = (kdp_dumpinfo_req_t *)manual_pkt.data
+ set $kgm_pkt->hdr.request = KDP_DUMPINFO
+ set $kgm_pkt->hdr.len = sizeof(kdp_dumpinfo_req_t)
+ set $kgm_pkt->hdr.is_reply = 0
+ set $kgm_pkt->hdr.seq = 0
+ set $kgm_pkt->hdr.key = 0
+ set $kgm_pkt->type = $arg0
+ set $kgm_pkt->name = ""
+ set $kgm_pkt->destip = ""
+ set $kgm_pkt->routerip = ""
+ set $kgm_pkt->port = 0
+
+ if $argc > 1
+ set $kgm_pkt->name = "$arg1"
+ end
+ if $argc > 2
+ set $kgm_pkt->destip = "$arg2"
+ end
+ if $argc > 3
+ set $kgm_pkt->routerip = "$arg3"
+ end
+ if $argc > 4
+ set $kgm_pkt->port = $arg4
+ end
+
+ set manual_pkt.input = 1
+ # dummy to make sure manual packet is executed
+ set $kgm_dummy = &_mh_execute_header
end
define sendcore
- set kdp_trigger_core_dump = 1
- set kdp_flag |= 0x40
- set panicd_ip_str = "$arg0"
- set panicd_specified = 1
- set disable_debug_output = 0
- set disableConsoleOutput = 0
- set logPanicDataToScreen = 1
- set reattach_wait = 1
- resume_off
+ if $argc > 1
+ dumpinfoint KDP_DUMPINFO_CORE $arg1 $arg0
+ else
+ dumpinfoint KDP_DUMPINFO_CORE \0 $arg0
+ end
end
document sendcore
-Syntax: sendcore <IP address>
+Syntax: sendcore <IP address> [filename]
|Configure the kernel to transmit a kernel coredump to a server (kdumpd)
|at the specified IP address. This is useful when the remote target has
|not been previously configured to transmit coredumps, and you wish to
|preserve kernel state for later examination. NOTE: You must issue a "continue"
|command after using this macro to trigger the kernel coredump. The kernel
|will resume waiting in the debugger after completion of the coredump. You
-|may disable coredumps by executing the "disablecore" macro.
+|may disable coredumps by executing the "disablecore" macro. You can
+|optionally specify the filename to be used for the generated core file.
+end
+
+define sendsyslog
+ if $argc > 1
+ dumpinfoint KDP_DUMPINFO_SYSTEMLOG $arg1 $arg0
+ else
+ dumpinfoint KDP_DUMPINFO_SYSTEMLOG \0 $arg0
+ end
+end
+
+document sendsyslog
+Syntax: sendsyslog <IP address> [filename]
+|Configure the kernel to transmit a kernel system log to a server (kdumpd)
+|at the specified IP address. NOTE: You must issue a "continue"
+|command after using this macro to trigger the kernel system log. The kernel
+|will resume waiting in the debugger after completion. You can optionally
+|specify the name to be used for the generated system log.
+end
+
+define sendpaniclog
+ if panicstr
+ if $argc > 1
+ dumpinfoint KDP_DUMPINFO_PANICLOG $arg1 $arg0
+ else
+ dumpinfoint KDP_DUMPINFO_PANICLOG \0 $arg0
+ end
+ else
+ printf "No panic log available.\n"
+ end
+end
+
+document sendpaniclog
+Syntax: sendpaniclog <IP address> [filename]
+|Configure the kernel to transmit a kernel paniclog to a server (kdumpd)
+|at the specified IP address. NOTE: You must issue a "continue"
+|command after using this macro to trigger the kernel panic log. The kernel
+|will resume waiting in the debugger after completion. You can optionally
+|specify the name to be used for the generated panic log.
+end
+
+define getdumpinfo
+ dumpinfoint KDP_DUMPINFO_GETINFO
+ set $kgm_dumpinfo = (kdp_dumpinfo_reply_t *) manual_pkt.data
+ if $kgm_dumpinfo->type & KDP_DUMPINFO_REBOOT
+ printf "System will reboot after kernel info gets dumped.\n"
+ else
+ printf "Sysem will not reboot after kernel info gets dumped.\n"
+ end
+ if $kgm_dumpinfo->type & KDP_DUMPINFO_NORESUME
+ printf "System will allow a re-attach after a KDP disconnect.\n"
+ else
+ printf "System will resume after a KDP disconnect.\n"
+ end
+ set $kgm_dumpinfo_type = $kgm_dumpinfo->type & KDP_DUMPINFO_MASK
+ if $kgm_dumpinfo_type == KDP_DUMPINFO_DISABLE
+ printf "Kernel not setup for remote dumps.\n"
+ else
+ printf "Remote dump type: "
+ if $kgm_dumpinfo_type == KDP_DUMPINFO_CORE
+ printf "Core file\n"
+ end
+ if $kgm_dumpinfo_type == KDP_DUMPINFO_PANICLOG
+ printf "Panic log\n"
+ end
+ if $kgm_dumpinfo_type == KDP_DUMPINFO_SYSTEMLOG
+ printf "System log\n"
+ end
+
+ printf "Name: "
+ if $kgm_dumpinfo->name[0] == '\0'
+ printf "(autogenerated)\n"
+ else
+ printf "%s\n", $kgm_dumpinfo->name
+ end
+
+ printf "Network Info: %s[%d] ", $kgm_dumpinfo->destip, $kgm_dumpinfo->port
+ if $kgm_dumpinfo->routerip[0] == '\0'
+ printf "\n"
+ else
+ printf "Router: %s\n", $kgm_dumpinfo->routerip
+ end
+ end
+end
+
+document getdumpinfo
+Syntax: getdumpinfo
+|Retrieve the current remote dump settings.
+end
+
+define setdumpinfo
+ dumpinfoint KDP_DUMPINFO_SETINFO $arg0 $arg1 $arg2 $arg3
+end
+
+document setdumpinfo
+Syntax: setdumpinfo <filename> <ip> <router> <port>
+|Configure the current remote dump settings. Specify \0 if you
+|want to use the defaults (filename) or previously configured
+|settings (ip/router). Specify 0 for the port if you wish to
+|use the previously configured/default setting for that.
end
define disablecore
- set kdp_trigger_core_dump = 0
- set kdp_flag |= 0x40
- set kdp_flag &= ~0x10
- set panicd_specified = 0
+ dumpinfoint KDP_DUMPINFO_DISABLE
end
document disablecore
end
define findregistryentryint
- set $kgm_namekey = (OSSymbol *) $kgm_reg_plane->nameKey
- set $kgm_childkey = (OSSymbol *) $kgm_reg_plane->keys[1]
- if $kgm_findregistry_verbose
- printf "Searching"
+ if !$kgm_reg_plane
+ set $kgm_reg_plane = (IORegistryPlane *) gIOServicePlane
+ end
+
+ if !$kgm_reg_plane
+ printf "Please load kgmacros after KDP attaching to the target.\n"
+ else
+ set $kgm_namekey = (OSSymbol *) $kgm_reg_plane->nameKey
+ set $kgm_childkey = (OSSymbol *) $kgm_reg_plane->keys[1]
+ if $kgm_findregistry_verbose
+ printf "Searching"
+ end
+ findregistryentryrecurse _ $arg0 0 0
end
- findregistryentryrecurse _ $arg0 0 0
end
define _findregistryentry
end
define showregistryentryint
- set $kgm_namekey = (OSSymbol *) $kgm_reg_plane->nameKey
- set $kgm_childkey = (OSSymbol *) $kgm_reg_plane->keys[1]
+ if !$kgm_reg_plane
+ set $kgm_reg_plane = (IORegistryPlane *) gIOServicePlane
+ end
- showregistryentryrecurse _ $arg0 0 0
+ if !$kgm_reg_plane
+ printf "Please load kgmacros after KDP attaching to the target.\n"
+ else
+ set $kgm_namekey = (OSSymbol *) $kgm_reg_plane->nameKey
+ set $kgm_childkey = (OSSymbol *) $kgm_reg_plane->keys[1]
+ showregistryentryrecurse _ $arg0 0 0
+ end
end
define showregistry
end
define showregistryentryintpmstate
- set $kgm_namekey = (OSSymbol *) $kgm_reg_plane->nameKey
- set $kgm_childkey = (OSSymbol *) $kgm_reg_plane->keys[1]
- showregistryentryrecursepmstate _ $arg0 0 0
+ if !$kgm_reg_plane
+ set $kgm_reg_plane = (IORegistryPlane *) gIOServicePlane
+ end
+
+ if !$kgm_reg_plane
+ printf "Please load kgmacros after KDP attaching to the target.\n"
+ else
+ set $kgm_namekey = (OSSymbol *) $kgm_reg_plane->nameKey
+ set $kgm_childkey = (OSSymbol *) $kgm_reg_plane->keys[1]
+ showregistryentryrecursepmstate _ $arg0 0 0
+ end
end
define showregistrypmstate
| best-effort guess to find any workloops that are actually not blocked in a continuation. For a
| complete list, it is best to compare the output of this macro against the output of 'showallstacks'.
end
+
define showthreadfortid
set $kgm_id_found = 0
|Routine to print information about all receive rights on the system that
|have enqueued messages.
end
+
+define kdp-connect
+ if $argc > 0
+ kdp-reattach $arg0
+ else
+ printf "Attempting to attach to localhost...\n"
+ kdp-reattach localhost
+ end
+end
+
+document kdp-connect
+Syntax: (gdb) kdpconnect <address-of-remote-host>
+| Attach to the machine with given hostname or IP address, or 'localhost' if blank
+end