diff options
author | David CARLIER <[email protected]> | 2019-08-19 09:36:28 +0100 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2019-08-19 17:36:28 +0900 |
commit | 6dd9736c3a73ecd9b0dcf47348a81fb934eb88b3 (patch) | |
tree | 0f495573266b8c4c82c826223a4ef81fab20b9a2 | |
parent | 605d2ce9b98c4306505c8be05483e3d296db5f1e (diff) |
crash report on mac little update
displaying vm info as Linux and FreeBSD.
checking libproc as it is present only from 10.5 version.
https://github.com/ruby/ruby/pull/2384
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | vm_dump.c | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index ff785b9398..c201a3597e 100644 --- a/configure.ac +++ b/configure.ac @@ -2765,6 +2765,7 @@ AS_CASE(["$target_os"], ]) AS_CASE(["$target_cpu-$target_os"], [*-darwin*], [ + AC_CHECK_HEADERS([libproc.h]) AC_CHECK_HEADERS([execinfo.h]) AS_IF([test "x$ac_cv_header_execinfo_h" = xyes], [ AC_CHECK_LIB([execinfo], [backtrace]) @@ -16,6 +16,16 @@ #ifdef HAVE_UCONTEXT_H #include <ucontext.h> #endif +#ifdef __APPLE__ +#ifdef HAVE_LIBPROC_H +#include <libproc.h> +#endif +#include <mach/vm_map.h> +#include <mach/mach_init.h> +#ifdef __LP64__ +#define vm_region_recurse vm_region_recurse_64 +#endif +#endif /* see vm_insnhelper.h for the values */ #ifndef VMDEBUG @@ -984,6 +994,41 @@ rb_vm_bugreport(const void *ctx) fprintf(stderr, "\n"); } #endif /* __FreeBSD__ */ +#ifdef __APPLE__ + vm_address_t addr = 0; + vm_size_t size = 0; + struct vm_region_submap_info map; + mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT; + natural_t depth = 0; + + fprintf(stderr, "* Process memory map:\n\n"); + while (1) { + if (vm_region_recurse(mach_task_self(), &addr, &size, &depth, + (vm_region_recurse_info_t)&map, &count) != KERN_SUCCESS) { + break; + } + + if (map.is_submap) { + // We only look at main addresses + depth++; + } else { + fprintf(stderr, "%lx-%lx %s%s%s", addr, (addr+size), + ((map.protection & VM_PROT_READ) != 0 ? "r" : "-"), + ((map.protection & VM_PROT_WRITE) != 0 ? "w" : "-"), + ((map.protection & VM_PROT_EXECUTE) != 0 ? "x" : "-")); +#ifdef HAVE_LIBPROC_H + char buff[PATH_MAX]; + if (proc_regionfilename(getpid(), addr, buff, sizeof(buff)) > 0) { + fprintf(stderr, " %s", buff); + } +#endif + fprintf(stderr, "\n"); + } + + addr += size; + size = 0; + } +#endif } } |