@@ -5470,29 +5470,28 @@ bool os::supports_map_sync() {
54705470}
54715471
54725472void os::print_memory_mappings (char * addr, size_t bytes, outputStream* st) {
5473+ // Note: all ranges are "[..)"
54735474 unsigned long long start = (unsigned long long )addr;
54745475 unsigned long long end = start + bytes;
54755476 FILE* f = ::fopen (" /proc/self/maps" , " r" );
54765477 int num_found = 0 ;
54775478 if (f != NULL ) {
5478- st->print (" Range [%llx-%llx) contains: " , start, end);
5479+ st->print_cr (" Range [%llx-%llx) contains: " , start, end);
54795480 char line[512 ];
54805481 while (fgets (line, sizeof (line), f) == line) {
5481- unsigned long long a1 = 0 ;
5482- unsigned long long a2 = 0 ;
5483- if (::sscanf (line, " %llx-%llx" , &a1 , &a2 ) == 2 ) {
5482+ unsigned long long segment_start = 0 ;
5483+ unsigned long long segment_end = 0 ;
5484+ if (::sscanf (line, " %llx-%llx" , &segment_start , &segment_end ) == 2 ) {
54845485 // Lets print out every range which touches ours.
5485- if ((a1 >= start && a1 < end) || // left leg in
5486- (a2 >= start && a2 < end) || // right leg in
5487- (a1 < start && a2 >= end)) { // superimposition
5486+ if (segment_start < end && segment_end > start) {
54885487 num_found ++;
54895488 st->print (" %s" , line); // line includes \n
54905489 }
54915490 }
54925491 }
54935492 ::fclose (f);
54945493 if (num_found == 0 ) {
5495- st->print (" nothing." );
5494+ st->print_cr (" nothing." );
54965495 }
54975496 st->cr ();
54985497 }
0 commit comments