193 } |
193 } |
194 |
194 |
195 //--------------------------------------------------------------- |
195 //--------------------------------------------------------------- |
196 // Part of the class sharing workaround: |
196 // Part of the class sharing workaround: |
197 // |
197 // |
198 // With class sharing, pages are mapped from classes[_g].jsa file. |
198 // With class sharing, pages are mapped from classes.jsa file. |
199 // The read-only class sharing pages are mapped as MAP_SHARED, |
199 // The read-only class sharing pages are mapped as MAP_SHARED, |
200 // PROT_READ pages. These pages are not dumped into core dump. |
200 // PROT_READ pages. These pages are not dumped into core dump. |
201 // With this workaround, these pages are read from classes[_g].jsa. |
201 // With this workaround, these pages are read from classes.jsa. |
202 |
202 |
203 // FIXME: !HACK ALERT! |
203 // FIXME: !HACK ALERT! |
204 // The format of sharing achive file header is needed to read shared heap |
204 // The format of sharing achive file header is needed to read shared heap |
205 // file mappings. For now, I am hard coding portion of FileMapHeader here. |
205 // file mappings. For now, I am hard coding portion of FileMapHeader here. |
206 // Refer to filemap.hpp. |
206 // Refer to filemap.hpp. |
282 |
282 |
283 static bool init_classsharing_workaround(struct ps_prochandle* ph) { |
283 static bool init_classsharing_workaround(struct ps_prochandle* ph) { |
284 lib_info* lib = ph->libs; |
284 lib_info* lib = ph->libs; |
285 while (lib != NULL) { |
285 while (lib != NULL) { |
286 // we are iterating over shared objects from the core dump. look for |
286 // we are iterating over shared objects from the core dump. look for |
287 // libjvm[_g].so. |
287 // libjvm.so. |
288 const char *jvm_name = 0; |
288 const char *jvm_name = 0; |
289 if ((jvm_name = strstr(lib->name, "/libjvm.so")) != 0 || |
289 if ((jvm_name = strstr(lib->name, "/libjvm.so")) != 0) { |
290 (jvm_name = strstr(lib->name, "/libjvm_g.so")) != 0) { |
|
291 char classes_jsa[PATH_MAX]; |
290 char classes_jsa[PATH_MAX]; |
292 struct FileMapHeader header; |
291 struct FileMapHeader header; |
293 size_t n = 0; |
292 size_t n = 0; |
294 int fd = -1, m = 0; |
293 int fd = -1, m = 0; |
295 uintptr_t base = 0, useSharedSpacesAddr = 0; |
294 uintptr_t base = 0, useSharedSpacesAddr = 0; |
369 close(fd); |
368 close(fd); |
370 return false; |
369 return false; |
371 } |
370 } |
372 |
371 |
373 ph->core->classes_jsa_fd = fd; |
372 ph->core->classes_jsa_fd = fd; |
374 // add read-only maps from classes[_g].jsa to the list of maps |
373 // add read-only maps from classes.jsa to the list of maps |
375 for (m = 0; m < NUM_SHARED_MAPS; m++) { |
374 for (m = 0; m < NUM_SHARED_MAPS; m++) { |
376 if (header._space[m]._read_only) { |
375 if (header._space[m]._read_only) { |
377 base = (uintptr_t) header._space[m]._base; |
376 base = (uintptr_t) header._space[m]._base; |
378 // no need to worry about the fractional pages at-the-end. |
377 // no need to worry about the fractional pages at-the-end. |
379 // possible fractional pages are handled by core_read_data. |
378 // possible fractional pages are handled by core_read_data. |