8054386: Allow Java debugging when CDS is enabled

Map archive RW when debugging is enabled

Reviewed-by: sspitsyn, iklam, mseledtsov, dholmes
This commit is contained in:
Chris Plummer 2015-06-05 13:40:09 -07:00
parent 24c9ffed42
commit c8c0356588

View file

@ -32,6 +32,7 @@
#include "memory/metadataFactory.hpp" #include "memory/metadataFactory.hpp"
#include "memory/oopFactory.hpp" #include "memory/oopFactory.hpp"
#include "oops/objArrayOop.hpp" #include "oops/objArrayOop.hpp"
#include "prims/jvmtiExport.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
@ -568,10 +569,19 @@ char* FileMapInfo::map_region(int i) {
size_t alignment = os::vm_allocation_granularity(); size_t alignment = os::vm_allocation_granularity();
size_t size = align_size_up(used, alignment); size_t size = align_size_up(used, alignment);
char *requested_addr = si->_base; char *requested_addr = si->_base;
bool read_only;
// If a tool agent is in use (debugging enabled), we must map the address space RW
if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) {
read_only = false;
} else {
read_only = si->_read_only;
}
// map the contents of the CDS archive in this memory // map the contents of the CDS archive in this memory
char *base = os::map_memory(_fd, _full_path, si->_file_offset, char *base = os::map_memory(_fd, _full_path, si->_file_offset,
requested_addr, size, si->_read_only, requested_addr, size, read_only,
si->_allow_exec); si->_allow_exec);
if (base == NULL || base != si->_base) { if (base == NULL || base != si->_base) {
fail_continue("Unable to map %s shared space at required address.", shared_region_name[i]); fail_continue("Unable to map %s shared space at required address.", shared_region_name[i]);
@ -637,11 +647,6 @@ bool FileMapInfo::_validating_classpath_entry_table = false;
bool FileMapInfo::initialize() { bool FileMapInfo::initialize() {
assert(UseSharedSpaces, "UseSharedSpaces expected."); assert(UseSharedSpaces, "UseSharedSpaces expected.");
if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) {
fail_continue("Tool agent requires sharing to be disabled.");
return false;
}
if (!open_for_read()) { if (!open_for_read()) {
return false; return false;
} }