@@ -444,7 +444,7 @@ void VMError::report(outputStream* st, bool _verbose) {
444
444
" Runtime Environment to continue." );
445
445
}
446
446
447
- #ifndef PRODUCT
447
+ #ifdef ASSERT
448
448
// Error handler self tests
449
449
450
450
// test secondary error handling. Test it twice, to test that resetting
@@ -503,7 +503,7 @@ void VMError::report(outputStream* st, bool _verbose) {
503
503
st->print_cr (" not possible; skipped." );
504
504
}
505
505
}
506
- #endif // PRODUCT
506
+ #endif // ASSERT
507
507
508
508
STEP (" printing type of error" )
509
509
@@ -1737,7 +1737,7 @@ bool VMError::check_timeout() {
1737
1737
1738
1738
}
1739
1739
1740
- #ifndef PRODUCT
1740
+ #ifdef ASSERT
1741
1741
typedef void (*voidfun_t )();
1742
1742
1743
1743
// Crash with an authentic sigfpe
@@ -1765,47 +1765,13 @@ static void crash_with_segfault() {
1765
1765
1766
1766
} // end: crash_with_segfault
1767
1767
1768
- void VMError::test_error_handler () {
1769
- controlled_crash (ErrorHandlerTest);
1770
- }
1771
-
1772
1768
// crash in a controlled way:
1773
- // how can be one of:
1774
- // 1,2 - asserts
1775
- // 3,4 - guarantee
1776
- // 5-7 - fatal
1777
- // 8 - vm_exit_out_of_memory
1778
- // 9 - ShouldNotCallThis
1779
- // 10 - ShouldNotReachHere
1780
- // 11 - Unimplemented
1781
- // 12,13 - (not guaranteed) crashes
1769
+ // 1 - assert
1770
+ // 2 - guarantee
1782
1771
// 14 - SIGSEGV
1783
1772
// 15 - SIGFPE
1784
1773
void VMError::controlled_crash (int how) {
1785
- if (how == 0 ) return ;
1786
-
1787
- // If asserts are disabled, use the corresponding guarantee instead.
1788
- NOT_DEBUG (if (how <= 2 ) how += 2 );
1789
-
1790
- const char * const str = " hello" ;
1791
- const size_t num = (size_t )os::vm_page_size ();
1792
-
1793
- const char * const eol = os::line_separator ();
1794
- const char * const msg = " this message should be truncated during formatting" ;
1795
- char * const dataPtr = NULL ; // bad data pointer
1796
- const void (*funcPtr)(void ); // bad function pointer
1797
1774
1798
- #if defined(PPC64) && !defined(ABI_ELFv2)
1799
- struct FunctionDescriptor functionDescriptor;
1800
-
1801
- functionDescriptor.set_entry ((address) 0xF );
1802
- funcPtr = (const void (*)()) &functionDescriptor;
1803
- #else
1804
- funcPtr = (const void (*)()) 0xF ;
1805
- #endif
1806
-
1807
- // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
1808
- // which tests cases 1 thru 13.
1809
1775
// Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
1810
1776
// Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
1811
1777
// Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
@@ -1821,30 +1787,10 @@ void VMError::controlled_crash(int how) {
1821
1787
}
1822
1788
1823
1789
switch (how) {
1824
- case 1 : vmassert (str == NULL , " expected null" ); break ;
1825
- case 2 : vmassert (num == 1023 && *str == ' X' ,
1826
- " num=" SIZE_FORMAT " str=\" %s\" " , num, str); break ;
1827
- case 3 : guarantee (str == NULL , " expected null" ); break ;
1828
- case 4 : guarantee (num == 1023 && *str == ' X' ,
1829
- " num=" SIZE_FORMAT " str=\" %s\" " , num, str); break ;
1830
- case 5 : fatal (" expected null" ); break ;
1831
- case 6 : fatal (" num=" SIZE_FORMAT " str=\" %s\" " , num, str); break ;
1832
- case 7 : fatal (" %s%s# %s%s# %s%s# %s%s# %s%s# "
1833
- " %s%s# %s%s# %s%s# %s%s# %s%s# "
1834
- " %s%s# %s%s# %s%s# %s%s# %s" ,
1835
- msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1836
- msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1837
- msg, eol, msg, eol, msg, eol, msg, eol, msg); break ;
1838
- case 8 : vm_exit_out_of_memory (num, OOM_MALLOC_ERROR, " ChunkPool::allocate" ); break ;
1839
- case 9 : ShouldNotCallThis (); break ;
1840
- case 10 : ShouldNotReachHere (); break ;
1841
- case 11 : Unimplemented (); break ;
1842
- // There's no guarantee the bad data pointer will crash us
1843
- // so "break" out to the ShouldNotReachHere().
1844
- case 12 : *dataPtr = ' \0 ' ; break ;
1845
- // There's no guarantee the bad function pointer will crash us
1846
- // so "break" out to the ShouldNotReachHere().
1847
- case 13 : (*funcPtr)(); break ;
1790
+ case 1 : assert (how == 0 , " test assert" ); break ;
1791
+ case 2 : guarantee (how == 0 , " test guarantee" ); break ;
1792
+
1793
+ // The other cases are unused.
1848
1794
case 14 : crash_with_segfault (); break ;
1849
1795
case 15 : crash_with_sigfpe (); break ;
1850
1796
case 16 : {
@@ -1858,19 +1804,11 @@ void VMError::controlled_crash(int how) {
1858
1804
fatal (" Force crash with a nested ThreadsListHandle." );
1859
1805
}
1860
1806
}
1861
- case 18 : {
1862
- // Check for assert when allocating from resource area without a
1863
- // ResourceMark. There must not be a ResourceMark on the
1864
- // current stack when invoking this test case.
1865
- ResourceArea* area = Thread::current ()->resource_area ();
1866
- assert (area->nesting () == 0 , " unexpected ResourceMark" );
1867
- area->allocate_bytes (100 );
1868
- break ;
1869
- }
1870
-
1871
- default : tty->print_cr (" ERROR: %d: unexpected test_num value." , how);
1807
+ default :
1808
+ // If another number is given, give a generic crash.
1809
+ fatal (" Crashing with number %d" , how);
1872
1810
}
1873
- tty->print_cr (" VMError:: controlled_crash: survived intentional crash. Did you suppress the assert?" );
1811
+ tty->print_cr (" controlled_crash: survived intentional crash. Did you suppress the assert?" );
1874
1812
ShouldNotReachHere ();
1875
1813
}
1876
- #endif // !PRODUCT
1814
+ #endif // !ASSERT
0 commit comments