hotspot/src/os/windows/vm/os_windows.cpp
changeset 37052 e608476da586
parent 36571 350fddc3a0c6
child 37113 5a33bf5089ac
equal deleted inserted replaced
37050:85b12760d820 37052:e608476da586
  2184 #endif
  2184 #endif
  2185 
  2185 
  2186 // Windows Vista/2008 heap corruption check
  2186 // Windows Vista/2008 heap corruption check
  2187 #define EXCEPTION_HEAP_CORRUPTION        0xC0000374
  2187 #define EXCEPTION_HEAP_CORRUPTION        0xC0000374
  2188 
  2188 
  2189 #define def_excpt(val) #val, val
       
  2190 
       
  2191 struct siglabel {
       
  2192   char *name;
       
  2193   int   number;
       
  2194 };
       
  2195 
       
  2196 // All Visual C++ exceptions thrown from code generated by the Microsoft Visual
  2189 // All Visual C++ exceptions thrown from code generated by the Microsoft Visual
  2197 // C++ compiler contain this error code. Because this is a compiler-generated
  2190 // C++ compiler contain this error code. Because this is a compiler-generated
  2198 // error, the code is not listed in the Win32 API header files.
  2191 // error, the code is not listed in the Win32 API header files.
  2199 // The code is actually a cryptic mnemonic device, with the initial "E"
  2192 // The code is actually a cryptic mnemonic device, with the initial "E"
  2200 // standing for "exception" and the final 3 bytes (0x6D7363) representing the
  2193 // standing for "exception" and the final 3 bytes (0x6D7363) representing the
  2201 // ASCII values of "msc".
  2194 // ASCII values of "msc".
  2202 
  2195 
  2203 #define EXCEPTION_UNCAUGHT_CXX_EXCEPTION    0xE06D7363
  2196 #define EXCEPTION_UNCAUGHT_CXX_EXCEPTION    0xE06D7363
  2204 
  2197 
  2205 
  2198 #define def_excpt(val) { #val, (val) }
  2206 struct siglabel exceptlabels[] = {
  2199 
       
  2200 static const struct { char* name; uint number; } exceptlabels[] = {
  2207     def_excpt(EXCEPTION_ACCESS_VIOLATION),
  2201     def_excpt(EXCEPTION_ACCESS_VIOLATION),
  2208     def_excpt(EXCEPTION_DATATYPE_MISALIGNMENT),
  2202     def_excpt(EXCEPTION_DATATYPE_MISALIGNMENT),
  2209     def_excpt(EXCEPTION_BREAKPOINT),
  2203     def_excpt(EXCEPTION_BREAKPOINT),
  2210     def_excpt(EXCEPTION_SINGLE_STEP),
  2204     def_excpt(EXCEPTION_SINGLE_STEP),
  2211     def_excpt(EXCEPTION_ARRAY_BOUNDS_EXCEEDED),
  2205     def_excpt(EXCEPTION_ARRAY_BOUNDS_EXCEEDED),
  2226     def_excpt(EXCEPTION_STACK_OVERFLOW),
  2220     def_excpt(EXCEPTION_STACK_OVERFLOW),
  2227     def_excpt(EXCEPTION_INVALID_DISPOSITION),
  2221     def_excpt(EXCEPTION_INVALID_DISPOSITION),
  2228     def_excpt(EXCEPTION_GUARD_PAGE),
  2222     def_excpt(EXCEPTION_GUARD_PAGE),
  2229     def_excpt(EXCEPTION_INVALID_HANDLE),
  2223     def_excpt(EXCEPTION_INVALID_HANDLE),
  2230     def_excpt(EXCEPTION_UNCAUGHT_CXX_EXCEPTION),
  2224     def_excpt(EXCEPTION_UNCAUGHT_CXX_EXCEPTION),
  2231     def_excpt(EXCEPTION_HEAP_CORRUPTION),
  2225     def_excpt(EXCEPTION_HEAP_CORRUPTION)
  2232 #ifdef _M_IA64
  2226 #ifdef _M_IA64
  2233     def_excpt(EXCEPTION_REG_NAT_CONSUMPTION),
  2227     , def_excpt(EXCEPTION_REG_NAT_CONSUMPTION)
  2234 #endif
  2228 #endif
  2235     NULL, 0
       
  2236 };
  2229 };
  2237 
  2230 
       
  2231 #undef def_excpt
       
  2232 
  2238 const char* os::exception_name(int exception_code, char *buf, size_t size) {
  2233 const char* os::exception_name(int exception_code, char *buf, size_t size) {
  2239   for (int i = 0; exceptlabels[i].name != NULL; i++) {
  2234   uint code = static_cast<uint>(exception_code);
  2240     if (exceptlabels[i].number == exception_code) {
  2235   for (uint i = 0; i < ARRAY_SIZE(exceptlabels); ++i) {
       
  2236     if (exceptlabels[i].number == code) {
  2241       jio_snprintf(buf, size, "%s", exceptlabels[i].name);
  2237       jio_snprintf(buf, size, "%s", exceptlabels[i].name);
  2242       return buf;
  2238       return buf;
  2243     }
  2239     }
  2244   }
  2240   }
  2245 
  2241 
  5636   "SEGV",       SIGSEGV,        // segment violation
  5632   "SEGV",       SIGSEGV,        // segment violation
  5637   "INT",        SIGINT,         // interrupt
  5633   "INT",        SIGINT,         // interrupt
  5638   "TERM",       SIGTERM,        // software term signal from kill
  5634   "TERM",       SIGTERM,        // software term signal from kill
  5639   "BREAK",      SIGBREAK,       // Ctrl-Break sequence
  5635   "BREAK",      SIGBREAK,       // Ctrl-Break sequence
  5640   "ILL",        SIGILL};        // illegal instruction
  5636   "ILL",        SIGILL};        // illegal instruction
  5641   for(int i=0;i<sizeof(siglabels)/sizeof(struct siglabel);i++)
  5637   for (unsigned i = 0; i < ARRAY_SIZE(siglabels); ++i) {
  5642     if(!strcmp(name, siglabels[i].name))
  5638     if (strcmp(name, siglabels[i].name) == 0) {
  5643       return siglabels[i].number;
  5639       return siglabels[i].number;
       
  5640     }
       
  5641   }
  5644   return -1;
  5642   return -1;
  5645 }
  5643 }
  5646 
  5644 
  5647 // Fast current thread access
  5645 // Fast current thread access
  5648 
  5646