< prev index next >

src/hotspot/os/posix/os_posix.cpp

Print this page

 122   } else {
 123     switch(rlim.rlim_cur) {
 124       case RLIM_INFINITY:
 125         jio_snprintf(buffer, bufferSize, "%s", core_path);
 126         success = true;
 127         break;
 128       case 0:
 129         jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
 130         success = false;
 131         break;
 132       default:
 133         jio_snprintf(buffer, bufferSize, "%s (max size " UINT64_FORMAT " kB). To ensure a full core dump, try \"ulimit -c unlimited\" before starting Java again", core_path, uint64_t(rlim.rlim_cur) / 1024);
 134         success = true;
 135         break;
 136     }
 137   }
 138 
 139   VMError::record_coredump_status(buffer, success);
 140 }
 141 




 142 int os::get_native_stack(address* stack, int frames, int toSkip) {
 143   int frame_idx = 0;
 144   int num_of_frames;  // number of frames captured
 145   frame fr = os::current_frame();
 146   while (fr.pc() && frame_idx < frames) {
 147     if (toSkip > 0) {
 148       toSkip --;
 149     } else {
 150       stack[frame_idx ++] = fr.pc();
 151     }
 152     if (fr.fp() == NULL || fr.cb() != NULL ||
 153         fr.sender_pc() == NULL || os::is_first_C_frame(&fr)) break;
 154 
 155     if (fr.sender_pc() && !os::is_first_C_frame(&fr)) {
 156       fr = os::get_sender_for_C_frame(&fr);
 157     } else {
 158       break;
 159     }
 160   }
 161   num_of_frames = frame_idx;
 162   for (; frame_idx < frames; frame_idx ++) {
 163     stack[frame_idx] = NULL;
 164   }
 165 
 166   return num_of_frames;
 167 }

 168 
 169 int os::get_last_error() {
 170   return errno;
 171 }
 172 
 173 size_t os::lasterror(char *buf, size_t len) {
 174   if (errno == 0)  return 0;
 175 
 176   const char *s = os::strerror(errno);
 177   size_t n = ::strlen(s);
 178   if (n >= len) {
 179     n = len - 1;
 180   }
 181   ::strncpy(buf, s, n);
 182   buf[n] = '\0';
 183   return n;
 184 }
 185 
 186 // Return true if user is running as root.
 187 bool os::have_special_privileges() {

 122   } else {
 123     switch(rlim.rlim_cur) {
 124       case RLIM_INFINITY:
 125         jio_snprintf(buffer, bufferSize, "%s", core_path);
 126         success = true;
 127         break;
 128       case 0:
 129         jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
 130         success = false;
 131         break;
 132       default:
 133         jio_snprintf(buffer, bufferSize, "%s (max size " UINT64_FORMAT " kB). To ensure a full core dump, try \"ulimit -c unlimited\" before starting Java again", core_path, uint64_t(rlim.rlim_cur) / 1024);
 134         success = true;
 135         break;
 136     }
 137   }
 138 
 139   VMError::record_coredump_status(buffer, success);
 140 }
 141 
 142 // Native stack isn't walkable for RISCV this way.
 143 // Native C frame and Java frame have different structure on RISCV.
 144 // A seperate implementation is provided under linux_riscv for RISCV.
 145 #if !defined(RISCV) || defined(ZERO)
 146 int os::get_native_stack(address* stack, int frames, int toSkip) {
 147   int frame_idx = 0;
 148   int num_of_frames;  // number of frames captured
 149   frame fr = os::current_frame();
 150   while (fr.pc() && frame_idx < frames) {
 151     if (toSkip > 0) {
 152       toSkip --;
 153     } else {
 154       stack[frame_idx ++] = fr.pc();
 155     }
 156     if (fr.fp() == NULL || fr.cb() != NULL ||
 157         fr.sender_pc() == NULL || os::is_first_C_frame(&fr)) break;
 158 
 159     if (fr.sender_pc() && !os::is_first_C_frame(&fr)) {
 160       fr = os::get_sender_for_C_frame(&fr);
 161     } else {
 162       break;
 163     }
 164   }
 165   num_of_frames = frame_idx;
 166   for (; frame_idx < frames; frame_idx ++) {
 167     stack[frame_idx] = NULL;
 168   }
 169 
 170   return num_of_frames;
 171 }
 172 #endif
 173 
 174 int os::get_last_error() {
 175   return errno;
 176 }
 177 
 178 size_t os::lasterror(char *buf, size_t len) {
 179   if (errno == 0)  return 0;
 180 
 181   const char *s = os::strerror(errno);
 182   size_t n = ::strlen(s);
 183   if (n >= len) {
 184     n = len - 1;
 185   }
 186   ::strncpy(buf, s, n);
 187   buf[n] = '\0';
 188   return n;
 189 }
 190 
 191 // Return true if user is running as root.
 192 bool os::have_special_privileges() {
< prev index next >