Mon, 13 Feb 2012 06:24:44 -0800
Merge
1.1 --- a/agent/src/os/linux/Makefile Fri Feb 10 11:46:20 2012 -0800 1.2 +++ b/agent/src/os/linux/Makefile Mon Feb 13 06:24:44 2012 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 # 1.5 -# Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved. 1.6 +# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 1.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 # 1.9 # This code is free software; you can redistribute it and/or modify it 1.10 @@ -40,7 +40,7 @@ 1.11 1.12 LIBS = -lthread_db 1.13 1.14 -CFLAGS = -c -fPIC -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES) 1.15 +CFLAGS = -c -fPIC -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES) -D_FILE_OFFSET_BITS=64 1.16 1.17 LIBSA = $(ARCH)/libsaproc.so 1.18
2.1 --- a/agent/src/os/linux/libproc_impl.c Fri Feb 10 11:46:20 2012 -0800 2.2 +++ b/agent/src/os/linux/libproc_impl.c Mon Feb 13 06:24:44 2012 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -50,10 +50,6 @@ 2.11 char alt_path[PATH_MAX + 1]; 2.12 2.13 init_alt_root(); 2.14 - fd = open(name, O_RDONLY); 2.15 - if (fd >= 0) { 2.16 - return fd; 2.17 - } 2.18 2.19 if (alt_root_len > 0) { 2.20 strcpy(alt_path, alt_root); 2.21 @@ -73,6 +69,11 @@ 2.22 return fd; 2.23 } 2.24 } 2.25 + } else { 2.26 + fd = open(name, O_RDONLY); 2.27 + if (fd >= 0) { 2.28 + return fd; 2.29 + } 2.30 } 2.31 2.32 return -1;
3.1 --- a/make/linux/makefiles/saproc.make Fri Feb 10 11:46:20 2012 -0800 3.2 +++ b/make/linux/makefiles/saproc.make Mon Feb 13 06:24:44 2012 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 # 3.5 -# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3.6 +# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 # 3.9 # This code is free software; you can redistribute it and/or modify it 3.10 @@ -75,6 +75,7 @@ 3.11 fi 3.12 @echo Making SA debugger back-end... 3.13 $(QUIETLY) $(CC) -D$(BUILDARCH) -D_GNU_SOURCE \ 3.14 + -D_FILE_OFFSET_BITS=64 \ 3.15 $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ 3.16 -I$(SASRCDIR) \ 3.17 -I$(GENERATED) \
4.1 --- a/src/os/bsd/vm/decoder_machO.hpp Fri Feb 10 11:46:20 2012 -0800 4.2 +++ b/src/os/bsd/vm/decoder_machO.hpp Mon Feb 13 06:24:44 2012 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -29,8 +29,9 @@ 4.11 4.12 #include "utilities/decoder.hpp" 4.13 4.14 -// Just a placehold for now 4.15 -class MachODecoder: public NullDecoder { 4.16 +// Just a placehold for now, a real implementation should derive 4.17 +// from AbstractDecoder 4.18 +class MachODecoder : public NullDecoder { 4.19 public: 4.20 MachODecoder() { } 4.21 ~MachODecoder() { }
5.1 --- a/src/os/windows/vm/decoder_windows.hpp Fri Feb 10 11:46:20 2012 -0800 5.2 +++ b/src/os/windows/vm/decoder_windows.hpp Mon Feb 13 06:24:44 2012 -0800 5.3 @@ -36,7 +36,7 @@ 5.4 typedef BOOL (WINAPI *pfn_SymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64); 5.5 typedef DWORD (WINAPI *pfn_UndecorateSymbolName)(const char*, char*, DWORD, DWORD); 5.6 5.7 -class WindowsDecoder: public NullDecoder { 5.8 +class WindowsDecoder : public AbstractDecoder { 5.9 5.10 public: 5.11 WindowsDecoder();
6.1 --- a/src/share/vm/classfile/vmSymbols.hpp Fri Feb 10 11:46:20 2012 -0800 6.2 +++ b/src/share/vm/classfile/vmSymbols.hpp Mon Feb 13 06:24:44 2012 -0800 6.3 @@ -284,6 +284,7 @@ 6.4 template(run_method_name, "run") \ 6.5 template(exit_method_name, "exit") \ 6.6 template(add_method_name, "add") \ 6.7 + template(remove_method_name, "remove") \ 6.8 template(parent_name, "parent") \ 6.9 template(threads_name, "threads") \ 6.10 template(groups_name, "groups") \
7.1 --- a/src/share/vm/utilities/decoder.cpp Fri Feb 10 11:46:20 2012 -0800 7.2 +++ b/src/share/vm/utilities/decoder.cpp Mon Feb 13 06:24:44 2012 -0800 7.3 @@ -25,7 +25,9 @@ 7.4 #include "precompiled.hpp" 7.5 #include "prims/jvm.h" 7.6 #include "runtime/mutexLocker.hpp" 7.7 +#include "runtime/os.hpp" 7.8 #include "utilities/decoder.hpp" 7.9 +#include "utilities/vmError.hpp" 7.10 7.11 #if defined(_WINDOWS) 7.12 #include "decoder_windows.hpp" 7.13 @@ -35,74 +37,94 @@ 7.14 #include "decoder_elf.hpp" 7.15 #endif 7.16 7.17 -NullDecoder* Decoder::_decoder = NULL; 7.18 -NullDecoder Decoder::_do_nothing_decoder; 7.19 -Mutex* Decoder::_decoder_lock = new Mutex(Mutex::safepoint, 7.20 - "DecoderLock"); 7.21 +AbstractDecoder* Decoder::_shared_decoder = NULL; 7.22 +AbstractDecoder* Decoder::_error_handler_decoder = NULL; 7.23 +NullDecoder Decoder::_do_nothing_decoder; 7.24 +Mutex* Decoder::_shared_decoder_lock = new Mutex(Mutex::native, 7.25 + "SharedDecoderLock"); 7.26 7.27 -// _decoder_lock should already acquired before enter this method 7.28 -NullDecoder* Decoder::get_decoder() { 7.29 - assert(_decoder_lock != NULL && _decoder_lock->owned_by_self(), 7.30 +AbstractDecoder* Decoder::get_shared_instance() { 7.31 + assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(), 7.32 "Require DecoderLock to enter"); 7.33 7.34 - if (_decoder != NULL) { 7.35 - return _decoder; 7.36 + if (_shared_decoder == NULL) { 7.37 + _shared_decoder = create_decoder(); 7.38 } 7.39 + return _shared_decoder; 7.40 +} 7.41 7.42 - // Decoder is a secondary service. Although, it is good to have, 7.43 - // but we can live without it. 7.44 +AbstractDecoder* Decoder::get_error_handler_instance() { 7.45 + if (_error_handler_decoder == NULL) { 7.46 + _error_handler_decoder = create_decoder(); 7.47 + } 7.48 + return _error_handler_decoder; 7.49 +} 7.50 + 7.51 + 7.52 +AbstractDecoder* Decoder::create_decoder() { 7.53 + AbstractDecoder* decoder; 7.54 #if defined(_WINDOWS) 7.55 - _decoder = new (std::nothrow) WindowsDecoder(); 7.56 + decoder = new (std::nothrow) WindowsDecoder(); 7.57 #elif defined (__APPLE__) 7.58 - _decoder = new (std::nothrow)MachODecoder(); 7.59 + decoder = new (std::nothrow)MachODecoder(); 7.60 #else 7.61 - _decoder = new (std::nothrow)ElfDecoder(); 7.62 + decoder = new (std::nothrow)ElfDecoder(); 7.63 #endif 7.64 7.65 - if (_decoder == NULL || _decoder->has_error()) { 7.66 - if (_decoder != NULL) { 7.67 - delete _decoder; 7.68 + if (decoder == NULL || decoder->has_error()) { 7.69 + if (decoder != NULL) { 7.70 + delete decoder; 7.71 } 7.72 - _decoder = &_do_nothing_decoder; 7.73 + decoder = &_do_nothing_decoder; 7.74 } 7.75 - return _decoder; 7.76 + return decoder; 7.77 } 7.78 7.79 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath) { 7.80 - assert(_decoder_lock != NULL, "Just check"); 7.81 - MutexLockerEx locker(_decoder_lock, true); 7.82 - NullDecoder* decoder = get_decoder(); 7.83 + assert(_shared_decoder_lock != NULL, "Just check"); 7.84 + bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; 7.85 + MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); 7.86 + AbstractDecoder* decoder = error_handling_thread ? 7.87 + get_error_handler_instance(): get_shared_instance(); 7.88 assert(decoder != NULL, "null decoder"); 7.89 7.90 return decoder->decode(addr, buf, buflen, offset, modulepath); 7.91 } 7.92 7.93 bool Decoder::demangle(const char* symbol, char* buf, int buflen) { 7.94 - assert(_decoder_lock != NULL, "Just check"); 7.95 - MutexLockerEx locker(_decoder_lock, true); 7.96 - NullDecoder* decoder = get_decoder(); 7.97 + assert(_shared_decoder_lock != NULL, "Just check"); 7.98 + bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; 7.99 + MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); 7.100 + AbstractDecoder* decoder = error_handling_thread ? 7.101 + get_error_handler_instance(): get_shared_instance(); 7.102 assert(decoder != NULL, "null decoder"); 7.103 return decoder->demangle(symbol, buf, buflen); 7.104 } 7.105 7.106 bool Decoder::can_decode_C_frame_in_vm() { 7.107 - assert(_decoder_lock != NULL, "Just check"); 7.108 - MutexLockerEx locker(_decoder_lock, true); 7.109 - NullDecoder* decoder = get_decoder(); 7.110 + assert(_shared_decoder_lock != NULL, "Just check"); 7.111 + bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; 7.112 + MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); 7.113 + AbstractDecoder* decoder = error_handling_thread ? 7.114 + get_error_handler_instance(): get_shared_instance(); 7.115 assert(decoder != NULL, "null decoder"); 7.116 return decoder->can_decode_C_frame_in_vm(); 7.117 } 7.118 7.119 -// shutdown real decoder and replace it with 7.120 -// _do_nothing_decoder 7.121 +/* 7.122 + * Shutdown shared decoder and replace it with 7.123 + * _do_nothing_decoder. Do nothing with error handler 7.124 + * instance, since the JVM is going down. 7.125 + */ 7.126 void Decoder::shutdown() { 7.127 - assert(_decoder_lock != NULL, "Just check"); 7.128 - MutexLockerEx locker(_decoder_lock, true); 7.129 + assert(_shared_decoder_lock != NULL, "Just check"); 7.130 + MutexLockerEx locker(_shared_decoder_lock, true); 7.131 7.132 - if (_decoder != NULL && _decoder != &_do_nothing_decoder) { 7.133 - delete _decoder; 7.134 + if (_shared_decoder != NULL && 7.135 + _shared_decoder != &_do_nothing_decoder) { 7.136 + delete _shared_decoder; 7.137 } 7.138 7.139 - _decoder = &_do_nothing_decoder; 7.140 + _shared_decoder = &_do_nothing_decoder; 7.141 } 7.142
8.1 --- a/src/share/vm/utilities/decoder.hpp Fri Feb 10 11:46:20 2012 -0800 8.2 +++ b/src/share/vm/utilities/decoder.hpp Mon Feb 13 06:24:44 2012 -0800 8.3 @@ -1,5 +1,5 @@ 8.4 /* 8.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 8.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 8.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 * 8.9 * This code is free software; you can redistribute it and/or modify it 8.10 @@ -29,7 +29,7 @@ 8.11 #include "memory/allocation.hpp" 8.12 #include "runtime/mutex.hpp" 8.13 8.14 -class NullDecoder: public CHeapObj { 8.15 +class AbstractDecoder : public CHeapObj { 8.16 public: 8.17 // status code for decoding native C frame 8.18 enum decoder_status { 8.19 @@ -43,6 +43,34 @@ 8.20 helper_init_error // SymInitialize failed (Windows only) 8.21 }; 8.22 8.23 + // decode an pc address to corresponding function name and an offset from the beginning of 8.24 + // the function 8.25 + virtual bool decode(address pc, char* buf, int buflen, int* offset, 8.26 + const char* modulepath = NULL) = 0; 8.27 + // demangle a C++ symbol 8.28 + virtual bool demangle(const char* symbol, char* buf, int buflen) = 0; 8.29 + // if the decoder can decode symbols in vm 8.30 + virtual bool can_decode_C_frame_in_vm() const = 0; 8.31 + 8.32 + virtual decoder_status status() const { 8.33 + return _decoder_status; 8.34 + } 8.35 + 8.36 + virtual bool has_error() const { 8.37 + return is_error(_decoder_status); 8.38 + } 8.39 + 8.40 + static bool is_error(decoder_status status) { 8.41 + return (status > 0); 8.42 + } 8.43 + 8.44 +protected: 8.45 + decoder_status _decoder_status; 8.46 +}; 8.47 + 8.48 +// Do nothing decoder 8.49 +class NullDecoder : public AbstractDecoder { 8.50 +public: 8.51 NullDecoder() { 8.52 _decoder_status = not_available; 8.53 } 8.54 @@ -61,40 +89,34 @@ 8.55 virtual bool can_decode_C_frame_in_vm() const { 8.56 return false; 8.57 } 8.58 - 8.59 - virtual decoder_status status() const { 8.60 - return _decoder_status; 8.61 - } 8.62 - 8.63 - virtual bool has_error() const { 8.64 - return is_error(_decoder_status); 8.65 - } 8.66 - 8.67 - static bool is_error(decoder_status status) { 8.68 - return (status > 0); 8.69 - } 8.70 - 8.71 -protected: 8.72 - decoder_status _decoder_status; 8.73 }; 8.74 8.75 8.76 -class Decoder: AllStatic { 8.77 +class Decoder : AllStatic { 8.78 public: 8.79 static bool decode(address pc, char* buf, int buflen, int* offset, const char* modulepath = NULL); 8.80 static bool demangle(const char* symbol, char* buf, int buflen); 8.81 static bool can_decode_C_frame_in_vm(); 8.82 8.83 + // shutdown shared instance 8.84 static void shutdown(); 8.85 protected: 8.86 - static NullDecoder* get_decoder(); 8.87 + // shared decoder instance, _shared_instance_lock is needed 8.88 + static AbstractDecoder* get_shared_instance(); 8.89 + // a private instance for error handler. Error handler can be 8.90 + // triggered almost everywhere, including signal handler, where 8.91 + // no lock can be taken. So the shared decoder can not be used 8.92 + // in this scenario. 8.93 + static AbstractDecoder* get_error_handler_instance(); 8.94 8.95 + static AbstractDecoder* create_decoder(); 8.96 private: 8.97 - static NullDecoder* _decoder; 8.98 - static NullDecoder _do_nothing_decoder; 8.99 + static AbstractDecoder* _shared_decoder; 8.100 + static AbstractDecoder* _error_handler_decoder; 8.101 + static NullDecoder _do_nothing_decoder; 8.102 8.103 protected: 8.104 - static Mutex* _decoder_lock; 8.105 + static Mutex* _shared_decoder_lock; 8.106 }; 8.107 8.108 #endif // SHARE_VM_UTILITIES_DECODER_HPP
9.1 --- a/src/share/vm/utilities/decoder_elf.hpp Fri Feb 10 11:46:20 2012 -0800 9.2 +++ b/src/share/vm/utilities/decoder_elf.hpp Mon Feb 13 06:24:44 2012 -0800 9.3 @@ -1,5 +1,5 @@ 9.4 /* 9.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 9.6 + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 9.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.8 * 9.9 * This code is free software; you can redistribute it and/or modify it 9.10 @@ -30,7 +30,7 @@ 9.11 #include "utilities/decoder.hpp" 9.12 #include "utilities/elfFile.hpp" 9.13 9.14 -class ElfDecoder: public NullDecoder { 9.15 +class ElfDecoder : public AbstractDecoder { 9.16 9.17 public: 9.18 ElfDecoder() {
10.1 --- a/src/share/vm/utilities/preserveException.cpp Fri Feb 10 11:46:20 2012 -0800 10.2 +++ b/src/share/vm/utilities/preserveException.cpp Mon Feb 13 06:24:44 2012 -0800 10.3 @@ -32,9 +32,9 @@ 10.4 thread = Thread::current(); 10.5 _thread = thread; 10.6 _preserved_exception_oop = Handle(thread, _thread->pending_exception()); 10.7 - _thread->clear_pending_exception(); // Needed to avoid infinite recursion 10.8 _preserved_exception_line = _thread->exception_line(); 10.9 _preserved_exception_file = _thread->exception_file(); 10.10 + _thread->clear_pending_exception(); // Needed to avoid infinite recursion 10.11 } 10.12 10.13
11.1 --- a/src/share/vm/utilities/vmError.hpp Fri Feb 10 11:46:20 2012 -0800 11.2 +++ b/src/share/vm/utilities/vmError.hpp Mon Feb 13 06:24:44 2012 -0800 11.3 @@ -27,11 +27,12 @@ 11.4 11.5 #include "utilities/globalDefinitions.hpp" 11.6 11.7 - 11.8 +class Decoder; 11.9 class VM_ReportJavaOutOfMemory; 11.10 11.11 class VMError : public StackObj { 11.12 friend class VM_ReportJavaOutOfMemory; 11.13 + friend class Decoder; 11.14 11.15 enum ErrorType { 11.16 internal_error = 0xe0000000,