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

Reviewed-by: stefank, minqi
  • Loading branch information
tstuefe committed Feb 1, 2022
1 parent 4532c3a commit d1cc5fd
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 @@ -5380,29 +5380,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 = 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
}
}
}
::fclose(f);
if (num_found == 0) {
st->print("nothing.");
st->print_cr("nothing.");
}
st->cr();
}
Expand Down

3 comments on commit d1cc5fd

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@tstuefe
Copy link
Member Author

@tstuefe tstuefe commented on d1cc5fd Apr 1, 2022

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d1cc5fd Apr 1, 2022

Choose a reason for hiding this comment

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

@tstuefe the backport was successfully created on the branch tstuefe-backport-d1cc5fda in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d1cc5fda from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 1 Feb 2022 and was reviewed by Stefan Karlsson and Yumin Qi.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev tstuefe-backport-d1cc5fda:tstuefe-backport-d1cc5fda
$ git checkout tstuefe-backport-d1cc5fda
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev tstuefe-backport-d1cc5fda

Please sign in to comment.