diff src/share/vm/utilities/debug.hpp @ 6999:679e6584c177

added ScopedDebugValue to add values of interest to hs_err crash logs
author Doug Simon <doug.simon@oracle.com>
date Wed, 21 Nov 2012 19:23:43 +0100
parents da91efe96a93
children b8f261ba79c6 96a337d307bd
line wrap: on
line diff
--- a/src/share/vm/utilities/debug.hpp	Tue Nov 20 22:50:44 2012 +0100
+++ b/src/share/vm/utilities/debug.hpp	Wed Nov 21 19:23:43 2012 +0100
@@ -30,6 +30,35 @@
 
 #include <stdarg.h>
 
+#ifdef GRAAL
+// Scopes a value that may be of interest in a crash log.
+class DebugScopedValue {
+protected:
+  DebugScopedValue *_parent;
+  const char* _file;
+  int _line;
+public:
+  DebugScopedValue(const char* file, int line);
+  ~DebugScopedValue();
+  void print(outputStream* st);
+  virtual void print_on(outputStream* st) = 0;
+  DebugScopedValue* parent() { return _parent; }
+};
+
+class DebugScopedScalar : DebugScopedValue {
+private:
+  void* _value;
+public:
+  DebugScopedScalar(const char* file, int line, void* v) : DebugScopedValue(file, line), _value(v) {}
+  void print_on(outputStream* st);
+};
+#define DS_SCALAR(val) DebugScopedScalar __dss__(__FILE__, __LINE__, (void*) val)
+#define DS_SCALAR1(name, val) DebugScopedScalar name(__FILE__, __LINE__, (void*) val)
+#else
+#define DS_SCALAR(name) do {} while (0)
+#define DS_SCALAR1(name, val) do {} while (0)
+#endif
+
 // Simple class to format the ctor arguments into a fixed-sized buffer.
 class FormatBufferBase {
  protected: