Frames | No Frames |
1: /* MethodCommandSet.java -- class to implement the Method Command Set 2: Copyright (C) 2005, 2006 Free Software Foundation 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package gnu.classpath.jdwp.processor; 40: 41: import gnu.classpath.jdwp.JdwpConstants; 42: import gnu.classpath.jdwp.VMMethod; 43: import gnu.classpath.jdwp.exception.JdwpException; 44: import gnu.classpath.jdwp.exception.JdwpInternalErrorException; 45: import gnu.classpath.jdwp.exception.NotImplementedException; 46: import gnu.classpath.jdwp.id.ClassReferenceTypeId; 47: import gnu.classpath.jdwp.util.LineTable; 48: import gnu.classpath.jdwp.util.VariableTable; 49: 50: import java.io.DataOutputStream; 51: import java.io.IOException; 52: import java.nio.ByteBuffer; 53: 54: /** 55: * A class representing the Method Command Set. 56: * 57: * @author Aaron Luchko <aluchko@redhat.com> 58: */ 59: public class MethodCommandSet 60: extends CommandSet 61: { 62: public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command) 63: throws JdwpException 64: { 65: try 66: { 67: switch (command) 68: { 69: case JdwpConstants.CommandSet.Method.LINE_TABLE: 70: executeLineTable(bb, os); 71: break; 72: case JdwpConstants.CommandSet.Method.VARIABLE_TABLE: 73: executeVariableTable(bb, os); 74: break; 75: case JdwpConstants.CommandSet.Method.BYTE_CODES: 76: executeByteCodes(bb, os); 77: break; 78: case JdwpConstants.CommandSet.Method.IS_OBSOLETE: 79: executeIsObsolete(bb, os); 80: break; 81: case JdwpConstants.CommandSet.Method.VARIABLE_TABLE_WITH_GENERIC: 82: executeVariableTableWithGeneric(bb, os); 83: break; 84: default: 85: throw new NotImplementedException( 86: "Command " + command + " not found in Method Command Set."); 87: } 88: } 89: catch (IOException ex) 90: { 91: // The DataOutputStream we're using isn't talking to a socket at all 92: // So if we throw an IOException we're in serious trouble 93: throw new JdwpInternalErrorException(ex); 94: } 95: 96: return false; 97: } 98: 99: private void executeLineTable(ByteBuffer bb, DataOutputStream os) 100: throws JdwpException, IOException 101: { 102: ClassReferenceTypeId refId 103: = (ClassReferenceTypeId) idMan.readReferenceTypeId(bb); 104: Class clazz = refId.getType(); 105: 106: VMMethod method = VMMethod.readId(clazz, bb); 107: LineTable lt = method.getLineTable(); 108: lt.write(os); 109: } 110: 111: private void executeVariableTable(ByteBuffer bb, DataOutputStream os) 112: throws JdwpException, IOException 113: { 114: ClassReferenceTypeId refId 115: = (ClassReferenceTypeId) idMan.readReferenceTypeId(bb); 116: Class clazz = refId.getType(); 117: 118: VMMethod method = VMMethod.readId(clazz, bb); 119: VariableTable vt = method.getVariableTable(); 120: vt.write(os); 121: } 122: 123: private void executeByteCodes(ByteBuffer bb, DataOutputStream os) 124: throws JdwpException 125: { 126: // This command is optional, determined by VirtualMachines CapabilitiesNew 127: // so we'll leave it till later to implement 128: throw new NotImplementedException("Command ByteCodes not implemented."); 129: } 130: 131: private void executeIsObsolete(ByteBuffer bb, DataOutputStream os) 132: throws IOException 133: { 134: // The debugger is really asking if this method has been redefined using 135: // VirtualMachineCommandSet.RedefineClasses. Since we don't implement that 136: // command the answer to this will always be false. 137: os.writeBoolean(false); 138: } 139: 140: private void executeVariableTableWithGeneric(ByteBuffer bb, 141: DataOutputStream os) 142: throws JdwpException 143: { 144: // We don't have generics yet 145: throw new NotImplementedException( 146: "Command SourceDebugExtension not implemented."); 147: } 148: 149: }