< prev index next >

src/hotspot/share/utilities/debug.hpp

Print this page
rev 49276 : 8191101: Show register content in hs-err file on assert
Reviewed-by:

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -29,10 +29,21 @@
 #include "utilities/compilerWarnings.hpp"
 #include "utilities/macros.hpp"
 
 #include <stddef.h>
 
+// ShowRegistersOnAssert support (for now Linux only)
+#if defined(LINUX) && !defined(ZERO)
+#define CAN_SHOW_REGISTERS_ON_ASSERT
+extern void* volatile g_assert_poison;
+#define TOUCH_ASSERT_POISON (*(char*)g_assert_poison = 'X');
+void initialize_assert_poison();
+bool handle_assert_poison_fault(const void* ucVoid, const void* faulting_address);
+#else
+#define TOUCH_ASSERT_POISON
+#endif // CAN_SHOW_REGISTERS_ON_ASSERT
+
 // assertions
 #ifndef ASSERT
 #define vmassert(p, ...)
 #else
 // Note: message says "assert" rather than "vmassert" for backward

@@ -40,10 +51,11 @@
 // Note: The signature is vmassert(p, format, ...), but the solaris
 // compiler can't handle an empty ellipsis in a macro without a warning.
 #define vmassert(p, ...)                                                       \
 do {                                                                           \
   if (!(p)) {                                                                  \
+    TOUCH_ASSERT_POISON                                                        \
     if (is_executing_unit_tests()) {                                           \
       report_assert_msg(__VA_ARGS__);                                          \
     }                                                                          \
     report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \
     BREAKPOINT;                                                                \

@@ -65,10 +77,11 @@
 // an extra arg and use strerror to convert it to a meaningful string
 // like "Invalid argument", "out of memory" etc
 #define vmassert_status(p, status, msg) \
 do {                                                                           \
   if (!(p)) {                                                                  \
+    TOUCH_ASSERT_POISON                                                        \
     report_vm_status_error(__FILE__, __LINE__, "assert(" #p ") failed",        \
                            status, msg);                                       \
     BREAKPOINT;                                                                \
   }                                                                            \
 } while (0)

@@ -81,17 +94,19 @@
 // cheap tests that catch errors that would otherwise be hard to find.
 // guarantee is also used for Verify options.
 #define guarantee(p, ...)                                                         \
 do {                                                                              \
   if (!(p)) {                                                                     \
+    TOUCH_ASSERT_POISON                                                        \
     report_vm_error(__FILE__, __LINE__, "guarantee(" #p ") failed", __VA_ARGS__); \
     BREAKPOINT;                                                                   \
   }                                                                               \
 } while (0)
 
 #define fatal(...)                                                                \
 do {                                                                              \
+  TOUCH_ASSERT_POISON                                                             \
   report_fatal(__FILE__, __LINE__, __VA_ARGS__);                                  \
   BREAKPOINT;                                                                     \
 } while (0)
 
 // out of memory

@@ -101,22 +116,25 @@
   BREAKPOINT;                                                                     \
 } while (0)
 
 #define ShouldNotCallThis()                                                       \
 do {                                                                              \
+  TOUCH_ASSERT_POISON                                                             \
   report_should_not_call(__FILE__, __LINE__);                                     \
   BREAKPOINT;                                                                     \
 } while (0)
 
 #define ShouldNotReachHere()                                                      \
 do {                                                                              \
+  TOUCH_ASSERT_POISON                                                             \
   report_should_not_reach_here(__FILE__, __LINE__);                               \
   BREAKPOINT;                                                                     \
 } while (0)
 
 #define Unimplemented()                                                           \
 do {                                                                              \
+  TOUCH_ASSERT_POISON                                                             \
   report_unimplemented(__FILE__, __LINE__);                                       \
   BREAKPOINT;                                                                     \
 } while (0)
 
 #define Untested(msg)                                                             \
< prev index next >