Mercurial > hg > graal-compiler
diff src/share/vm/utilities/debug.cpp @ 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 | 4202510ee0fe |
children | 291ffc492eb6 |
line wrap: on
line diff
--- a/src/share/vm/utilities/debug.cpp Tue Nov 20 22:50:44 2012 +0100 +++ b/src/share/vm/utilities/debug.cpp Wed Nov 21 19:23:43 2012 +0100 @@ -860,3 +860,37 @@ #endif #endif // !PRODUCT + +#ifdef GRAAL + +DebugScopedValue::DebugScopedValue(const char* file, int line) { + _file = file; + _line = line; + Thread* thread = Thread::current(); + if (thread != NULL && thread->is_Java_thread()) { + JavaThread* javaThread = (JavaThread*) thread; + _parent = javaThread->debug_scope(); + javaThread->set_debug_scope(this); + } else { + _parent = NULL; + } +} + +DebugScopedValue::~DebugScopedValue() { + Thread* thread = Thread::current(); + if (thread != NULL && thread->is_Java_thread()) { + JavaThread* javaThread = (JavaThread*) thread; + javaThread->set_debug_scope(_parent); + _parent = NULL; + } +} + +void DebugScopedValue::print(outputStream* st) { + st->print("%s:%d: ", _file, _line); + print_on(st); +} + +void DebugScopedScalar::print_on(outputStream* st) { + st->print("int: %d, char: %c, long: %ld, hex: %p", _value, _value, _value, _value); +} +#endif