< prev index next >
src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c
Print this page
@@ -39,10 +39,17 @@
#ifdef __APPLE__
#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
#endif
@@ -111,11 +118,11 @@
destroy_map_info(ph);
free(ph->core);
}
}
-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");
return NULL;
}
@@ -123,18 +130,19 @@
// initialize map
map->fd = fd;
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;
}
// add this to map list
map->next = ph->core->maps;
@@ -147,11 +155,11 @@
// Part of the class sharing workaround
static map_info* add_class_share_map_info(struct ps_prochandle* ph, off_t offset,
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;
}
map->next = ph->core->class_share_maps;
ph->core->class_share_maps = map;
< prev index next >