How to debug TWCore using Eclipse

Debugging in Eclipse is fairly easy and straightforward if you get the hang of it.

In a nutshell:

  1. Set a breakpoint somewhere in the code where you want to check the variables or to see the flow of the executing code.
  2. Switch to the debug perspective when the breakpoint is passed
  3. Examine the variables in the debug perspective
  4. Use the debug buttons (Step Into, Step Over, Step Out) to see the code that's being executed, line by line.

Notice:

Step-by-step

As an example, I will debug the following modified (and simplified) ultrabot as I need to know the value of the variable messagesCount on line 18 :

package twcore.bots.ultrabot;

import twcore.core.*;
import twcore.core.command.*;
import twcore.core.events.*;

public class ultrabot extends SubspaceBot {

    private int messagesCount;

    /** Creates a new instance of ultrabot */
    public ultrabot(BotAction botAction) {
        super(botAction);
    }

    public void handleEvent(Message event) {
        messagesCount++;
        if(messagesCount == 70) {
            m_botAction.die();
        }
    }

    public void handleEvent(LoggedOn event) {
        m_botAction.joinArena("#robopark");
    }
}

... More to come :)