Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java debugging using eclipse

Options
  • 02-07-2008 2:54pm
    #1
    Registered Users Posts: 427 ✭✭


    Hi
    I have a java program running on my machine in debug mode. I have connected to the JVM using the eclipse degugger and can now insert break points into the source code and trace through it. My problem is that I cannot go one step at a time unless execution hits a break point first.

    I want to be able to ececute one line at a time (pause after each line until a button is pressed) from the very start of execution regardless of whether there is any break point. Does anyone know how to do this?

    I can almost do this using the F6 key but I must first insert a break point. Unfortunately I do not know the location of the code which is first executed therefore I cannot do this.
    Sorry, if this isn't very clear.
    Thanks.
    Kevin


Comments

  • Registered Users Posts: 54 ✭✭ejvilla


    Search (Press CTRL+H and select file search) for a main() method in *.java

    This should give you your entry point.

    AFAIK you will need to set an initial breakpoint.

    You say you have it hitting a breakpoint at the moment? In debug mode, you should have the option to look at whats executing on the stack. Trace this back to the class that made the first call.


    Might be difficult to find the entry point this way if there are multiple threads... although you could just click on them all in the debugger - right-click and choose 'suspend'.

    Kevo wrote: »
    Hi
    I have a java program running on my machine in debug mode. I have connected to the JVM using the eclipse degugger and can now insert break points into the source code and trace through it. My problem is that I cannot go one step at a time unless execution hits a break point first.

    I want to be able to ececute one line at a time (pause after each line until a button is pressed) from the very start of execution regardless of whether there is any break point. Does anyone know how to do this?

    I can almost do this using the F6 key but I must first insert a break point. Unfortunately I do not know the location of the code which is first executed therefore I cannot do this.
    Sorry, if this isn't very clear.
    Thanks.
    Kevin


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    When it switches over to the debug perspective there should be buttons that say step into /step out.

    Step out one will execute commands one at a time.

    Step into will do the same but if you hit a method will enter into that method and step through, and so on.


  • Registered Users Posts: 1,996 ✭✭✭lynchie


    Start your app with suspend = y

    -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

    Click run in eclipse and it should start the app and suspend it straight away

    then in the debug launcher add a new remote java application and set the address the same. Click debug, it should attach to the other suspended jvm.

    Though thinking about it, im not sure if it will allow you to step through until you hit a breakpoint. If not, sure click on the threads window, and add a breakpoint on the suspended thread.


  • Registered Users Posts: 54 ✭✭ejvilla


    We might be using different versions of eclipse but I'm set up as follows:

    Step Into = F5 (enter a method)
    Step Over = F6 (one line at a time)
    Step Out of = F7 (exit a method - used in conjunction with F5)

    Hobbes wrote: »
    When it switches over to the debug perspective there should be buttons that say step into /step out.

    Step out one will execute commands one at a time.

    Step into will do the same but if you hit a method will enter into that method and step through, and so on.


  • Registered Users Posts: 11,264 ✭✭✭✭jester77


    You can always try and trace backwards. Ctrl+Shift+G on your first breakpoint will show all references to it. Looking through them might help you.


  • Advertisement
Advertisement