< prev index next >

src/share/vm/utilities/decoder.cpp

Print this page
rev 13549 : 8185712: [windows] Improve native symbol decoder
Reviewed-by: goetz, zgu


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "prims/jvm.h"
  27 #include "runtime/os.hpp"
  28 #include "utilities/decoder.hpp"
  29 #include "utilities/vmError.hpp"
  30 
  31 #if defined(_WINDOWS)
  32   #include "decoder_windows.hpp"
  33   #include "windbghelp.hpp"
  34 #elif defined(__APPLE__)
  35   #include "decoder_machO.hpp"
  36 #elif defined(AIX)
  37   #include "decoder_aix.hpp"
  38 #else
  39   #include "decoder_elf.hpp"
  40 #endif
  41 
  42 AbstractDecoder*  Decoder::_shared_decoder = NULL;
  43 AbstractDecoder*  Decoder::_error_handler_decoder = NULL;
  44 NullDecoder       Decoder::_do_nothing_decoder;
  45 Mutex*            Decoder::_shared_decoder_lock = new Mutex(Mutex::native,
  46                                 "SharedDecoderLock",
  47                                 false,
  48                                 Monitor::_safepoint_check_never);
  49 
  50 AbstractDecoder* Decoder::get_shared_instance() {
  51   assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(),
  52     "Require DecoderLock to enter");
  53 
  54   if (_shared_decoder == NULL) {
  55     _shared_decoder = create_decoder();
  56   }
  57   return _shared_decoder;
  58 }
  59 
  60 AbstractDecoder* Decoder::get_error_handler_instance() {
  61   if (_error_handler_decoder == NULL) {
  62     _error_handler_decoder = create_decoder();
  63   }
  64   return _error_handler_decoder;
  65 }
  66 
  67 
  68 AbstractDecoder* Decoder::create_decoder() {
  69   AbstractDecoder* decoder;
  70 #if defined(_WINDOWS)
  71   decoder = new (std::nothrow) WindowsDecoder();
  72 #elif defined (__APPLE__)
  73   decoder = new (std::nothrow)MachODecoder();
  74 #elif defined(AIX)
  75   decoder = new (std::nothrow)AIXDecoder();
  76 #else
  77   decoder = new (std::nothrow)ElfDecoder();
  78 #endif
  79 
  80   if (decoder == NULL || decoder->has_error()) {
  81     if (decoder != NULL) {
  82       delete decoder;
  83     }
  84     decoder = &_do_nothing_decoder;
  85   }
  86   return decoder;
  87 }
  88 
  89 inline bool DecoderLocker::is_first_error_thread() {
  90   return (os::current_thread_id() == VMError::get_first_error_tid());
  91 }
  92 


 119   bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid;
 120   MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true);
 121   AbstractDecoder* decoder = error_handling_thread ?
 122     get_error_handler_instance(): get_shared_instance();
 123   assert(decoder != NULL, "null decoder");
 124 
 125   return decoder->decode(addr, buf, buflen, offset, base);
 126 }
 127 
 128 
 129 bool Decoder::demangle(const char* symbol, char* buf, int buflen) {
 130   assert(_shared_decoder_lock != NULL, "Just check");
 131   bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid;
 132   MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true);
 133   AbstractDecoder* decoder = error_handling_thread ?
 134     get_error_handler_instance(): get_shared_instance();
 135   assert(decoder != NULL, "null decoder");
 136   return decoder->demangle(symbol, buf, buflen);
 137 }
 138 
 139 bool Decoder::can_decode_C_frame_in_vm() {
 140   assert(_shared_decoder_lock != NULL, "Just check");
 141   bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid;
 142   MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true);
 143   AbstractDecoder* decoder = error_handling_thread ?
 144     get_error_handler_instance(): get_shared_instance();
 145   assert(decoder != NULL, "null decoder");
 146   return decoder->can_decode_C_frame_in_vm();
 147 }
 148 
 149 /*
 150  * Shutdown shared decoder and replace it with
 151  * _do_nothing_decoder. Do nothing with error handler
 152  * instance, since the JVM is going down.
 153  */
 154 void Decoder::shutdown() {
 155   assert(_shared_decoder_lock != NULL, "Just check");
 156   MutexLockerEx locker(_shared_decoder_lock, true);
 157 
 158   if (_shared_decoder != NULL &&
 159     _shared_decoder != &_do_nothing_decoder) {
 160     delete _shared_decoder;
 161   }
 162 
 163   _shared_decoder = &_do_nothing_decoder;
 164 }
 165 
 166 void Decoder::print_state_on(outputStream* st) {
 167 #ifdef _WINDOWS
 168   WindowsDbgHelp::print_state_on(st);
 169 #endif
 170 }
 171 


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "prims/jvm.h"
  27 #include "runtime/os.hpp"
  28 #include "utilities/decoder.hpp"
  29 #include "utilities/vmError.hpp"
  30 
  31 #ifndef _WINDOWS
  32 #if defined(__APPLE__)


  33   #include "decoder_machO.hpp"
  34 #elif defined(AIX)
  35   #include "decoder_aix.hpp"
  36 #else
  37   #include "decoder_elf.hpp"
  38 #endif
  39 
  40 AbstractDecoder*  Decoder::_shared_decoder = NULL;
  41 AbstractDecoder*  Decoder::_error_handler_decoder = NULL;
  42 NullDecoder       Decoder::_do_nothing_decoder;
  43 Mutex*            Decoder::_shared_decoder_lock = new Mutex(Mutex::native,
  44                                 "SharedDecoderLock",
  45                                 false,
  46                                 Monitor::_safepoint_check_never);
  47 
  48 AbstractDecoder* Decoder::get_shared_instance() {
  49   assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(),
  50     "Require DecoderLock to enter");
  51 
  52   if (_shared_decoder == NULL) {
  53     _shared_decoder = create_decoder();
  54   }
  55   return _shared_decoder;
  56 }
  57 
  58 AbstractDecoder* Decoder::get_error_handler_instance() {
  59   if (_error_handler_decoder == NULL) {
  60     _error_handler_decoder = create_decoder();
  61   }
  62   return _error_handler_decoder;
  63 }
  64 
  65 
  66 AbstractDecoder* Decoder::create_decoder() {
  67   AbstractDecoder* decoder;
  68 #if defined (__APPLE__)


  69   decoder = new (std::nothrow)MachODecoder();
  70 #elif defined(AIX)
  71   decoder = new (std::nothrow)AIXDecoder();
  72 #else
  73   decoder = new (std::nothrow)ElfDecoder();
  74 #endif
  75 
  76   if (decoder == NULL || decoder->has_error()) {
  77     if (decoder != NULL) {
  78       delete decoder;
  79     }
  80     decoder = &_do_nothing_decoder;
  81   }
  82   return decoder;
  83 }
  84 
  85 inline bool DecoderLocker::is_first_error_thread() {
  86   return (os::current_thread_id() == VMError::get_first_error_tid());
  87 }
  88 


 115   bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid;
 116   MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true);
 117   AbstractDecoder* decoder = error_handling_thread ?
 118     get_error_handler_instance(): get_shared_instance();
 119   assert(decoder != NULL, "null decoder");
 120 
 121   return decoder->decode(addr, buf, buflen, offset, base);
 122 }
 123 
 124 
 125 bool Decoder::demangle(const char* symbol, char* buf, int buflen) {
 126   assert(_shared_decoder_lock != NULL, "Just check");
 127   bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid;
 128   MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true);
 129   AbstractDecoder* decoder = error_handling_thread ?
 130     get_error_handler_instance(): get_shared_instance();
 131   assert(decoder != NULL, "null decoder");
 132   return decoder->demangle(symbol, buf, buflen);
 133 }
 134 
 135 void Decoder::print_state_on(outputStream* st) {







 136 }
 137 
 138 bool Decoder::get_source_info(address pc, char* buf, size_t buflen, int* line) {
 139   return false;













 140 }
 141 
 142 #endif // !_WINDOWS




 143 
< prev index next >