Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8280941: os::print_memory_mappings() prints segment preceeding the in…
…clusion range

Backport-of: d1cc5fda8f9fe3480d661985f15c71a8a9a4a7f8
  • Loading branch information
tstuefe committed Apr 1, 2022
1 parent 0bb751b commit 1007ded
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/hotspot/os/linux/os_linux.cpp
Expand Up @@ -5470,29 +5470,28 @@ 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 = ::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
}
}
}
::fclose(f);
if (num_found == 0) {
st->print("nothing.");
st->print_cr("nothing.");
}
st->cr();
}
Expand Down

1 comment on commit 1007ded

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.