< prev index next >

src/hotspot/share/runtime/os.cpp

Print this page

1231   // Try an OS specific find
1232   if (os::find(addr, st)) {
1233     return;
1234   }
1235 
1236   if (accessible) {
1237     st->print(INTPTR_FORMAT " points into unknown readable memory:", p2i(addr));
1238     if (is_aligned(addr, sizeof(intptr_t))) {
1239       st->print(" " PTR_FORMAT " |", *(intptr_t*)addr);
1240     }
1241     for (address p = addr; p < align_up(addr + 1, sizeof(intptr_t)); ++p) {
1242       st->print(" %02x", *(u1*)p);
1243     }
1244     st->cr();
1245     return;
1246   }
1247 
1248   st->print_cr(INTPTR_FORMAT " is an unknown value", p2i(addr));
1249 }
1250 


1251 // Looks like all platforms can use the same function to check if C
1252 // stack is walkable beyond current frame.
1253 bool os::is_first_C_frame(frame* fr) {
1254 
1255 #ifdef _WINDOWS
1256   return true; // native stack isn't walkable on windows this way.
1257 #endif
1258 
1259   // Load up sp, fp, sender sp and sender fp, check for reasonable values.
1260   // Check usp first, because if that's bad the other accessors may fault
1261   // on some architectures.  Ditto ufp second, etc.
1262   uintptr_t fp_align_mask = (uintptr_t)(sizeof(address)-1);
1263   // sp on amd can be 32 bit aligned.
1264   uintptr_t sp_align_mask = (uintptr_t)(sizeof(int)-1);
1265 
1266   uintptr_t usp    = (uintptr_t)fr->sp();
1267   if ((usp & sp_align_mask) != 0) return true;
1268 
1269   uintptr_t ufp    = (uintptr_t)fr->fp();
1270   if ((ufp & fp_align_mask) != 0) return true;
1271 
1272   uintptr_t old_sp = (uintptr_t)fr->sender_sp();
1273   if ((old_sp & sp_align_mask) != 0) return true;
1274   if (old_sp == 0 || old_sp == (uintptr_t)-1) return true;
1275 
1276   uintptr_t old_fp = (uintptr_t)fr->link();
1277   if ((old_fp & fp_align_mask) != 0) return true;
1278   if (old_fp == 0 || old_fp == (uintptr_t)-1 || old_fp == ufp) return true;
1279 
1280   // stack grows downwards; if old_fp is below current fp or if the stack
1281   // frame is too large, either the stack is corrupted or fp is not saved
1282   // on stack (i.e. on x86, ebp may be used as general register). The stack
1283   // is not walkable beyond current frame.
1284   if (old_fp < ufp) return true;
1285   if (old_fp - ufp > 64 * K) return true;
1286 
1287   return false;
1288 }
1289 
1290 
1291 // Set up the boot classpath.
1292 
1293 char* os::format_boot_path(const char* format_string,
1294                            const char* home,
1295                            int home_len,
1296                            char fileSep,
1297                            char pathSep) {
1298     assert((fileSep == '/' && pathSep == ':') ||
1299            (fileSep == '\\' && pathSep == ';'), "unexpected separator chars");
1300 
1301     // Scan the format string to determine the length of the actual
1302     // boot classpath, and handle platform dependencies as well.
1303     int formatted_path_len = 0;
1304     const char* p;
1305     for (p = format_string; *p != 0; ++p) {
1306         if (*p == '%') formatted_path_len += home_len - 1;
1307         ++formatted_path_len;
1308     }
1309 

1231   // Try an OS specific find
1232   if (os::find(addr, st)) {
1233     return;
1234   }
1235 
1236   if (accessible) {
1237     st->print(INTPTR_FORMAT " points into unknown readable memory:", p2i(addr));
1238     if (is_aligned(addr, sizeof(intptr_t))) {
1239       st->print(" " PTR_FORMAT " |", *(intptr_t*)addr);
1240     }
1241     for (address p = addr; p < align_up(addr + 1, sizeof(intptr_t)); ++p) {
1242       st->print(" %02x", *(u1*)p);
1243     }
1244     st->cr();
1245     return;
1246   }
1247 
1248   st->print_cr(INTPTR_FORMAT " is an unknown value", p2i(addr));
1249 }
1250 
1251 // native stack isn't walkable for RISCV this way.
1252 #if !defined(RISCV) || defined(ZERO)
1253 // Looks like all platforms can use the same function to check if C
1254 // stack is walkable beyond current frame.
1255 bool os::is_first_C_frame(frame* fr) {
1256 
1257 #ifdef _WINDOWS
1258   return true; // native stack isn't walkable on windows this way.
1259 #endif
1260 
1261   // Load up sp, fp, sender sp and sender fp, check for reasonable values.
1262   // Check usp first, because if that's bad the other accessors may fault
1263   // on some architectures.  Ditto ufp second, etc.
1264   uintptr_t fp_align_mask = (uintptr_t)(sizeof(address)-1);
1265   // sp on amd can be 32 bit aligned.
1266   uintptr_t sp_align_mask = (uintptr_t)(sizeof(int)-1);
1267 
1268   uintptr_t usp    = (uintptr_t)fr->sp();
1269   if ((usp & sp_align_mask) != 0) return true;
1270 
1271   uintptr_t ufp    = (uintptr_t)fr->fp();
1272   if ((ufp & fp_align_mask) != 0) return true;
1273 
1274   uintptr_t old_sp = (uintptr_t)fr->sender_sp();
1275   if ((old_sp & sp_align_mask) != 0) return true;
1276   if (old_sp == 0 || old_sp == (uintptr_t)-1) return true;
1277 
1278   uintptr_t old_fp = (uintptr_t)fr->link();
1279   if ((old_fp & fp_align_mask) != 0) return true;
1280   if (old_fp == 0 || old_fp == (uintptr_t)-1 || old_fp == ufp) return true;
1281 
1282   // stack grows downwards; if old_fp is below current fp or if the stack
1283   // frame is too large, either the stack is corrupted or fp is not saved
1284   // on stack (i.e. on x86, ebp may be used as general register). The stack
1285   // is not walkable beyond current frame.
1286   if (old_fp < ufp) return true;
1287   if (old_fp - ufp > 64 * K) return true;
1288 
1289   return false;
1290 }
1291 #endif // !RISCV64 || ZERO
1292 
1293 // Set up the boot classpath.
1294 
1295 char* os::format_boot_path(const char* format_string,
1296                            const char* home,
1297                            int home_len,
1298                            char fileSep,
1299                            char pathSep) {
1300     assert((fileSep == '/' && pathSep == ':') ||
1301            (fileSep == '\\' && pathSep == ';'), "unexpected separator chars");
1302 
1303     // Scan the format string to determine the length of the actual
1304     // boot classpath, and handle platform dependencies as well.
1305     int formatted_path_len = 0;
1306     const char* p;
1307     for (p = format_string; *p != 0; ++p) {
1308         if (*p == '%') formatted_path_len += home_len - 1;
1309         ++formatted_path_len;
1310     }
1311 
< prev index next >