8283198: Remove src/jdk.hotspot.agent/test

Reviewed-by: amenkov, ayang, sspitsyn
This commit is contained in:
Francesco Andreuzzi 2025-09-26 19:51:04 +00:00 committed by Alex Menkov
parent 62cc347242
commit c6cecc581f
6 changed files with 0 additions and 408 deletions

View File

@ -1,164 +0,0 @@
/*
* Copyright (c) 2003, 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.
*
*/
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
import sun.jvm.hotspot.utilities.*;
/**
We don't run any of the "standard" SA command line tools for sanity
check. This is because the standard tools print addresses in hex
which could change legally. Also, textual comparison of output may
not match because of other reasons as well. This tool checks
validity of threads and frames logically. This class has reference
frame names from "known" threads. The debuggee is assumed to run
"LibprocTest.java".
*/
public class LibprocClient extends Tool {
public void run() {
// try to get VM version and check
String version = VM.getVM().getVMRelease();
Assert.that(version.startsWith("1.5"), "1.5 expected");
// try getting threads
Threads threads = VM.getVM().getThreads();
boolean mainTested = false;
// check frames of each thread
for (JavaThread cur = threads.first(); cur != null; cur = cur.next()) {
if (cur.isJavaThread()) {
String name = cur.getThreadName();
// testing of basic frame walking for all threads
for (JavaVFrame vf = getLastJavaVFrame(cur); vf != null; vf = vf.javaSender()) {
checkFrame(vf);
}
// special testing for "known" threads. For now, only "main" thread.
if (name.equals("main")) {
checkMainThread(cur);
mainTested = true;
}
}
}
Assert.that(mainTested, "main thread missing");
}
public static void main(String[] args) {
try {
LibprocClient lc = new LibprocClient();
lc.start(args);
lc.getAgent().detach();
System.out.println("\nPASSED\n");
} catch (Exception exp) {
System.out.println("\nFAILED\n");
exp.printStackTrace();
}
}
// -- Internals only below this point
private static JavaVFrame getLastJavaVFrame(JavaThread cur) {
RegisterMap regMap = cur.newRegisterMap(true);
Frame f = cur.getCurrentFrameGuess();
if (f == null) {
System.err.println(" (Unable to get a top most frame)");
return null;
}
VFrame vf = VFrame.newVFrame(f, regMap, cur, true, true);
if (vf == null) {
System.err.println(" (Unable to create vframe for topmost frame guess)");
return null;
}
if (vf.isJavaFrame()) {
return (JavaVFrame) vf;
}
return (JavaVFrame) vf.javaSender();
}
private void checkMethodSignature(Symbol sig) {
SignatureIterator itr = new SignatureIterator(sig) {
public void doBool () {}
public void doChar () {}
public void doFloat () {}
public void doDouble() {}
public void doByte () {}
public void doShort () {}
public void doInt () {}
public void doLong () {}
public void doVoid () {}
public void doObject(int begin, int end) {}
public void doArray (int begin, int end) {}
};
// this will throw RuntimeException for any invalid item in signature.
itr.iterate();
}
private void checkBCI(Method m, int bci) {
if (! m.isNative()) {
byte[] buf = m.getByteCode();
Assert.that(bci >= 0 && bci < buf.length, "invalid bci, not in code range");
if (m.hasLineNumberTable()) {
int lineNum = m.getLineNumberFromBCI(bci);
Assert.that(lineNum >= 0, "expecting non-negative line number");
}
}
}
private void checkMethodHolder(Method method) {
Klass klass = method.getMethodHolder();
Assert.that(klass != null, "expecting non-null instance klass");
}
private void checkFrame(JavaVFrame vf) {
Method method = vf.getMethod();
Assert.that(method != null, "expecting a non-null method here");
Assert.that(method.getName() != null, "expecting non-null method name");
checkMethodHolder(method);
checkMethodSignature(method.getSignature());
checkBCI(method, vf.getBCI());
}
// from the test case LibprocTest.java - in the main thread we
// should see frames as below
private static String[] mainThreadMethods = new String[] {
"java.lang.Object.wait(long)",
"java.lang.Object.wait()",
"LibprocTest.main(java.lang.String[])"
};
private void checkMainThread(JavaThread thread) {
checkFrames(thread, mainThreadMethods);
}
private void checkFrames(JavaThread thread, String[] expectedMethodNames) {
int i = 0;
for (JavaVFrame vf = getLastJavaVFrame(thread); vf != null; vf = vf.javaSender(), i++) {
Method m = vf.getMethod();
Assert.that(m.externalNameAndSignature().equals(expectedMethodNames[i]),
"expected frame missing");
}
}
}

View File

@ -1,41 +0,0 @@
/*
* Copyright (c) 2003, 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.
*
*/
/**
This is test case run by debuggee for running LibprocClient.java.
*/
public class LibprocTest {
public static void main(String[] args) throws Exception {
String myStr = "";
System.out.println("main start");
synchronized(myStr) {
try {
myStr.wait();
} catch (InterruptedException ee) {
}
}
System.out.println("main end");
}
}

View File

@ -1,30 +0,0 @@
#
# Copyright (c) 2003, 2024, 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.
#
#
all:
javac LibprocTest.java
javac -classpath ../../build/classes LibprocClient.java
clean:
rm -rf *.class

View File

@ -1,42 +0,0 @@
#
# Copyright (c) 2007, 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.
#
#
After making any changes to libproc.so, the shell scripts described
below can be run to verify that it does not break Java Serviceability
Agent.
Setup:
You need to have jdk 1.5 installed to run this test. Set environment
variable SA_JAVA to point to the java executable of jdk
1.5. Otherwise, the script picks-up 'java' from PATH.
Running the tests:
run libproctest.sh (32-bit debuggee) and libproctest64.sh (64-bit
debuggee)
Interpreting result:
"PASSED" or "FAILED" is printed in standard output.

View File

@ -1,66 +0,0 @@
#!/bin/ksh
#
# Copyright (c) 2003, 2020, 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.
#
#
# This script is used to run consistency check of Serviceabilty Agent
# after making any libproc.so changes. Prints "PASSED" or "FAILED" in
# standard output.
usage() {
echo "usage: $0"
echo " set SA_JAVA to be java executable from JDK 1.5"
exit 1
}
STARTDIR=`dirname $0`
if [ "$1" == "-help" ]; then
usage
fi
if [ "x$SA_JAVA" = "x" ]; then
SA_JAVA=java
fi
# create java process with test case
tmp=/tmp/libproctest
rm -f $tmp
$SA_JAVA -classpath $STARTDIR LibprocTest > $tmp &
pid=$!
while [ ! -s $tmp ] ; do
# Kludge alert!
sleep 2
done
# dump core
gcore $pid
kill -9 $pid
# run libproc client
$SA_JAVA -showversion -cp $STARTDIR/../../build/classes::$STARTDIR/../sa.jar:$STARTDIR LibprocClient x core.$pid
# delete core
rm -f core.$pid

View File

@ -1,65 +0,0 @@
#!/bin/ksh
#
# Copyright (c) 2003, 2020, 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.
#
#
# This script is used to run consistency check of Serviceabilty Agent
# after making any libproc.so changes. Prints "PASSED" or "FAILED" in
# standard output.
usage() {
echo "usage: $0"
echo " set SA_JAVA to be the java executable from JDK 1.5"
exit 1
}
if [ "$1" == "-help" ]; then
usage
fi
if [ "x$SA_JAVA" = "x" ]; then
SA_JAVA=java
fi
STARTDIR=`dirname $0`
# create java process with test case
tmp=/tmp/libproctest
rm -f $tmp
$SA_JAVA -d64 -classpath $STARTDIR LibprocTest > $tmp &
pid=$!
while [ ! -s $tmp ] ; do
# Kludge alert!
sleep 2
done
# dump core
gcore $pid
kill -9 $pid
# run libproc client
$SA_JAVA -d64 -showversion -cp $STARTDIR/../../build/classes::$STARTDIR/../sa.jar:$STARTDIR LibprocClient x core.$pid
# delete core
rm -f core.$pid