JdbMethodExitTest.sh revision 2362
2362N/A# Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. 0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A# This code is free software; you can redistribute it and/or modify it 0N/A# under the terms of the GNU General Public License version 2 only, as 0N/A# published by the Free Software Foundation. 0N/A# This code is distributed in the hope that it will be useful, but WITHOUT 0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A# version 2 for more details (a copy is included in the LICENSE file that 0N/A# accompanied this code). 0N/A# You should have received a copy of the GNU General Public License version 0N/A# 2 along with this work; if not, write to the Free Software Foundation, 0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A# @summary TTY: Add support for method exit event return values to jdb 0N/A# @author Jim Holmlund 0N/A# These are variables that can be set to control execution 0N/Aimport java.net.URLClassLoader; 0N/A * This tests the jdb trace command 0N/A // These are the values that will be returned by the methods 0N/A static URL[] urls = new URL[1]; 0N/A public static byte byteValue = 89; 0N/A public static char charValue = 'x'; 0N/A public static double doubleValue = 2.2; 0N/A public static float floatValue = 3.3f; 0N/A public static int intValue = 1; 0N/A public static short shortValue = 8; 0N/A public static boolean booleanValue = false; 0N/A public static Class classValue = Object.class; 0N/A public static ClassLoader classLoaderValue; 0N/A urls[0] = new URL("hi there"); 0N/A } catch (java.net.MalformedURLException ee) { 0N/A classLoaderValue = new URLClassLoader(urls); 0N/A public static Thread threadValue; 0N/A public static ThreadGroup threadGroupValue; 0N/A public static String stringValue = "abc"; 0N/A public static int[] intArrayValue = new int[] {1, 2, 3}; 0N/A public static $classname objectValue = 0N/A public String ivar = stringValue; 0N/A // These are the instance methods 0N/A public byte i_bytef() { return byteValue; } 0N/A public char i_charf() { return charValue; } 0N/A public double i_doublef() { return doubleValue; } 0N/A public float i_floatf() { return floatValue; } 0N/A public int i_intf() { return intValue; } 0N/A public short i_shortf() { return shortValue; } 0N/A public boolean i_booleanf() { return booleanValue; } 0N/A public String i_stringf() { return stringValue; } 0N/A public Class i_classf() { return classValue; } 0N/A public ClassLoader i_classLoaderf() 0N/A { return classLoaderValue; } 0N/A public Thread i_threadf() { return threadValue = Thread.currentThread(); } 0N/A public ThreadGroup i_threadGroupf() 0N/A { return threadGroupValue = threadValue.getThreadGroup(); } 0N/A public int[] i_intArrayf() { return intArrayValue; } 0N/A public Object i_nullObjectf() { return null; } 0N/A public Object i_objectf() { return objectValue; } 0N/A public void i_voidf() {} 0N/A static void doit($classname xx) { 0N/A xx.i_classLoaderf(); 0N/A xx.i_threadGroupf(); 0N/A // Prove it works for native methods too 0N/A StrictMath.sin(doubleValue); 0N/A stringValue.intern(); 0N/A public static void bkpt() { 0N/A int i = 0; //@1 breakpoint 0N/A public static String traceMethods() { 0N/A return "traceMethods"; 0N/A public static String traceMethods1() { 0N/A return "traceMethods1"; 0N/A public static String traceExits() { 0N/A return "traceExits"; 0N/A public static String traceExits1() { 0N/A return "traceExits1"; 0N/A public static String traceExit() { 0N/A public static String traceExit1() { 0N/A return "traceExit1"; 0N/A public static void main(String[] args) { 0N/A // The debugger will stop at the start of main, 0N/A // enable method exit events, and then do 0N/A $classname xx = new $classname(); 0N/A // test all possible return types 0N/A // test trace methods 0N/A // test trace go methods 0N/A // test trace method exits 0N/A // test trace method exits 0N/A // test trace method exit 0N/A // test trace method exit 0N/A# drive jdb by sending cmds to it and examining its output 0N/A # test all possible return types 0N/A # trace exit of methods with all the return values 0N/A # (but just check a couple of them) 0N/A # Get out of bkpt back to the call to traceMethods 0N/A cmd step # skip over setting return value in caller :-( 0N/A# You could replace this next line with the contents