< prev index next >

src/hotspot/share/utilities/nativeCallStack.cpp

Print this page




  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 "runtime/os.hpp"
  27 #include "utilities/decoder.hpp"
  28 #include "utilities/globalDefinitions.hpp"
  29 #include "utilities/nativeCallStack.hpp"
  30 
  31 const NativeCallStack NativeCallStack::EMPTY_STACK(0, false);
  32 
  33 NativeCallStack::NativeCallStack(int toSkip, bool fillStack) :
  34   _hash_value(0) {
  35 
  36   if (fillStack) {
  37     // We need to skip the NativeCallStack::NativeCallStack frame if a tail call is NOT used
  38     // to call os::get_native_stack. A tail call is used if _NMT_NOINLINE_ is not defined
  39     // (which means this is not a slowdebug build), and we are on 64-bit (except Windows).
  40     // This is not necessarily a rule, but what has been obvserved to date.
  41 #if (defined(_NMT_NOINLINE_) || defined(_WINDOWS) || !defined(_LP64))
  42     // Not a tail call.
  43     toSkip++;
  44 #if (defined(_NMT_NOINLINE_) && defined(BSD) && defined(_LP64))
  45     // Mac OS X slowdebug builds have this odd behavior where NativeCallStack::NativeCallStack
  46     // appears as two frames, so we need to skip an extra frame.
  47     toSkip++;
  48 #endif // Special-case for BSD.
  49 #endif // Not a tail call.
  50     os::get_native_stack(_stack, NMT_TrackingStackDepth, toSkip);
  51   } else {


 109     out->print("[BOOTSTRAP]");
 110   } else {
 111     for (int frame = 0; frame < NMT_TrackingStackDepth; frame ++) {
 112       pc = get_frame(frame);
 113       if (pc == NULL) break;
 114       // Print indent
 115       for (int index = 0; index < indent; index ++) out->print(" ");
 116       if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
 117         out->print("[" PTR_FORMAT "] %s+0x%x", p2i(pc), buf, offset);
 118       } else {
 119         out->print("[" PTR_FORMAT "]", p2i(pc));
 120       }
 121 
 122       if (Decoder::get_source_info(pc, buf, sizeof(buf), &line_no)) {
 123         out->print("  (%s:%d)", buf, line_no);
 124       }
 125       out->cr();
 126     }
 127   }
 128 }
 129 


  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 "runtime/os.hpp"
  27 #include "utilities/decoder.hpp"
  28 #include "utilities/globalDefinitions.hpp"
  29 #include "utilities/nativeCallStack.hpp"
  30 
  31 NativeCallStack NativeCallStack::EMPTY_STACK(0, false);
  32 
  33 NativeCallStack::NativeCallStack(int toSkip, bool fillStack) :
  34   _hash_value(0) {
  35 
  36   if (fillStack) {
  37     // We need to skip the NativeCallStack::NativeCallStack frame if a tail call is NOT used
  38     // to call os::get_native_stack. A tail call is used if _NMT_NOINLINE_ is not defined
  39     // (which means this is not a slowdebug build), and we are on 64-bit (except Windows).
  40     // This is not necessarily a rule, but what has been obvserved to date.
  41 #if (defined(_NMT_NOINLINE_) || defined(_WINDOWS) || !defined(_LP64))
  42     // Not a tail call.
  43     toSkip++;
  44 #if (defined(_NMT_NOINLINE_) && defined(BSD) && defined(_LP64))
  45     // Mac OS X slowdebug builds have this odd behavior where NativeCallStack::NativeCallStack
  46     // appears as two frames, so we need to skip an extra frame.
  47     toSkip++;
  48 #endif // Special-case for BSD.
  49 #endif // Not a tail call.
  50     os::get_native_stack(_stack, NMT_TrackingStackDepth, toSkip);
  51   } else {


 109     out->print("[BOOTSTRAP]");
 110   } else {
 111     for (int frame = 0; frame < NMT_TrackingStackDepth; frame ++) {
 112       pc = get_frame(frame);
 113       if (pc == NULL) break;
 114       // Print indent
 115       for (int index = 0; index < indent; index ++) out->print(" ");
 116       if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
 117         out->print("[" PTR_FORMAT "] %s+0x%x", p2i(pc), buf, offset);
 118       } else {
 119         out->print("[" PTR_FORMAT "]", p2i(pc));
 120       }
 121 
 122       if (Decoder::get_source_info(pc, buf, sizeof(buf), &line_no)) {
 123         out->print("  (%s:%d)", buf, line_no);
 124       }
 125       out->cr();
 126     }
 127   }
 128 }

< prev index next >