Home | History | Annotate | Download | only in Method
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one or more
      3  * contributor license agreements.  See the NOTICE file distributed with
      4  * this work for additional information regarding copyright ownership.
      5  * The ASF licenses this file to You under the Apache License, Version 2.0
      6  * (the "License"); you may not use this file except in compliance with
      7  * the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *
     15  *  See the License for the specific language governing permissions and
     16  *  limitations under the License.
     17  */
     18 
     19 /**
     20  * @author Anton V. Karnachuk
     21  */
     22 
     23 /**
     24  * Created on 14.02.2005
     25  */
     26 package org.apache.harmony.jpda.tests.jdwp.Method;
     27 
     28 import java.io.UnsupportedEncodingException;
     29 
     30 import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
     31 import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
     32 import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
     33 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
     34 
     35 
     36 
     37 /**
     38  * JDWP Unit test for Method.VariableTable command.
     39  */
     40 public class VariableTableTest extends JDWPMethodTestCase {
     41     /**
     42      * This testcase exercises Method.VariableTable command.
     43      * <BR>It runs MethodDebuggee, receives methods of debuggee.
     44      * For each received method sends Method.VariableTable command
     45      * and prints returned VariableTable.
     46      */
     47     public void testVariableTableTest001() throws UnsupportedEncodingException {
     48         logWriter.println("testVariableTableTest001 started");
     49         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
     50 
     51         long classID = getClassIDBySignature("L"+getDebuggeeClassName().replace('.', '/')+";");
     52 
     53         MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
     54         assertFalse("Invalid number of methods: 0", methodsInfo.length == 0);
     55 
     56         for (int i = 0; i < methodsInfo.length; i++) {
     57             logWriter.println(methodsInfo[i].toString());
     58 
     59             // get variable table for this class
     60             CommandPacket packet = new CommandPacket(
     61                     JDWPCommands.MethodCommandSet.CommandSetID,
     62                     JDWPCommands.MethodCommandSet.VariableTableCommand);
     63             packet.setNextValueAsClassID(classID);
     64             packet.setNextValueAsMethodID(methodsInfo[i].getMethodID());
     65             ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
     66             checkReplyPacket(reply, "Method::VariableTable command");
     67 
     68             int argCnt = reply.getNextValueAsInt();
     69             logWriter.println("argCnt = "+argCnt);
     70             int slots = reply.getNextValueAsInt();
     71             logWriter.println("slots = "+slots);
     72             for (int j = 0; j < slots; j++) {
     73                 long codeIndex = reply.getNextValueAsLong();
     74                 logWriter.println("codeIndex = "+codeIndex);
     75                 String name = reply.getNextValueAsString();
     76                 logWriter.println("name = "+name);
     77                 String signature = reply.getNextValueAsString();
     78                 logWriter.println("signature = "+signature);
     79                 int length = reply.getNextValueAsInt();
     80                 logWriter.println("length = "+length);
     81                 int slot = reply.getNextValueAsInt();
     82                 logWriter.println("slot = "+slot);
     83             }
     84 
     85         }
     86 
     87         synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
     88     }
     89 }
     90