8025812: tmtools/jmap/heap_config tests fail on Linux-ia32 because it Cant attach to the core file
authordsamersoff
Thu, 17 Oct 2013 16:08:01 +0400
changeset 21069 728330d2593a
parent 21068 9ae484a7cc55
child 21071 cb6d8284307f
child 21073 8d1d576cfdb2
8025812: tmtools/jmap/heap_config tests fail on Linux-ia32 because it Cant attach to the core file Summary: Coredump store memsz elf field rounded up to page Reviewed-by: dholmes, sla
hotspot/agent/src/os/linux/ps_core.c
--- a/hotspot/agent/src/os/linux/ps_core.c	Wed Oct 16 15:26:12 2013 -0400
+++ b/hotspot/agent/src/os/linux/ps_core.c	Thu Oct 17 16:08:01 2013 +0400
@@ -719,7 +719,7 @@
   ELF_PHDR* phbuf;
   ELF_PHDR* lib_php = NULL;
 
-  int page_size=sysconf(_SC_PAGE_SIZE);
+  int page_size = sysconf(_SC_PAGE_SIZE);
 
   if ((phbuf = read_program_header_table(lib_fd, lib_ehdr)) == NULL) {
     return false;
@@ -736,26 +736,29 @@
 
       if (existing_map == NULL){
         if (add_map_info(ph, lib_fd, lib_php->p_offset,
-                          target_vaddr, lib_php->p_filesz) == NULL) {
+                          target_vaddr, lib_php->p_memsz) == NULL) {
           goto err;
         }
       } else {
+        // Coredump stores value of p_memsz elf field
+        // rounded up to page boundary.
+
         if ((existing_map->memsz != page_size) &&
             (existing_map->fd != lib_fd) &&
-            (existing_map->memsz != lib_php->p_filesz)){
+            (ROUNDUP(existing_map->memsz, page_size) != ROUNDUP(lib_php->p_memsz, page_size))) {
 
-          print_debug("address conflict @ 0x%lx (size = %ld, flags = %d\n)",
-                        target_vaddr, lib_php->p_filesz, lib_php->p_flags);
+          print_debug("address conflict @ 0x%lx (existing map size = %ld, size = %ld, flags = %d)\n",
+                        target_vaddr, existing_map->memsz, lib_php->p_memsz, lib_php->p_flags);
           goto err;
         }
 
         /* replace PT_LOAD segment with library segment */
         print_debug("overwrote with new address mapping (memsz %ld -> %ld)\n",
-                     existing_map->memsz, lib_php->p_filesz);
+                     existing_map->memsz, ROUNDUP(lib_php->p_memsz, page_size));
 
         existing_map->fd = lib_fd;
         existing_map->offset = lib_php->p_offset;
-        existing_map->memsz = lib_php->p_filesz;
+        existing_map->memsz = ROUNDUP(lib_php->p_memsz, page_size);
       }
     }