compared with
Current by Jonathan Bar Or
on Jan 07, 2012 08:40.


 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 1 changes. View first change.

 You can set up Eclipse to debug and step through any part of your CT application, be it the CT server, a GUI client, an agent, or a controller.
  
 h1. Adding a new debug configuration
  
 Eclipse calls each set of run/debug settings a "configuration"(don't confuse this with CT configuration classes, of course).
  
 Every configuration corresponds to one class with a {{main(String\[\] args)}} method that you can run.
  
 This is example shows you how to make a debug configuration for the CT server. Note that when you are debugging _CT configuration classes_, they are run by the server, so this is how you would debug your confguration class.
  
 # Click Run > Debug Configurations
 # Select "Java Application."
 # Press the New button.
 # Give the configuration a name.
 # Choose your Eclipse project from the list.
 # Pick the main class by clicking *Search* and finding the class {{FrontEnd}} in the package {{edu.harvard.eecs.airg.coloredtrails.shared.app}}.
 # Open the *Arguments* tab.
 # Enter {code}
 -s{code}
  as the argument. This is the command-line argument that causes the FrontEnd class to launch the CT server.
 # Open the *Common* tab.
 # Choose _Save as... > Shared file_, and pick your branch's top-level directory. This way, the debug configuration will be stored in a file that you can put into Subversion; you won't have recreate it every time you work on a different machine.
  
 h1. Before debugging
  
 Before debugging one of your classes, don't forget to run the appropriate Ant build tasks (in some cases, you may need to precede these with the {{clean}} task. Otherwise, some of the classes that get loaded at runtime may be outdated.
   
 h1. Remote debugging
  
 You can debug remotely (with Eclipse) as such:
  
 # In order to debug a specific agent, run it in debug mode with an accepting socket of a specific port. This is done as such:
 ## Locate the command for the agent running: "java -classpath dist/ct3.jar SomeAgent SomePin Argument1 Argument2"
 ## Change as such: "java -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=6079,server=y,suspend=n -classpath dist/ct3.jar SomeAgent SomePin Argument1 Argument2"
 ## In this example, we opened as socket at port 6079 which will be the debugging server.
 # In Eclipse, start a new remote debugging session by:
 ## choosing "Run" --> "Debug configurations"...
 ## Creating a new configuration under "Remote Java Application". Give it a name (e.g. "My remote agent debug").
 ## Connection Type is: "Standard (Socket Attach)"
 ## Host is: "localhost". You can choose a different machine by a NetBIOS name or IP as well.
 ## Port is: "6079" (in our example).
 ## In the source tab, select the correct source folder. It is also recommended to make it include subfolders as well.
 ## After launching the agent, click on "Debug". You can add breakpoints as you wish.