# See wiki page on gdb macros: http://vmweb.vmware.com/~mts/cgi-bin/view.cgi/VMkernel/GdbMacros define reboot maintenance packet R9 disconnect end document reboot reboot Ask the machine to reset itself end define genbt set $newRIP = ((uint64)$arg0) set $newRBP = ((uint64)$arg1) set $newRSP = ((uint64)$arg2) if (($newRSP == 0) || ($newRBP == 0) || ($newRIP ==0)) printf "No. RIP=%#x RBP=%#x or RSP=%#x is zero!\n", \ $newRIP, $newRBP, $newRSP else if (($newRBP - $newRSP) > (32*1024)) printf "No. RBP too far from RSP ...\n" printf " RIP=%#x RBP=%#x RSP=%#x\n", $newRIP, $newRBP, $newRSP else set $saveRIP = $rip set $saveRSP = $rsp set $saveRBP = $rbp set $rip = $newRIP set $rbp = $newRBP set $rsp = $newRSP bt set $rsp = $saveRSP set $rbp = $saveRBP set $rip = $saveRIP end end end document genbt genbt Print a backtrace generated from the given RIP, RBP, and RSP (Only works on live-debugging, not core files) end define btfromnmi set $exc_full_frame = (VMKFullExcFrame *) $arg0 set $my_rip = $exc_full_frame->frame.rip set $my_rsp = $exc_full_frame->frame.rsp set $my_rbp = $exc_full_frame->regs.rbp printf "$rip == %p, $rsp == %p, $rbp == %p\n", $my_rip, $my_rsp, $my_rbp genbt $my_rip $my_rbp $my_rsp end document btfromnmi btfromnmi Print a backtrace generated from the given exec frame (Only works on live-debugging, not core files) end define mem2chunk p (mchunkptr)((char*)($arg0) - (2 * sizeof(size_t))) end document mem2chunk mem2chunk
Convert a ptr to a malloc_chunk pointer (ptr - 8) end define chunk2mem p (void*)((char*)($arg0) + (2 * sizeof(size_t))) end document chunk2mem mem2chunk
Convert a mchunkptr to a void* (ptr + 8) end define memchunkfooter set $memc = (mchunkptr)((char*)($arg0) - (2 * sizeof(size_t))) set $msz = ($memc.size & ~0x01) printf "%p -> size = %d\n", $arg0, $msz set $footer = (uint32*)(((char*)$memc) + $msz + sizeof(size_t)) set $p_user = $footer[-2] if ($footer[-3] != 0x5a5a5a5a) printf "[Footer very corrupt!]\n" end if (($p_user < $memc) || ($p_user > ($memc + $msz))) printf "[footer corrupt!]\n" printf "footer[-3] = %#x; caller_pc = %#x; p_user = %p\n", $footer[-3], $footer[-1], $footer[-2] else printf "footer[-3] = %#x; caller_pc = %#x; p_user = %s\n", $footer[-3], $footer[-1], $footer[-2] end end document memchunkfooter memchunkfooter
Show memchunk footer stuff for arbitrary malloced ptr end define verifyConfigOptions set $i = 0 while ($i < (sizeof(configDesc) / sizeof(configDesc[0]))) if (configDesc[$i].defaultVal != configOption[$i]) printf " Option %-24s: %4d != %4d (default)\n", configDesc[$i].name, configOption[$i], configDesc[$i].defaultVal end set $i = $i + 1 end end document verifyConfigOptions verifyConfig Checks all current vmkernel config option setting against their default values. Prints inequalities as "vmkernel option OptionName: currentVal != defaultVal (default)". end #eof