< prev index next >

src/os/linux/vm/os_linux.cpp

Print this page




2129   }
2130 
2131   ::close(fd);
2132 
2133   return true;
2134 }
2135 
2136 void os::print_dll_info(outputStream *st) {
2137    st->print_cr("Dynamic libraries:");
2138 
2139    char fname[32];
2140    pid_t pid = os::Linux::gettid();
2141 
2142    jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
2143 
2144    if (!_print_ascii_file(fname, st)) {
2145      st->print("Can not get library information for pid = %d\n", pid);
2146    }
2147 }
2148 



































2149 void os::print_os_info_brief(outputStream* st) {
2150   os::Linux::print_distro_info(st);
2151 
2152   os::Posix::print_uname_info(st);
2153 
2154   os::Linux::print_libversion_info(st);
2155 
2156 }
2157 
2158 void os::print_os_info(outputStream* st) {
2159   st->print("OS:");
2160 
2161   os::Linux::print_distro_info(st);
2162 
2163   os::Posix::print_uname_info(st);
2164 
2165   // Print warning if unsafe chroot environment detected
2166   if (unsafe_chroot_detected) {
2167     st->print("WARNING!! ");
2168     st->print_cr("%s", unstable_chroot_error);


4011 
4012   // Give back the unused reserved pieces.
4013 
4014   for (int j = 0; j < i; ++j) {
4015     if (base[j] != NULL) {
4016       unmap_memory(base[j], size[j]);
4017     }
4018   }
4019 
4020   if (i < max_tries) {
4021     _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes);
4022     return requested_addr;
4023   } else {
4024     _highest_vm_reserved_address = old_highest;
4025     return NULL;
4026   }
4027 }
4028 
4029 size_t os::read(int fd, void *buf, unsigned int nBytes) {
4030   return ::read(fd, buf, nBytes);




4031 }
4032 
4033 // TODO-FIXME: reconcile Solaris' os::sleep with the linux variation.
4034 // Solaris uses poll(), linux uses park().
4035 // Poll() is likely a better choice, assuming that Thread.interrupt()
4036 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
4037 // SIGSEGV, see 4355769.
4038 
4039 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
4040   assert(thread == Thread::current(),  "thread consistency check");
4041 
4042   ParkEvent * const slp = thread->_SleepEvent ;
4043   slp->reset() ;
4044   OrderAccess::fence() ;
4045 
4046   if (interruptible) {
4047     jlong prevtime = javaTimeNanos();
4048 
4049     for (;;) {
4050       if (os::is_interrupted(thread, true)) {




2129   }
2130 
2131   ::close(fd);
2132 
2133   return true;
2134 }
2135 
2136 void os::print_dll_info(outputStream *st) {
2137    st->print_cr("Dynamic libraries:");
2138 
2139    char fname[32];
2140    pid_t pid = os::Linux::gettid();
2141 
2142    jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
2143 
2144    if (!_print_ascii_file(fname, st)) {
2145      st->print("Can not get library information for pid = %d\n", pid);
2146    }
2147 }
2148 
2149 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) {
2150   FILE *procmapsFile = NULL;
2151 
2152   // Open the procfs maps file for the current process
2153   if ((procmapsFile = fopen("/proc/self/maps", "r")) != NULL) {
2154     // Allocate PATH_MAX for file name plus a reasonable size for other fields.
2155     char line[PATH_MAX + 100];
2156 
2157     // Read line by line from 'file'
2158     while (fgets(line, sizeof(line), procmapsFile) != NULL) {
2159       u8 base, top, offset, inode;
2160       char permissions[5];
2161       char device[6];
2162       char name[PATH_MAX + 1];
2163 
2164       // Parse fields from line
2165       sscanf(line, UINT64_FORMAT_X "-" UINT64_FORMAT_X " %4s " UINT64_FORMAT_X " %7s " INT64_FORMAT " %s",
2166              &base, &top, permissions, &offset, device, &inode, name);
2167 
2168       // Filter by device id '00:00' so that we only get file system mapped files.
2169       if (strcmp(device, "00:00") != 0) {
2170 
2171         // Call callback with the fields of interest
2172         if(callback(name, (address)base, (address)top, param)) {
2173           // Oops abort, callback aborted
2174           fclose(procmapsFile);
2175           return 1;
2176         }
2177       }
2178     }
2179     fclose(procmapsFile);
2180   }
2181   return 0;
2182 }
2183 
2184 void os::print_os_info_brief(outputStream* st) {
2185   os::Linux::print_distro_info(st);
2186 
2187   os::Posix::print_uname_info(st);
2188 
2189   os::Linux::print_libversion_info(st);
2190 
2191 }
2192 
2193 void os::print_os_info(outputStream* st) {
2194   st->print("OS:");
2195 
2196   os::Linux::print_distro_info(st);
2197 
2198   os::Posix::print_uname_info(st);
2199 
2200   // Print warning if unsafe chroot environment detected
2201   if (unsafe_chroot_detected) {
2202     st->print("WARNING!! ");
2203     st->print_cr("%s", unstable_chroot_error);


4046 
4047   // Give back the unused reserved pieces.
4048 
4049   for (int j = 0; j < i; ++j) {
4050     if (base[j] != NULL) {
4051       unmap_memory(base[j], size[j]);
4052     }
4053   }
4054 
4055   if (i < max_tries) {
4056     _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes);
4057     return requested_addr;
4058   } else {
4059     _highest_vm_reserved_address = old_highest;
4060     return NULL;
4061   }
4062 }
4063 
4064 size_t os::read(int fd, void *buf, unsigned int nBytes) {
4065   return ::read(fd, buf, nBytes);
4066 }
4067 
4068 size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
4069   return ::pread(fd, buf, nBytes, offset);
4070 }
4071 
4072 // TODO-FIXME: reconcile Solaris' os::sleep with the linux variation.
4073 // Solaris uses poll(), linux uses park().
4074 // Poll() is likely a better choice, assuming that Thread.interrupt()
4075 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
4076 // SIGSEGV, see 4355769.
4077 
4078 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
4079   assert(thread == Thread::current(),  "thread consistency check");
4080 
4081   ParkEvent * const slp = thread->_SleepEvent ;
4082   slp->reset() ;
4083   OrderAccess::fence() ;
4084 
4085   if (interruptible) {
4086     jlong prevtime = javaTimeNanos();
4087 
4088     for (;;) {
4089       if (os::is_interrupted(thread, true)) {


< prev index next >