22 #define MAX_POSBUF 128 24 #define VM_CFP_CNT(th, cfp) \ 25 ((rb_control_frame_t *)((th)->ec.vm_stack + (th)->ec.vm_stack_size) - \ 26 (rb_control_frame_t *)(cfp)) 33 char ep_in_heap =
' ';
37 const char *magic, *iseq_name =
"-", *selfstr =
"-", *biseq_name =
"-";
43 ep = (ptrdiff_t)cfp->
ep;
47 switch (VM_FRAME_TYPE(cfp)) {
89 #define RUBY_VM_IFUNC_P(ptr) imemo_type_p((VALUE)ptr, imemo_ifunc) 91 iseq_name =
"<ifunc>";
117 fprintf(stderr,
"p:---- ");
124 fprintf(stderr,
"%-6s", magic);
126 fprintf(stderr,
" %s", posbuf);
128 if (VM_FRAME_FINISHED_P(cfp)) {
129 fprintf(stderr,
" [FINISH]");
132 fprintf(stderr,
" \t");
133 fprintf(stderr,
"iseq: %-24s ", iseq_name);
134 fprintf(stderr,
"self: %-24s ", selfstr);
135 fprintf(stderr,
"%-1s ", biseq_name);
137 fprintf(stderr,
"\n");
147 fprintf(stderr,
"-- stack frame ------------\n");
149 fprintf(stderr,
"%04ld (%p): %08"PRIxVALUE, (
long)(p - st), p, *p);
157 fprintf(stderr,
" <- ep");
159 fprintf(stderr,
"\n");
163 fprintf(stderr,
"-- Control frame information " 164 "-----------------------------------------------\n");
166 control_frame_dump(th, cfp);
169 fprintf(stderr,
"\n");
183 fprintf(stderr,
"-- env --------------------\n");
186 fprintf(stderr,
"--\n");
187 for (i = 0; i < env->
env_size; i++) {
188 fprintf(stderr,
"%04d: %08"PRIxVALUE" (%p)", i, env->
env[i], (
void *)&env->
env[i]);
189 if (&env->
env[i] == ep) fprintf(stderr,
" <- ep");
190 fprintf(stderr,
"\n");
195 fprintf(stderr,
"---------------------------\n");
206 fprintf(stderr,
"-- proc -------------------\n");
207 fprintf(stderr,
"self: %s\n", selfstr);
208 env = VM_ENV_ENVVAL_PTR(vm_block_ep(&proc->
block));
237 int i,
argc = 0, local_table_size = 0;
242 if (VM_FRAME_RUBYFRAME_P(cfp)) {
259 const VALUE *ptr = ep - local_table_size;
261 control_frame_dump(th, cfp);
263 for (i = 0; i <
argc; i++) {
268 for (; i < local_table_size - 1; i++) {
274 ptr = vm_base_ptr(cfp);
275 for (; ptr < sp; ptr++, i++) {
276 switch (
TYPE(*ptr)) {
291 else if (VM_FRAME_FINISHED_P(cfp)) {
292 if ((th)->ec.vm_stack + (th)->ec.vm_stack_size > (
VALUE *)(cfp + 1)) {
293 vm_stack_dump_each(th, cfp + 1);
300 rb_bug(
"unsupport frame type: %08lx", VM_FRAME_TYPE(cfp));
313 if (VM_FRAME_RUBYFRAME_P(cfp)) {
345 if(0)printf(
"[%03ld] ", (
long)(cfp->
sp - th->
ec.
vm_stack));
356 fprintf(stderr,
" (1)");
373 fprintf(stderr,
" (2)");
380 vm_stack_dump_each(th, th->
ec.
cfp);
382 #if OPT_STACK_CACHING 392 (
"--------------------------------------------------------------\n");
402 fprintf(stderr,
"Thread state dump:\n");
403 fprintf(stderr,
"pc : %p, sp : %p\n", (
void *)cfp->
pc, (
void *)cfp->
sp);
404 fprintf(stderr,
"cfp: %p, ep : %p\n", (
void *)cfp, (
void *)cfp->
ep);
409 #if defined(HAVE_BACKTRACE) 410 # ifdef HAVE_LIBUNWIND 412 # define backtrace unw_backtrace 413 # elif defined(__APPLE__) && defined(__x86_64__) && defined(HAVE_LIBUNWIND_H) 414 # define UNW_LOCAL_ONLY 415 # include <libunwind.h> 416 # include <sys/mman.h> 419 backtrace(
void **trace,
int size)
421 unw_cursor_t cursor; unw_context_t uc;
426 unw_init_local(&cursor, &uc);
427 while (unw_step(&cursor) > 0) {
428 unw_get_reg(&cursor, UNW_REG_IP, &ip);
429 trace[n++] = (
void *)ip;
432 unw_get_proc_name(&cursor, buf, 256, &ip);
433 if (strncmp(
"_sigtramp", buf,
sizeof(
"_sigtramp")) == 0) {
434 goto darwin_sigtramp;
449 unw_get_reg(&cursor, UNW_X86_64_RBX, &ip);
450 uctx = (ucontext_t *)ip;
451 unw_set_reg(&cursor, UNW_X86_64_RAX, uctx->uc_mcontext->__ss.__rax);
452 unw_set_reg(&cursor, UNW_X86_64_RBX, uctx->uc_mcontext->__ss.__rbx);
453 unw_set_reg(&cursor, UNW_X86_64_RCX, uctx->uc_mcontext->__ss.__rcx);
454 unw_set_reg(&cursor, UNW_X86_64_RDX, uctx->uc_mcontext->__ss.__rdx);
455 unw_set_reg(&cursor, UNW_X86_64_RDI, uctx->uc_mcontext->__ss.__rdi);
456 unw_set_reg(&cursor, UNW_X86_64_RSI, uctx->uc_mcontext->__ss.__rsi);
457 unw_set_reg(&cursor, UNW_X86_64_RBP, uctx->uc_mcontext->__ss.__rbp);
458 unw_set_reg(&cursor, UNW_X86_64_RSP, 8+(uctx->uc_mcontext->__ss.__rsp));
459 unw_set_reg(&cursor, UNW_X86_64_R8, uctx->uc_mcontext->__ss.__r8);
460 unw_set_reg(&cursor, UNW_X86_64_R9, uctx->uc_mcontext->__ss.__r9);
461 unw_set_reg(&cursor, UNW_X86_64_R10, uctx->uc_mcontext->__ss.__r10);
462 unw_set_reg(&cursor, UNW_X86_64_R11, uctx->uc_mcontext->__ss.__r11);
463 unw_set_reg(&cursor, UNW_X86_64_R12, uctx->uc_mcontext->__ss.__r12);
464 unw_set_reg(&cursor, UNW_X86_64_R13, uctx->uc_mcontext->__ss.__r13);
465 unw_set_reg(&cursor, UNW_X86_64_R14, uctx->uc_mcontext->__ss.__r14);
466 unw_set_reg(&cursor, UNW_X86_64_R15, uctx->uc_mcontext->__ss.__r15);
467 ip = uctx->uc_mcontext->__ss.__rip;
495 r = mincore((
const void *)ip, 1, vec);
496 if (r || vec[0] <= 0 ||
memcmp((
const char *)ip-2,
"\x0f\x05", 2) == 0) {
499 trace[n++] = (
void *)ip;
500 ip = *(unw_word_t*)uctx->uc_mcontext->__ss.__rsp;
502 trace[n++] = (
void *)ip;
503 unw_set_reg(&cursor, UNW_REG_IP, ip);
505 while (unw_step(&cursor) > 0) {
506 unw_get_reg(&cursor, UNW_REG_IP, &ip);
507 trace[n++] = (
void *)ip;
511 # elif defined(BROKEN_BACKTRACE) 512 # undef HAVE_BACKTRACE 513 # define HAVE_BACKTRACE 0 516 # define HAVE_BACKTRACE 0 520 # include <execinfo.h> 521 #elif defined(_WIN32) 522 # include <imagehlp.h> 523 # ifndef SYMOPT_DEBUG 524 # define SYMOPT_DEBUG 0x80000000 526 # ifndef MAX_SYM_NAME 527 # define MAX_SYM_NAME 2000 535 DWORD ThCallbackStack;
536 DWORD ThCallbackBStore;
539 DWORD64 KiCallUserMode;
540 DWORD64 KeUserCallbackDispatcher;
541 DWORD64 SystemRangeStart;
542 DWORD64 KiUserExceptionDispatcher;
549 ADDRESS64 AddrReturn;
552 ADDRESS64 AddrBStore;
553 void *FuncTableEntry;
584 typedef void *PREAD_PROCESS_MEMORY_ROUTINE64;
585 typedef void *PFUNCTION_TABLE_ACCESS_ROUTINE64;
586 typedef void *PGET_MODULE_BASE_ROUTINE64;
587 typedef void *PTRANSLATE_ADDRESS_ROUTINE64;
591 dump_thread(
void *arg)
594 BOOL (WINAPI *pSymInitialize)(HANDLE,
const char *, BOOL);
595 BOOL (WINAPI *pSymCleanup)(HANDLE);
596 BOOL (WINAPI *pStackWalk64)(
DWORD, HANDLE, HANDLE, STACKFRAME64 *,
void *, PREAD_PROCESS_MEMORY_ROUTINE64, PFUNCTION_TABLE_ACCESS_ROUTINE64, PGET_MODULE_BASE_ROUTINE64, PTRANSLATE_ADDRESS_ROUTINE64);
597 DWORD64 (WINAPI *pSymGetModuleBase64)(HANDLE, DWORD64);
598 BOOL (WINAPI *pSymFromAddr)(HANDLE, DWORD64, DWORD64 *, SYMBOL_INFO *);
599 BOOL (WINAPI *pSymGetLineFromAddr64)(HANDLE, DWORD64,
DWORD *, IMAGEHLP_LINE64 *);
600 HANDLE (WINAPI *pOpenThread)(
DWORD, BOOL,
DWORD);
601 DWORD tid = *(DWORD *)arg;
605 dbghelp = LoadLibrary(
"dbghelp.dll");
606 if (!dbghelp)
return;
607 pSymInitialize = (BOOL (WINAPI *)(HANDLE,
const char *, BOOL))GetProcAddress(dbghelp,
"SymInitialize");
608 pSymCleanup = (BOOL (WINAPI *)(HANDLE))GetProcAddress(dbghelp,
"SymCleanup");
609 pStackWalk64 = (BOOL (WINAPI *)(
DWORD, HANDLE, HANDLE, STACKFRAME64 *,
void *, PREAD_PROCESS_MEMORY_ROUTINE64, PFUNCTION_TABLE_ACCESS_ROUTINE64, PGET_MODULE_BASE_ROUTINE64, PTRANSLATE_ADDRESS_ROUTINE64))GetProcAddress(dbghelp,
"StackWalk64");
610 pSymGetModuleBase64 = (DWORD64 (WINAPI *)(HANDLE, DWORD64))GetProcAddress(dbghelp,
"SymGetModuleBase64");
611 pSymFromAddr = (BOOL (WINAPI *)(HANDLE, DWORD64, DWORD64 *, SYMBOL_INFO *))GetProcAddress(dbghelp,
"SymFromAddr");
612 pSymGetLineFromAddr64 = (BOOL (WINAPI *)(HANDLE, DWORD64, DWORD *, IMAGEHLP_LINE64 *))GetProcAddress(dbghelp,
"SymGetLineFromAddr64");
613 pOpenThread = (HANDLE (WINAPI *)(
DWORD, BOOL,
DWORD))GetProcAddress(GetModuleHandle(
"kernel32.dll"),
"OpenThread");
614 if (pSymInitialize && pSymCleanup && pStackWalk64 && pSymGetModuleBase64 &&
615 pSymFromAddr && pSymGetLineFromAddr64 && pOpenThread) {
616 SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG | SYMOPT_LOAD_LINES);
617 ph = GetCurrentProcess();
619 th = pOpenThread(THREAD_SUSPEND_RESUME|THREAD_GET_CONTEXT,
FALSE, tid);
621 if (SuspendThread(th) != (DWORD)-1) {
623 memset(&context, 0,
sizeof(context));
624 context.ContextFlags = CONTEXT_FULL;
625 if (GetThreadContext(th, &context)) {
626 char libpath[MAX_PATH];
627 char buf[
sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
628 SYMBOL_INFO *info = (SYMBOL_INFO *)
buf;
631 memset(&frame, 0,
sizeof(frame));
632 #if defined(_M_AMD64) || defined(__x86_64__) 633 mac = IMAGE_FILE_MACHINE_AMD64;
634 frame.AddrPC.Mode = AddrModeFlat;
635 frame.AddrPC.Offset = context.Rip;
636 frame.AddrFrame.Mode = AddrModeFlat;
637 frame.AddrFrame.Offset = context.Rbp;
638 frame.AddrStack.Mode = AddrModeFlat;
639 frame.AddrStack.Offset = context.Rsp;
640 #elif defined(_M_IA64) || defined(__ia64__) 641 mac = IMAGE_FILE_MACHINE_IA64;
642 frame.AddrPC.Mode = AddrModeFlat;
643 frame.AddrPC.Offset = context.StIIP;
644 frame.AddrBStore.Mode = AddrModeFlat;
645 frame.AddrBStore.Offset = context.RsBSP;
646 frame.AddrStack.Mode = AddrModeFlat;
647 frame.AddrStack.Offset = context.IntSp;
649 mac = IMAGE_FILE_MACHINE_I386;
650 frame.AddrPC.Mode = AddrModeFlat;
651 frame.AddrPC.Offset = context.Eip;
652 frame.AddrFrame.Mode = AddrModeFlat;
653 frame.AddrFrame.Offset = context.Ebp;
654 frame.AddrStack.Mode = AddrModeFlat;
655 frame.AddrStack.Offset = context.Esp;
658 while (pStackWalk64(mac, ph, th, &frame, &context,
NULL,
660 DWORD64 addr = frame.AddrPC.Offset;
661 IMAGEHLP_LINE64 line;
662 DWORD64 displacement;
665 if (addr == frame.AddrReturn.Offset || addr == 0 ||
666 frame.AddrReturn.Offset == 0)
669 memset(
buf, 0,
sizeof(
buf));
670 info->SizeOfStruct =
sizeof(SYMBOL_INFO);
671 info->MaxNameLen = MAX_SYM_NAME;
672 if (pSymFromAddr(ph, addr, &displacement, info)) {
673 if (GetModuleFileName((HANDLE)(
uintptr_t)pSymGetModuleBase64(ph, addr), libpath,
sizeof(libpath)))
674 fprintf(stderr,
"%s", libpath);
675 fprintf(stderr,
"(%s+0x%I64x)",
676 info->Name, displacement);
678 fprintf(stderr,
" [0x%p]", (
void *)(
VALUE)addr);
679 memset(&line, 0,
sizeof(line));
680 line.SizeOfStruct =
sizeof(line);
681 if (pSymGetLineFromAddr64(ph, addr, &tmp, &line))
682 fprintf(stderr,
" %s:%lu", line.FileName, line.LineNumber);
683 fprintf(stderr,
"\n");
693 FreeLibrary(dbghelp);
701 #define MAX_NATIVE_TRACE 1024 702 static void *trace[MAX_NATIVE_TRACE];
703 int n = (int)backtrace(trace, MAX_NATIVE_TRACE);
704 #if defined(USE_ELF) && defined(HAVE_DLADDR) && !defined(__sparc) 705 rb_dump_backtrace_with_lines(n, trace);
707 char **syms = backtrace_symbols(trace, n);
710 for (i=0; i<n; i++) {
711 fprintf(stderr,
"%s\n", syms[i]);
716 #elif defined(_WIN32) 717 DWORD tid = GetCurrentThreadId();
718 HANDLE th = (HANDLE)_beginthread(dump_thread, 0, &tid);
719 if (th != (HANDLE)-1)
720 WaitForSingleObject(th, INFINITE);
724 #ifdef HAVE_LIBPROCSTAT 725 #include <sys/user.h> 726 #include <sys/sysctl.h> 727 #include <sys/param.h> 728 #include <libprocstat.h> 729 # ifndef KVME_TYPE_MGTDEVICE 730 # define KVME_TYPE_MGTDEVICE 8 733 procstat_vm(
struct procstat *procstat,
struct kinfo_proc *kipp)
735 struct kinfo_vmentry *freep, *kve;
742 ptrwidth = 2*
sizeof(
void *) + 2;
744 fprintf(stderr,
"%*s %*s %3s %4s %4s %3s %3s %4s %-2s %-s\n",
745 ptrwidth,
"START", ptrwidth,
"END",
"PRT",
"RES",
746 "PRES",
"REF",
"SHD",
"FL",
"TP",
"PATH");
748 #ifdef HAVE_PROCSTAT_GETVMMAP 749 freep = procstat_getvmmap(procstat, kipp, &cnt);
751 freep = kinfo_getvmmap(kipp->ki_pid, &cnt);
755 for (i = 0; i <
cnt; i++) {
757 fprintf(stderr,
"%#*jx ", ptrwidth, (uintmax_t)kve->kve_start);
758 fprintf(stderr,
"%#*jx ", ptrwidth, (uintmax_t)kve->kve_end);
759 fprintf(stderr,
"%s", kve->kve_protection & KVME_PROT_READ ?
"r" :
"-");
760 fprintf(stderr,
"%s", kve->kve_protection & KVME_PROT_WRITE ?
"w" :
"-");
761 fprintf(stderr,
"%s ", kve->kve_protection & KVME_PROT_EXEC ?
"x" :
"-");
762 fprintf(stderr,
"%4d ", kve->kve_resident);
763 fprintf(stderr,
"%4d ", kve->kve_private_resident);
764 fprintf(stderr,
"%3d ", kve->kve_ref_count);
765 fprintf(stderr,
"%3d ", kve->kve_shadow_count);
766 fprintf(stderr,
"%-1s", kve->kve_flags & KVME_FLAG_COW ?
"C" :
"-");
767 fprintf(stderr,
"%-1s", kve->kve_flags & KVME_FLAG_NEEDS_COPY ?
"N" :
769 fprintf(stderr,
"%-1s", kve->kve_flags & KVME_FLAG_SUPER ?
"S" :
"-");
770 fprintf(stderr,
"%-1s ", kve->kve_flags & KVME_FLAG_GROWS_UP ?
"U" :
771 kve->kve_flags & KVME_FLAG_GROWS_DOWN ?
"D" :
"-");
772 switch (kve->kve_type) {
776 case KVME_TYPE_DEFAULT:
779 case KVME_TYPE_VNODE:
785 case KVME_TYPE_DEVICE:
797 case KVME_TYPE_MGTDEVICE:
800 case KVME_TYPE_UNKNOWN:
805 fprintf(stderr,
"%-2s ", str);
806 fprintf(stderr,
"%-s\n", kve->kve_path);
812 #if defined __linux__ 813 # if defined __x86_64__ || defined __i386__ 814 # define HAVE_PRINT_MACHINE_REGISTERS 1 816 #elif defined __APPLE__ 817 # if defined __x86_64__ || defined __i386__ 818 # define HAVE_PRINT_MACHINE_REGISTERS 1 822 #ifdef HAVE_PRINT_MACHINE_REGISTERS 824 print_machine_register(
size_t reg,
const char *reg_name,
int col_count,
int max_col)
830 ret =
snprintf(buf,
sizeof(buf),
" %3.3s: 0x%016zx", reg_name, reg);
832 ret =
snprintf(buf,
sizeof(buf),
" %3.3s: 0x%08zx", reg_name, reg);
834 if (col_count + ret > max_col) {
843 # define dump_machine_register(reg) (col_count = print_machine_register(mctx->gregs[REG_##reg], #reg, col_count, 80)) 844 # elif defined __APPLE__ 845 # define dump_machine_register(reg) (col_count = print_machine_register(mctx->__ss.__##reg, #reg, col_count, 80)) 854 fprintf(stderr,
"-- Machine register context " 855 "------------------------------------------------\n");
857 # if defined __linux__ 859 const mcontext_t *
const mctx = &ctx->uc_mcontext;
860 # if defined __x86_64__ 861 dump_machine_register(RIP);
862 dump_machine_register(RBP);
863 dump_machine_register(RSP);
864 dump_machine_register(RAX);
865 dump_machine_register(RBX);
866 dump_machine_register(RCX);
867 dump_machine_register(RDX);
868 dump_machine_register(RDI);
869 dump_machine_register(RSI);
870 dump_machine_register(R8);
871 dump_machine_register(R9);
872 dump_machine_register(R10);
873 dump_machine_register(R11);
874 dump_machine_register(R12);
875 dump_machine_register(R13);
876 dump_machine_register(R14);
877 dump_machine_register(R15);
878 dump_machine_register(EFL);
879 # elif defined __i386__ 880 dump_machine_register(GS);
881 dump_machine_register(FS);
882 dump_machine_register(ES);
883 dump_machine_register(DS);
884 dump_machine_register(EDI);
885 dump_machine_register(ESI);
886 dump_machine_register(EBP);
887 dump_machine_register(ESP);
888 dump_machine_register(EBX);
889 dump_machine_register(EDX);
890 dump_machine_register(ECX);
891 dump_machine_register(EAX);
892 dump_machine_register(TRAPNO);
893 dump_machine_register(
ERR);
894 dump_machine_register(EIP);
895 dump_machine_register(CS);
896 dump_machine_register(EFL);
897 dump_machine_register(UESP);
898 dump_machine_register(SS);
901 # elif defined __APPLE__ 903 const mcontext_t mctx = ctx->uc_mcontext;
904 # if defined __x86_64__ 905 dump_machine_register(rax);
906 dump_machine_register(rbx);
907 dump_machine_register(rcx);
908 dump_machine_register(rdx);
909 dump_machine_register(rdi);
910 dump_machine_register(rsi);
911 dump_machine_register(rbp);
912 dump_machine_register(rsp);
913 dump_machine_register(r8);
914 dump_machine_register(r9);
915 dump_machine_register(r10);
916 dump_machine_register(r11);
917 dump_machine_register(r12);
918 dump_machine_register(r13);
919 dump_machine_register(r14);
920 dump_machine_register(r15);
921 dump_machine_register(rip);
922 dump_machine_register(rflags);
923 # elif defined __i386__ 924 dump_machine_register(eax);
925 dump_machine_register(ebx);
926 dump_machine_register(ecx);
927 dump_machine_register(edx);
928 dump_machine_register(edi);
929 dump_machine_register(esi);
930 dump_machine_register(ebp);
931 dump_machine_register(esp);
932 dump_machine_register(ss);
933 dump_machine_register(eflags);
934 dump_machine_register(eip);
935 dump_machine_register(cs);
936 dump_machine_register(ds);
937 dump_machine_register(es);
938 dump_machine_register(fs);
939 dump_machine_register(gs);
943 fprintf(stderr,
"\n\n");
946 # define rb_dump_machine_register(ctx) ((void)0) 953 # define PROC_MAPS_NAME "/proc/self/maps" 955 #ifdef PROC_MAPS_NAME 956 enum {other_runtime_info = 1};
958 enum {other_runtime_info = 0};
970 #if HAVE_BACKTRACE || defined(_WIN32) 971 fprintf(stderr,
"-- C level backtrace information " 972 "-------------------------------------------\n");
976 fprintf(stderr,
"\n");
979 if (other_runtime_info || vm) {
980 fprintf(stderr,
"-- Other runtime information " 981 "-----------------------------------------------\n\n");
987 const int max_name_length = 1024;
988 # define LIMITED_NAME_LENGTH(s) \ 989 (((len = RSTRING_LEN(s)) > max_name_length) ? max_name_length : (int)len) 992 fprintf(stderr,
"* Loaded script: %.*s\n",
994 fprintf(stderr,
"\n");
995 fprintf(stderr,
"* Loaded features:\n\n");
999 fprintf(stderr,
" %4d %.*s\n", i,
1007 fprintf(stderr,
" %4d %s:<unnamed>\n", i, type);
1010 fprintf(stderr,
" %4d %s:%.*s\n", i, type,
1016 fprintf(stderr,
" %4d #<%p:%p>\n", i,
1017 (
void *)
CLASS_OF(name), (
void *)name);
1020 fprintf(stderr,
" %4d #<%.*s:%p>\n", i,
1025 fprintf(stderr,
"\n");
1029 #ifdef PROC_MAPS_NAME 1031 FILE *fp = fopen(PROC_MAPS_NAME,
"r");
1033 fprintf(stderr,
"* Process memory map:\n\n");
1037 size_t rn = fread(buff, 1, 0x100, fp);
1038 if (fwrite(buff, 1, rn, stderr) != rn)
1043 fprintf(stderr,
"\n\n");
1047 #ifdef HAVE_LIBPROCSTAT 1048 # define MIB_KERN_PROC_PID_LEN 4 1049 int mib[MIB_KERN_PROC_PID_LEN];
1050 struct kinfo_proc kp;
1051 size_t len =
sizeof(
struct kinfo_proc);
1054 mib[2] = KERN_PROC_PID;
1056 if (sysctl(mib, MIB_KERN_PROC_PID_LEN, &kp, &len,
NULL, 0) == -1) {
1060 struct procstat *prstat = procstat_open_sysctl();
1061 fprintf(stderr,
"* Process memory map:\n\n");
1062 procstat_vm(prstat, &kp);
1063 procstat_close(prstat);
1064 fprintf(stderr,
"\n");
1070 #ifdef NON_SCALAR_THREAD_ID 1081 #ifdef NON_SCALAR_THREAD_ID 1083 ruby_fill_thread_id_string(th->
thread_id, buf);
1084 fprintf(stderr,
"th: %p, native_id: %s\n", th, buf);
1086 fprintf(stderr,
"th: %p, native_id: %p\n", th, (
void *)th->
thread_id);
void rb_vmdebug_env_dump_raw(const rb_env_t *env, const VALUE *ep)
void rb_bug(const char *fmt,...)
int rb_vm_get_sourceline(const rb_control_frame_t *cfp)
#define VM_CFP_CNT(th, cfp)
VALUE rb_vmdebug_thread_dump_state(VALUE self)
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
struct rb_method_definition_struct *const def
const rb_callable_method_entry_t * rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
void rb_vmdebug_stack_dump_th(VALUE thval)
struct rb_iseq_constant_body * body
VALUE rb_inspect(VALUE)
Convenient wrapper of Object::inspect.
void rb_vmdebug_stack_dump_all_threads(void)
const VALUE * iseq_encoded
VALUE rb_obj_class(VALUE)
call-seq: obj.class -> class
#define RB_TYPE_P(obj, type)
const rb_env_t * rb_vm_env_prev_env(const rb_env_t *env)
unsigned int local_table_size
rb_atomic_t cnt[RUBY_NSIG]
VALUE * rb_iseq_original_iseq(const rb_iseq_t *iseq)
void rb_vmdebug_debug_print_register(rb_thread_t *th)
void rb_vmdebug_debug_print_pre(rb_thread_t *th, rb_control_frame_t *cfp, const VALUE *_pc)
struct rb_iseq_constant_body::@135 param
parameter information
void rb_vmdebug_stack_dump_raw(rb_thread_t *th, rb_control_frame_t *cfp)
unsigned char buf[MIME_BUF_SIZE]
void rb_vm_bugreport(const void *ctx)
#define OPT_STACK_CACHING
const char * rb_id2name(ID)
int memcmp(const void *s1, const void *s2, size_t len)
enum rb_iseq_constant_body::iseq_type type
register unsigned int len
#define StringValueCStr(v)
void rb_print_backtrace(void)
#define RARRAY_AREF(a, i)
int rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos, const rb_iseq_t *iseq, VALUE child)
Disassemble a instruction Iseq -> Iseq inspect object.
void rb_vmdebug_thread_dump_regs(VALUE thval)
rb_nativethread_id_t thread_id
const struct rb_block block
#define rb_dump_machine_register(ctx)
VALUE rb_iseq_path(const rb_iseq_t *iseq)
#define RUBY_VM_IFUNC_P(ptr)
void rb_vmdebug_proc_dump_raw(rb_proc_t *proc)
rb_execution_context_t ec
char rb_thread_id_string_t[sizeof(rb_nativethread_id_t) *2+3]
void rb_vmdebug_stack_dump_raw_current(void)
struct list_head living_threads
#define GC_GUARDED_PTR_REF(p)
void rb_backtrace_print_as_bugreport(void)
VALUE rb_class_real(VALUE cl)
Looks up the nearest ancestor of cl, skipping singleton classes or module inclusions.
VALUE rb_search_class_path(VALUE)
void rb_vmdebug_debug_print_post(rb_thread_t *th, rb_control_frame_t *cfp)
#define LIMITED_NAME_LENGTH(s)
rb_iseq_location_t location