LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Sponsors
  • Mirrors
  • Logos
  • Contact us
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Cvs-checkins > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: cvs at opencores.org<cvs@o...>
    Date: Tue Dec 18 14:52:02 CET 2007
    Subject: [cvs-checkins] MODIFIED: jop ...
    Top
    Date: 00/07/12 18:14:52

    Modified: jop/java/tools/src/com/jopdesign/debug/jdwp/test
    TestJopServer.java
    Log:
    Added a few more tests, including to set/clear breakpoints and to

    get the list of stack frames. Changed the class to ask if it should retry,

    when the server is not yet available.

    Some constants were added.



    Methods changed:

    108: public static void main(String[] args) throws IOException

    180: public void testJopDebugKernelInteractively(String symbolFile,

    181: BufferedReader reader) throws IOException,ClassNotFoundException

    563: private void printCommandMenu()

    788: public void testJopSimCommunication(String symbolFile, BufferedReader reader)

    789: throws IOException, ClassNotFoundException

    1030: private void initialize(String symbolFile, BufferedReader reader)





    Methods added:

    421: private void interactiveTestSetBreakpoint(BufferedReader reader) throws IOException

    458: private void interactiveTestClearBreakpoint(BufferedReader reader) throws IOException

    580: private void interactiveTestForJDWPPacketsSent()

    658: private boolean isValidInstructionOffset(int methodStructPointer, int offset)




    Revision Changes Path
    1.5 jop/java/tools/src/com/jopdesign/debug/jdwp/test/TestJopServer.java

    http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/com/jopdesign/debug/jdwp/test/TestJopServer.java.diff?r1=1.4&r2=1.5

    (In the diff below, changes in quantity of whitespace are not shown.)

    Index: TestJopServer.java
    ===================================================================
    RCS file: /cvsroot/paulo/jop/java/tools/src/com/jopdesign/debug/jdwp/test/TestJopServer.java,v
    retrieving revision 1.4
    retrieving revision 1.5
    diff -u -b -r1.4 -r1.5
    --- TestJopServer.java 13 Dec 2007 00:05:25 -0000 1.4
    +++ TestJopServer.java 18 Dec 2007 13:52:02 -0000 1.5
    @@ -85,9 +85,12 @@
    private static final int RESUME_EXECUTION = 7;
    private static final int EXIT_OPTION = 8;
    private static final int TEST_JDWP_PACKETS = 9;
    + private static final int TEST_JDWP_PACKETS_SENT = 10;
    + private static final int SET_BREAKPOINT = 11;
    + private static final int CLEAR_BREAKPOINT = 12;
    + private static final int GET_STACK_LIST = 13;

    -// private static final int SET_BREAKPOINT = 9;
    -// private static final int CLEAR_BREAKPOINT = 10;
    + private static final int INVALID_BYTECODE = -1;

    private JOPDebugChannel debugChannel;
    private SymbolManager manager;
    @@ -99,6 +102,11 @@
    }

    /**
    + * A test class for the JOP server. It works in two modes:
    + * the first is a simple, automatic test to check connection.
    + * The second is a simple interactive menu which can be used
    + * to test basic services and help during the development of
    + * other services.
    *
    * @param args
    * @throws IOException
    @@ -119,12 +127,14 @@
    }

    TestJopServer testObject = new TestJopServer();
    + // create a reader to make it easy to read lines from the input
    + BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    try
    {
    if(args.length == 1)
    {
    - testObject.testJopSimCommunication(args[0]);
    + testObject.testJopSimCommunication(args[0], reader); } else { @@ -132,11 +142,11 @@ { try { - testObject.testJopDebugKernelInteractively(args[0]); + testObject.testJopDebugKernelInteractively(args[0], reader); } catch(SocketException exception) { - println("Interrupted. Connection closed by the server."); + println("Could not connect or connection was closed by the server."); } } else @@ -172,14 +182,12 @@ // } // } - public void testJopDebugKernelInteractively(String symbolFile) throws IOException, ClassNotFoundException + public void testJopDebugKernelInteractively(String symbolFile, + BufferedReader reader) throws IOException, ClassNotFoundException { int command; boolean shouldContinue; - initialize(symbolFile); - - // create a reader to make it easy to read lines from the input - BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); + initialize(symbolFile, reader); // flag to control interactive loop shouldContinue = true; @@ -252,6 +260,30 @@ break; } + case TEST_JDWP_PACKETS_SENT: + { + interactiveTestForJDWPPacketsSent(); + break; + } + + case SET_BREAKPOINT: + { + interactiveTestSetBreakpoint(reader); + break; + } + + case CLEAR_BREAKPOINT: + { + interactiveTestClearBreakpoint(reader); + break; + } + + case GET_STACK_LIST: + { + testGetStackFrameList(); + break; + } + case INVALID_OPTION: default: { @@ -265,6 +297,8 @@ } /** + * Test method to get a local variable. + * * @param reader * @throws IOException * @@ -356,7 +390,6 @@ /** * @param reader * @throws IOException - * */ private void interactiveTestSetLocalVariable(BufferedReader reader) throws IOException { @@ -392,6 +425,83 @@ println("Value updated."); } + private void interactiveTestSetBreakpoint(BufferedReader reader) throws IOException + { + int methodPointer, instructionOffset; + int bytecode; + + println("Please input the method struct pointer: "); + methodPointer = readNonNegativeInteger(reader); + + if(isValidMethodPointer(methodPointer) == false) + { + println("Failure: invalid method pointer -> " + methodPointer); + println(); + return; + } + + // get and test the instruction offset + print("Please input the instruction offset: "); + instructionOffset = readNonNegativeInteger(reader); + + if(isValidInstructionOffset(methodPointer, instructionOffset) == false) + { + println("Failure: invalid instruction offset -> " + instructionOffset); + println(); + return; + } + + bytecode = debugChannel.setBreakPoint(methodPointer, instructionOffset); + if (bytecode != INVALID_BYTECODE) + { + println("Success. Breakpoint set. Previous bytecode: " + bytecode); + } + else + { + println("Failure . Breakpoint *not* set."); + } + } + + private void interactiveTestClearBreakpoint(BufferedReader reader) throws IOException + { + int methodPointer, instructionOffset; + int bytecode; + + println("Please input the method struct pointer: "); + methodPointer = readNonNegativeInteger(reader); + + if(isValidMethodPointer(methodPointer) == false) + { + println("Failure: invalid method pointer -> " + methodPointer); + println(); + return; + } + + // get and test the instruction offset + print("Please input the instruction offset: "); + instructionOffset = readNonNegativeInteger(reader); + + if(isValidInstructionOffset(methodPointer, instructionOffset) == false) + { + println("Failure: invalid instruction offset -> " + instructionOffset); + println(); + return; + } + + print("Please input the previous bytecode: "); + bytecode = readNonNegativeInteger(reader); + + int result = debugChannel.clearBreakPoint(methodPointer, instructionOffset, bytecode); + if (result != INVALID_BYTECODE) + { + println("Success. Breakpoint cleared."); + } + else + { + println("Failure . Breakpoint *not* cleared."); + } + } + /** * @throws IOException * @@ -471,6 +581,16 @@ } /** + * @throws IOException + * + */ + private void interactiveTestForJDWPPacketsSent() + throws IOException + { + debugChannel.testJDWPPacketsSent(); + } + + /** * Print an object to the standard output and flush the buffer. * Created to better interact with Ant. * @@ -539,6 +659,15 @@ } /** + * @param methodStructPointer + * @return + */ + private boolean isValidInstructionOffset(int methodStructPointer, int offset) + { + return manager.isValidInstructionOffset(methodStructPointer, offset); + } + + /** * @throws IOException * */ @@ -554,7 +683,7 @@ */ private void interactiveTestExit(BufferedReader reader) throws IOException { - debugChannel.sendExitCommand(0); + debugChannel.sendExitCommand(16); } /** @@ -591,10 +720,17 @@ print(TEST_JDWP_PACKETS); println(". Test JDWP packet creation."); -// print(SET_BREAKPOINT); -// println(". "); -// print(CLEAR_BREAKPOINT); -// println(". "); + print(TEST_JDWP_PACKETS_SENT); + println(". Test JDWP packet reply."); + + print(SET_BREAKPOINT); + println(". Set breakpoint"); + + print(CLEAR_BREAKPOINT); + println(". Clear breakpoint"); + + print(GET_STACK_LIST); + println(". Get the list of stack frames"); println(); printLine(); @@ -647,19 +783,22 @@ } /** + * Automatic test to check communication with JOP. * + * @param symbolFile + * @param reader * @throws IOException * @throws ClassNotFoundException - * @throws ClassNotFoundException */ - public void testJopSimCommunication(String symbolFile) throws IOException, ClassNotFoundException + public void testJopSimCommunication(String symbolFile, BufferedReader reader) + throws IOException, ClassNotFoundException { int received = 2; int methodPointer; int stackDepth; int index; - initialize(symbolFile); + initialize(symbolFile, reader); testStackAccess(); testMethodCalls(); @@ -889,22 +1028,43 @@ * Connect to the server and load the symbol file. * * @param symbolFile + * @param reader * @throws IOException * @throws ClassNotFoundException */ - private void initialize(String symbolFile) throws IOException, ClassNotFoundException + private void initialize(String symbolFile, BufferedReader reader) + throws IOException, ClassNotFoundException + { + boolean shouldRetry; + + shouldRetry = true; + do { try { debugChannel.connect(); + shouldRetry = false; // handshake(); } catch (IOException exception) { println(); println("Connection failure. Please make sure the server is running."); + println("Retry? (y/n)"); + String data = reader.readLine(); + data = data.trim().toLowerCase(); + if("y".equals(data) == false) + { + shouldRetry = false; throw exception; } + else + { + shouldRetry = true; + } + } + } + while(shouldRetry); // load symbols to know the method addresses try

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.