< prev index next >

test/runtime/NMT/CheckForProperDetailStackTrace.java

Print this page
rev 11986 : 8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
Summary: Also add methods to check for slow/fastdebug to Platform.java.
Reviewed-by: simonis, cjplummer, dholmes


  40     /* The stack trace we look for by default. Note that :: has been replaced by .*
  41        to make sure it maches even if the symbol is not unmangled. */
  42     public static String stackTraceDefault =
  43         ".*ModuleEntryTable.*new_entry.*\n" +
  44         ".*ModuleEntryTable.*locked_create_entry_or_null.*\n" +
  45         ".*Modules.*define_module.*\n" +
  46         ".*JVM_DefineModule.*\n";
  47 
  48     /* The stack trace we look for on Solaris and Windows slowdebug builds. For some
  49        reason ALWAYSINLINE for AllocateHeap is ignored, so it appears in the stack strace. */
  50     public static String stackTraceAllocateHeap =
  51         ".*AllocateHeap.*\n" +
  52         ".*ModuleEntryTable.*new_entry.*\n" +
  53         ".*ModuleEntryTable.*locked_create_entry_or_null.*\n" +
  54         ".*Modules.*define_module.*\n";
  55 
  56     /* A symbol that should always be present in NMT detail output. */
  57     private static String expectedSymbol =
  58         "locked_create_entry_or_null";
  59 
  60     private static final String jdkDebug = System.getProperty("jdk.debug");
  61     private static boolean isSlowDebugBuild() {
  62         return (jdkDebug.toLowerCase().equals("slowdebug"));
  63     }
  64 
  65     public static void main(String args[]) throws Exception {
  66         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  67             "-XX:+UnlockDiagnosticVMOptions",
  68             "-XX:NativeMemoryTracking=detail",
  69             "-XX:+PrintNMTStatistics",
  70             "-version");
  71         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  72 
  73         output.shouldHaveExitValue(0);
  74 
  75         // We should never see either of these frames because they are supposed to be skipped. */
  76         output.shouldNotContain("NativeCallStack::NativeCallStack");
  77         output.shouldNotContain("os::get_native_stack");
  78 
  79         // AllocateHeap shouldn't be in the output because it is suppose to always be inlined.
  80         // We check for that here, but allow it for Windows and Solaris slowdebug builds because
  81         // the compiler ends up not inlining AllocateHeap.
  82         Boolean okToHaveAllocateHeap =
  83             isSlowDebugBuild() && (Platform.isSolaris() || Platform.isWindows());

  84         if (!okToHaveAllocateHeap) {
  85             output.shouldNotContain("AllocateHeap");
  86         }
  87 
  88         // See if we have any stack trace symbols in the output
  89         boolean hasSymbols =
  90             output.getStdout().contains(expectedSymbol) || output.getStderr().contains(expectedSymbol);
  91         if (!hasSymbols) {
  92             // It's ok for ARM not to have symbols, because it does not support NMT detail
  93             // when targeting thumb2. It's also ok for Windows not to have symbols, because
  94             // they are only available if the symbols file is included with the build.
  95             if (Platform.isWindows() || Platform.isARM()) {
  96                 return; // we are done
  97             }
  98             output.reportDiagnosticSummary();
  99             throw new RuntimeException("Expected symbol missing missing from output: " + expectedSymbol);
 100         }
 101 
 102         /* Make sure the expected NMT detail stack trace is found. */
 103         String expectedStackTrace =


  40     /* The stack trace we look for by default. Note that :: has been replaced by .*
  41        to make sure it maches even if the symbol is not unmangled. */
  42     public static String stackTraceDefault =
  43         ".*ModuleEntryTable.*new_entry.*\n" +
  44         ".*ModuleEntryTable.*locked_create_entry_or_null.*\n" +
  45         ".*Modules.*define_module.*\n" +
  46         ".*JVM_DefineModule.*\n";
  47 
  48     /* The stack trace we look for on Solaris and Windows slowdebug builds. For some
  49        reason ALWAYSINLINE for AllocateHeap is ignored, so it appears in the stack strace. */
  50     public static String stackTraceAllocateHeap =
  51         ".*AllocateHeap.*\n" +
  52         ".*ModuleEntryTable.*new_entry.*\n" +
  53         ".*ModuleEntryTable.*locked_create_entry_or_null.*\n" +
  54         ".*Modules.*define_module.*\n";
  55 
  56     /* A symbol that should always be present in NMT detail output. */
  57     private static String expectedSymbol =
  58         "locked_create_entry_or_null";
  59 





  60     public static void main(String args[]) throws Exception {
  61         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  62             "-XX:+UnlockDiagnosticVMOptions",
  63             "-XX:NativeMemoryTracking=detail",
  64             "-XX:+PrintNMTStatistics",
  65             "-version");
  66         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  67 
  68         output.shouldHaveExitValue(0);
  69 
  70         // We should never see either of these frames because they are supposed to be skipped. */
  71         output.shouldNotContain("NativeCallStack::NativeCallStack");
  72         output.shouldNotContain("os::get_native_stack");
  73 
  74         // AllocateHeap shouldn't be in the output because it is supposed to always be inlined.
  75         // We check for that here, but allow it for Aix, Solaris and Windows slowdebug builds
  76         // because the compiler ends up not inlining AllocateHeap.
  77         Boolean okToHaveAllocateHeap =
  78             Platform.isSlowDebugBuild() &&
  79             (Platform.isAix() || Platform.isSolaris() || Platform.isWindows());
  80         if (!okToHaveAllocateHeap) {
  81             output.shouldNotContain("AllocateHeap");
  82         }
  83 
  84         // See if we have any stack trace symbols in the output
  85         boolean hasSymbols =
  86             output.getStdout().contains(expectedSymbol) || output.getStderr().contains(expectedSymbol);
  87         if (!hasSymbols) {
  88             // It's ok for ARM not to have symbols, because it does not support NMT detail
  89             // when targeting thumb2. It's also ok for Windows not to have symbols, because
  90             // they are only available if the symbols file is included with the build.
  91             if (Platform.isWindows() || Platform.isARM()) {
  92                 return; // we are done
  93             }
  94             output.reportDiagnosticSummary();
  95             throw new RuntimeException("Expected symbol missing missing from output: " + expectedSymbol);
  96         }
  97 
  98         /* Make sure the expected NMT detail stack trace is found. */
  99         String expectedStackTrace =
< prev index next >