< prev index next >

src/share/vm/utilities/decoder.cpp

Print this page
rev 13529 : 8185712: [windows] Improve native symbol decoder
Reviewed-by:


  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 


 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 


 143 }
 144 
 145 /*
 146  * Shutdown shared decoder and replace it with
 147  * _do_nothing_decoder. Do nothing with error handler
 148  * instance, since the JVM is going down.
 149  */
 150 void Decoder::shutdown() {
 151   assert(_shared_decoder_lock != NULL, "Just check");
 152   MutexLockerEx locker(_shared_decoder_lock, true);
 153 
 154   if (_shared_decoder != NULL &&
 155     _shared_decoder != &_do_nothing_decoder) {
 156     delete _shared_decoder;
 157   }
 158 
 159   _shared_decoder = &_do_nothing_decoder;
 160 }
 161 
 162 void Decoder::print_state_on(outputStream* st) {



 163 }
 164 
 165 bool Decoder::get_source_info(address pc, char* buf, size_t buflen, int* line) {
 166   return false;
 167 }
 168 
 169 #endif // !_WINDOWS
 170 
< prev index next >