Changes between Initial Version and Version 1 of HowToDebug


Ignore:
Timestamp:
Apr 17, 2008 1:22:29 PM (11 years ago)
Author:
Maverick
Comment:

Very first draft version of this page

Legend:

Unmodified
Added
Removed
Modified
  • HowToDebug

    v1 v1  
     1[[TracNav(Index)]] 
     2 
     3= How to debug TWCore using Eclipse = 
     4 
     5Debugging in Eclipse is fairly easy and straightforward if you get the hang of it. 
     6 
     7In a nutshell: 
     8 1. Set a breakpoint somewhere in the code where you want to check the variables or to see the flow of the executing code. 
     9 1. Switch to the debug perspective when the breakpoint is passed 
     10 1. Examine the variables in the debug perspective 
     11 1. Use the debug buttons (Step Into, Step Over, Step Out) to see the code that's being executed, line by line. 
     12 
     13Notice: 
     14 * You need to start your program in debug mode to be able to debug it (else your breakpoints will be ignored). 
     15 * When debugging a TWCore bot, it can time-out if you keep it suspended for too long. This is normal as any client need to keep sending packets to the server to make sure it's still alive. If you want to prevent this, you just have to resume your thread within a timely fashion after it's suspended on a breakpoint. 
     16 
     17 
     18== Step-by-step == 
     19As 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''' : 
     20 
     21{{{ 
     22#!java 
     23package twcore.bots.ultrabot; 
     24 
     25import twcore.core.*; 
     26import twcore.core.command.*; 
     27import twcore.core.events.*; 
     28 
     29public class ultrabot extends SubspaceBot { 
     30 
     31    private int messagesCount; 
     32 
     33    /** Creates a new instance of ultrabot */ 
     34    public ultrabot(BotAction botAction) { 
     35        super(botAction); 
     36    } 
     37 
     38    public void handleEvent(Message event) { 
     39        messagesCount++; 
     40        if(messagesCount == 70) { 
     41            m_botAction.die(); 
     42        } 
     43    } 
     44 
     45    public void handleEvent(LoggedOn event) { 
     46        m_botAction.joinArena("#robopark"); 
     47    } 
     48} 
     49 
     50}}} 
     51 
     52 
     53 
     54... More to come :)