< prev index next >

test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java

Print this page
rev 59103 : imported patch hotspot


  52 public class CheckForProperDetailStackTrace {
  53 
  54     /* The stack trace we look for by default. Note that :: has been replaced by .*
  55        to make sure it matches even if the symbol is not unmangled.
  56     */
  57     private static String stackTraceDefault =
  58         ".*Hashtable.*allocate_new_entry.*\n" +
  59         ".*ModuleEntryTable.*new_entry.*\n" +
  60         ".*ModuleEntryTable.*locked_create_entry.*\n" +
  61         ".*Modules.*define_module.*\n";
  62 
  63     /* Alternate stacktrace that we check if the default fails, because
  64        new_entry may be inlined.
  65     */
  66     private static String stackTraceAlternate =
  67         ".*Hashtable.*allocate_new_entry.*\n" +
  68         ".*ModuleEntryTable.*locked_create_entry.*\n" +
  69         ".*Modules.*define_module.*\n" +
  70         ".*JVM_DefineModule.*\n";
  71 
  72     /* The stack trace we look for on AIX, Solaris and Windows slowdebug builds.
  73        ALWAYSINLINE is only a hint and is ignored for AllocateHeap on the
  74        aforementioned platforms. When that happens allocate_new_entry is
  75        inlined instead.
  76     */
  77     private static String stackTraceAllocateHeap =
  78         ".*AllocateHeap.*\n" +
  79         ".*ModuleEntryTable.*new_entry.*\n" +
  80         ".*ModuleEntryTable.*locked_create_entry.*\n" +
  81         ".*Modules.*define_module.*\n";
  82 
  83     /* A symbol that should always be present in NMT detail output. */
  84     private static String expectedSymbol = "locked_create_entry";
  85 
  86     public static void main(String args[]) throws Exception {
  87         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  88             "-XX:+UnlockDiagnosticVMOptions",
  89             "-XX:NativeMemoryTracking=detail",
  90             "-XX:+PrintNMTStatistics",
  91             "-version");
  92         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  93 
  94         output.shouldHaveExitValue(0);
  95 
  96         // We should never see either of these frames because they are supposed to be skipped.
  97         output.shouldNotContain("NativeCallStack::NativeCallStack");
  98         output.shouldNotContain("os::get_native_stack");
  99 
 100         // AllocateHeap shouldn't be in the output because it is supposed to always be inlined.
 101         // We check for that here, but allow it for Aix, Solaris and Windows slowdebug builds
 102         // because the compiler ends up not inlining AllocateHeap.
 103         Boolean okToHaveAllocateHeap = Platform.isSlowDebugBuild() &&
 104                                        (Platform.isAix() || Platform.isSolaris() || Platform.isWindows());
 105         if (!okToHaveAllocateHeap) {
 106             output.shouldNotContain("AllocateHeap");
 107         }
 108 
 109         // See if we have any stack trace symbols in the output
 110         boolean hasSymbols = output.getStdout().contains(expectedSymbol) ||
 111                              output.getStderr().contains(expectedSymbol);
 112         if (!hasSymbols) {
 113             // It's ok for ARM not to have symbols, because it does not support NMT detail
 114             // when targeting thumb2. It's also ok for Windows not to have symbols, because
 115             // they are only available if the symbols file is included with the build.
 116             if (Platform.isWindows() || Platform.isARM()) {
 117                 return; // we are done
 118             }
 119             output.reportDiagnosticSummary();
 120             throw new RuntimeException("Expected symbol missing from output: " + expectedSymbol);
 121         }
 122 
 123         // Make sure the expected NMT detail stack trace is found
 124         System.out.println("Looking for a stack matching:");




  52 public class CheckForProperDetailStackTrace {
  53 
  54     /* The stack trace we look for by default. Note that :: has been replaced by .*
  55        to make sure it matches even if the symbol is not unmangled.
  56     */
  57     private static String stackTraceDefault =
  58         ".*Hashtable.*allocate_new_entry.*\n" +
  59         ".*ModuleEntryTable.*new_entry.*\n" +
  60         ".*ModuleEntryTable.*locked_create_entry.*\n" +
  61         ".*Modules.*define_module.*\n";
  62 
  63     /* Alternate stacktrace that we check if the default fails, because
  64        new_entry may be inlined.
  65     */
  66     private static String stackTraceAlternate =
  67         ".*Hashtable.*allocate_new_entry.*\n" +
  68         ".*ModuleEntryTable.*locked_create_entry.*\n" +
  69         ".*Modules.*define_module.*\n" +
  70         ".*JVM_DefineModule.*\n";
  71 
  72     /* The stack trace we look for on AIX and Windows slowdebug builds.
  73        ALWAYSINLINE is only a hint and is ignored for AllocateHeap on the
  74        aforementioned platforms. When that happens allocate_new_entry is
  75        inlined instead.
  76     */
  77     private static String stackTraceAllocateHeap =
  78         ".*AllocateHeap.*\n" +
  79         ".*ModuleEntryTable.*new_entry.*\n" +
  80         ".*ModuleEntryTable.*locked_create_entry.*\n" +
  81         ".*Modules.*define_module.*\n";
  82 
  83     /* A symbol that should always be present in NMT detail output. */
  84     private static String expectedSymbol = "locked_create_entry";
  85 
  86     public static void main(String args[]) throws Exception {
  87         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  88             "-XX:+UnlockDiagnosticVMOptions",
  89             "-XX:NativeMemoryTracking=detail",
  90             "-XX:+PrintNMTStatistics",
  91             "-version");
  92         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  93 
  94         output.shouldHaveExitValue(0);
  95 
  96         // We should never see either of these frames because they are supposed to be skipped.
  97         output.shouldNotContain("NativeCallStack::NativeCallStack");
  98         output.shouldNotContain("os::get_native_stack");
  99 
 100         // AllocateHeap shouldn't be in the output because it is supposed to always be inlined.
 101         // We check for that here, but allow it for Aix and Windows slowdebug builds
 102         // because the compiler ends up not inlining AllocateHeap.
 103         Boolean okToHaveAllocateHeap = Platform.isSlowDebugBuild() &&
 104                                        (Platform.isAix() || Platform.isWindows());
 105         if (!okToHaveAllocateHeap) {
 106             output.shouldNotContain("AllocateHeap");
 107         }
 108 
 109         // See if we have any stack trace symbols in the output
 110         boolean hasSymbols = output.getStdout().contains(expectedSymbol) ||
 111                              output.getStderr().contains(expectedSymbol);
 112         if (!hasSymbols) {
 113             // It's ok for ARM not to have symbols, because it does not support NMT detail
 114             // when targeting thumb2. It's also ok for Windows not to have symbols, because
 115             // they are only available if the symbols file is included with the build.
 116             if (Platform.isWindows() || Platform.isARM()) {
 117                 return; // we are done
 118             }
 119             output.reportDiagnosticSummary();
 120             throw new RuntimeException("Expected symbol missing from output: " + expectedSymbol);
 121         }
 122 
 123         // Make sure the expected NMT detail stack trace is found
 124         System.out.println("Looking for a stack matching:");


< prev index next >