/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @key stress
*
* @summary converted from VM testbase nsk/stress/strace/strace003.
* VM testbase keywords: [stress, strace]
* VM testbase readme:
* DESCRIPTION
* The test checks up java.lang.Thread.getStackTrace() method for many threads,
* that recursively invoke a native method in running mode ("alive" stack).
* The test fails if:
* - amount of stack trace elements is more than depth of recursion plus
* four elements corresponding to invocations of Thread.run(), Thread.wait(),
* Thread.exit(), Thread.yield() and ThreadGroup.remove() methods;
* - there is at least one element corresponding to invocation of unexpected
* method.
* This test is almost the same as nsk.stress.strace.strace001 except for
* the recursive method is a native one.
* COMMENTS
* Below assertion is revealed on engineer's build. It is needed to check
* on a promoted build.
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Started at: Fri Apr 25 15:47:13 NSK 2003
* waiting for all threads started ...
* >>> snapshot 1
* checking strace003Thread0(trace elements: 2)
* checking strace003Thread1(trace elements: 2)
* checking strace003Thread2(trace elements: 3)
* checking strace003Thread3(trace elements: 2)
* checking strace003Thread4(trace elements: 2)
* checking strace003Thread5(trace elements: 2)
* checking strace003Thread6(trace elements: 3)
* checking strace003Thread7(trace elements: 2)
* # To suppress the following error report, specify this argument
* # after -XX: or in .hotspotrc: SuppressErrorAt=/jniHandles.hpp:157
* #
* # HotSpot Virtual Machine Error, assertion failure
* # Please report this error at
* # http://java.sun.com/cgi-bin/bugreport.cgi
* #
* # Java VM: Java HotSpot(TM) Client VM (1.4.1-internal-debug mixed mode)
* #
* # assert(result != ((oop)::badJNIHandleVal), "Pointing to zapped jni handle area")
* #
* # Error ID: src/share/vm/runtime/jniHandles.hpp, 157 [ Patched ]
* #
* # Problematic Thread: prio=5 tid=0x001b99e8 nid=0xbf runnable
* #
* Heap at VM Abort:
* Heap
* def new generation total 2112K, used 300K [0xf1800000, 0xf1a20000, 0xf1f10000)
* eden space 2048K, 14% used [0xf1800000, 0xf184b358, 0xf1a00000)
* from space 64K, 0% used [0xf1a00000, 0xf1a00000, 0xf1a10000)
* to space 64K, 0% used [0xf1a10000, 0xf1a10000, 0xf1a20000)
* tenured generation total 1408K, used 0K [0xf1f10000, 0xf2070000, 0xf5800000)
* the space 1408K, 0% used [0xf1f10000, 0xf1f10000, 0xf1f10200, 0xf2070000)
* compacting perm gen total 4096K, used 1024K [0xf5800000, 0xf5c00000, 0xf9800000)
* the space 4096K, 25% used [0xf5800000, 0xf5900240, 0xf5900400, 0xf5c00000)
* Dumping core....
* Abort
* Finished at: Fri Apr 25 15:48:10 NSK 2003
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native nsk.stress.strace.strace003
*/
package nsk.stress.strace;
import nsk.share.ArgumentParser;
import nsk.share.Log;
import java.io.PrintStream;
/**
* The test check up java.lang.Thread.getStackTrace()
method for many threads,
* that recursively invoke a native method in running mode ("alive" stack).
*
*
The test creates THRD_COUNT
instances of strace003Thread
* class, tries to get their stack traces and checks up that returned array contains
* correct stack frames. Each stack frame must be corresponded to one of the following
* methods defined by the EXPECTED_METHODS
array.
These checking are performed REPEAT_COUNT
times.