8280941: os::print_memory_mappings() prints segment preceeding the inclusion range
Reviewed-by: stefank, minqi
This commit is contained in:
parent
4532c3a163
commit
d1cc5fda8f
@ -5380,21 +5380,20 @@ bool os::supports_map_sync() {
|
||||
}
|
||||
|
||||
void os::print_memory_mappings(char* addr, size_t bytes, outputStream* st) {
|
||||
// Note: all ranges are "[..)"
|
||||
unsigned long long start = (unsigned long long)addr;
|
||||
unsigned long long end = start + bytes;
|
||||
FILE* f = os::fopen("/proc/self/maps", "r");
|
||||
int num_found = 0;
|
||||
if (f != NULL) {
|
||||
st->print("Range [%llx-%llx) contains: ", start, end);
|
||||
st->print_cr("Range [%llx-%llx) contains: ", start, end);
|
||||
char line[512];
|
||||
while(fgets(line, sizeof(line), f) == line) {
|
||||
unsigned long long a1 = 0;
|
||||
unsigned long long a2 = 0;
|
||||
if (::sscanf(line, "%llx-%llx", &a1, &a2) == 2) {
|
||||
unsigned long long segment_start = 0;
|
||||
unsigned long long segment_end = 0;
|
||||
if (::sscanf(line, "%llx-%llx", &segment_start, &segment_end) == 2) {
|
||||
// Lets print out every range which touches ours.
|
||||
if ((a1 >= start && a1 < end) || // left leg in
|
||||
(a2 >= start && a2 < end) || // right leg in
|
||||
(a1 < start && a2 >= end)) { // superimposition
|
||||
if (segment_start < end && segment_end > start) {
|
||||
num_found ++;
|
||||
st->print("%s", line); // line includes \n
|
||||
}
|
||||
@ -5402,7 +5401,7 @@ void os::print_memory_mappings(char* addr, size_t bytes, outputStream* st) {
|
||||
}
|
||||
::fclose(f);
|
||||
if (num_found == 0) {
|
||||
st->print("nothing.");
|
||||
st->print_cr("nothing.");
|
||||
}
|
||||
st->cr();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user