< prev index next >

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

Print this page

  1 /*
  2  * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 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  */

116         // We should never see either of these frames because they are supposed to be skipped.
117         output.shouldNotContain("NativeCallStack::NativeCallStack");
118         output.shouldNotContain("os::get_native_stack");
119 
120         // AllocateHeap shouldn't be in the output because it is supposed to always be inlined.
121         // We check for that here, but allow it for Aix and Windows slowdebug builds
122         // because the compiler ends up not inlining AllocateHeap.
123         Boolean okToHaveAllocateHeap = Platform.isSlowDebugBuild() &&
124                                        (Platform.isAix() || Platform.isWindows());
125         if (!okToHaveAllocateHeap) {
126             output.shouldNotContain("AllocateHeap");
127         }
128 
129         // See if we have any stack trace symbols in the output
130         boolean hasSymbols = output.getStdout().contains(expectedSymbol) ||
131                              output.getStderr().contains(expectedSymbol);
132         if (!hasSymbols) {
133             // It's ok for ARM not to have symbols, because it does not support NMT detail
134             // when targeting thumb2. It's also ok for Windows not to have symbols, because
135             // they are only available if the symbols file is included with the build.
136             if (Platform.isWindows() || Platform.isARM()) {
137                 return; // we are done
138             }
139             output.reportDiagnosticSummary();
140             throw new RuntimeException("Expected symbol missing from output: " + expectedSymbol);
141         }
142 
143         // Make sure the expected NMT detail stack trace is found
144         System.out.println("Looking for a stack matching:");
145         if (okToHaveAllocateHeap) {
146             System.out.print(stackTraceAllocateHeap);
147             if (stackTraceMatches(stackTraceAllocateHeap, output)) {
148                 return;
149             }
150         } else {
151             System.out.print(stackTraceDefault);
152             if (!stackTraceMatches(stackTraceDefault, output)) {
153                 System.out.println("Looking for alternate stack matching:");
154                 System.out.print(stackTraceAlternate);
155                 if (stackTraceMatches(stackTraceAlternate, output)) {
156                     return;

  1 /*
  2  * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 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  */

116         // We should never see either of these frames because they are supposed to be skipped.
117         output.shouldNotContain("NativeCallStack::NativeCallStack");
118         output.shouldNotContain("os::get_native_stack");
119 
120         // AllocateHeap shouldn't be in the output because it is supposed to always be inlined.
121         // We check for that here, but allow it for Aix and Windows slowdebug builds
122         // because the compiler ends up not inlining AllocateHeap.
123         Boolean okToHaveAllocateHeap = Platform.isSlowDebugBuild() &&
124                                        (Platform.isAix() || Platform.isWindows());
125         if (!okToHaveAllocateHeap) {
126             output.shouldNotContain("AllocateHeap");
127         }
128 
129         // See if we have any stack trace symbols in the output
130         boolean hasSymbols = output.getStdout().contains(expectedSymbol) ||
131                              output.getStderr().contains(expectedSymbol);
132         if (!hasSymbols) {
133             // It's ok for ARM not to have symbols, because it does not support NMT detail
134             // when targeting thumb2. It's also ok for Windows not to have symbols, because
135             // they are only available if the symbols file is included with the build.
136             if (Platform.isWindows() || Platform.isARM() || Platform.isRISCV64()) {
137                 return; // we are done
138             }
139             output.reportDiagnosticSummary();
140             throw new RuntimeException("Expected symbol missing from output: " + expectedSymbol);
141         }
142 
143         // Make sure the expected NMT detail stack trace is found
144         System.out.println("Looking for a stack matching:");
145         if (okToHaveAllocateHeap) {
146             System.out.print(stackTraceAllocateHeap);
147             if (stackTraceMatches(stackTraceAllocateHeap, output)) {
148                 return;
149             }
150         } else {
151             System.out.print(stackTraceDefault);
152             if (!stackTraceMatches(stackTraceDefault, output)) {
153                 System.out.println("Looking for alternate stack matching:");
154                 System.out.print(stackTraceAlternate);
155                 if (stackTraceMatches(stackTraceAlternate, output)) {
156                     return;
< prev index next >