--- old/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c 2020-08-04 21:19:50.990000000 +0900 +++ new/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c 2020-08-04 21:19:50.860000000 +0900 @@ -41,6 +41,13 @@ #include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h" #endif +// Define a segment permission flag allowing read. +#ifdef PF_R +#define MAP_R_FLAG PF_R +#else +#define MAP_R_FLAG 0 +#endif + #ifdef LINUX // I have no idea why this function is called ps_pread() on macos but ps_pdread on linux. #define ps_pread ps_pdread @@ -113,7 +120,7 @@ } } -static map_info* allocate_init_map(int fd, off_t offset, uintptr_t vaddr, size_t memsz) { +static map_info* allocate_init_map(int fd, off_t offset, uintptr_t vaddr, size_t memsz, uint32_t flags) { map_info* map; if ( (map = (map_info*) calloc(1, sizeof(map_info))) == NULL) { print_debug("can't allocate memory for map_info\n"); @@ -125,14 +132,15 @@ map->offset = offset; map->vaddr = vaddr; map->memsz = memsz; + map->flags = flags; return map; } // add map info with given fd, offset, vaddr and memsz map_info* add_map_info(struct ps_prochandle* ph, int fd, off_t offset, - uintptr_t vaddr, size_t memsz) { + uintptr_t vaddr, size_t memsz, uint32_t flags) { map_info* map; - if ((map = allocate_init_map(fd, offset, vaddr, memsz)) == NULL) { + if ((map = allocate_init_map(fd, offset, vaddr, memsz, flags)) == NULL) { return NULL; } @@ -149,7 +157,7 @@ uintptr_t vaddr, size_t memsz) { map_info* map; if ((map = allocate_init_map(ph->core->classes_jsa_fd, - offset, vaddr, memsz)) == NULL) { + offset, vaddr, memsz, MAP_R_FLAG)) == NULL) { return NULL; }