Path: blob/master/test/hotspot/jtreg/runtime/ElfDecoder/TestElfDirectRead.java
40941 views
/*1* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 819337326* @summary Test reading ELF info direct from underlaying file27* @requires (os.family == "linux") & (os.arch != "ppc64")28* @modules java.base/jdk.internal.misc29* @library /test/lib30* @build sun.hotspot.WhiteBox31* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox32* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI33-XX:NativeMemoryTracking=detail TestElfDirectRead34*/3536// This test intentionally disables caching of Elf sections during symbol lookup37// with WhiteBox.disableElfSectionCache(). On platforms which do not use function38// descriptors but use instead plain function pointers this slows down the lookup just a39// little bit, because all the symbols from an Elf file are still read consecutively40// after one 'fseek()' call. But on platforms with function descriptors like ppc6441// big-endian, we get two 'fseek()' calls for each symbol read from the Elf file42// because reading the file descriptor table is nested inside the loop which reads43// the symbols. This really trashes the I/O system and considerable slows down the44// test, so we need an extra long timeout setting.4546/*47* @test48* @bug 819337349* @summary Test reading ELF info direct from underlaying file50* @requires (os.family == "linux") & (os.arch == "ppc64")51* @modules java.base/jdk.internal.misc52* @library /test/lib53* @build sun.hotspot.WhiteBox54* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox55* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI56-XX:NativeMemoryTracking=detail TestElfDirectRead57*/5859import jdk.test.lib.process.ProcessTools;60import jdk.test.lib.process.OutputAnalyzer;61import jdk.test.lib.JDKToolFinder;62import sun.hotspot.WhiteBox;6364public class TestElfDirectRead {65public static void main(String args[]) throws Exception {66WhiteBox wb = WhiteBox.getWhiteBox();67wb.disableElfSectionCache();68ProcessBuilder pb = new ProcessBuilder();69OutputAnalyzer output;70// Grab my own PID71String pid = Long.toString(ProcessTools.getProcessId());7273pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"});74output = new OutputAnalyzer(pb.start());75// This is a pre-populated stack frame, should always exist if can decode76output.shouldContain("MallocSiteTable::new_entry");77}78}79808182