Test Your Debugger Setup

To make sure that everything is functioning properly, create a simple Apex class, set a breakpoint in your code, and then hit the breakpoint using Execute Anonymous.
  1. Create an Apex class called SampleClass with this content.
    1public class SampleClass {
    2   public void level1(Integer depth1) {
    3      level2(2);
    4   }
    5    
    6   public void level2(Integer depth2) {
    7      level3(3);
    8   }
    9    
    10   public void level3(Integer depth3) {
    11      System.debug('Placeholder for setting breakpoint');
    12   }
    13}
  2. Save the class.
  3. If you don’t have Work Online enabled, save the class to the server. Right-click the class in the Package Explorer, then choose Force.com | Save to Server. This screenshot shows that Work Online is not enabled (1), and demonstrates how to save to the server (2).
    Force.com IDE perspective, showing offline project with class being saved to server
  4. Switch to the Debug perspective by choosing Window | Open Perspective | Other | Debug.

    After you’ve completed the initial Debugger setup, you can switch between perspectives by clicking the icons in the upper right corner of your Eclipse window.

    Tip

  5. Click the debug icon (Debug icon) in the toolbar and select Debug Configurations.
  6. Select Remote Apex Debugger.
  7. To create a configuration for your project, click the New launch configuration icon (New launch configuration icon).
  8. Name the configuration.
  9. Click Browse and select your project.
  10. Click Apply, and then click Debug.
  11. Click the debug icon (Debug icon) and launch the new debug configuration.
  12. Wait until you see an icon showing turning yellow gears in the Debug pane.
    Debug pane with turning yellow gears icon
  13. To set a breakpoint, double-click in the gray gutter to the left of the System.debug statement in SampleClass.cls.
    Source pane with breakpoint set in SampleClass.cls
  14. Select the Execute Anonymous tab at the bottom of the screen. If the Execute Anonymous tab isn’t available, choose Window | Show View | Other | Force.com and add it.
  15. Make sure that your project is the Active Project.
  16. In the Source to execute field, enter:
    1new SampleClass().level1(1);
  17. Click Execute Anonymous.

    You might get an error message like, “SocketTimeoutException: Read timed out,” when using Execute Anonymous to hit a breakpoint during a debugging session. Execute Anonymous expects to receive timely results from the server, but because you’ve stopped at a breakpoint your results don’t arrive in a timely fashion. Dismiss the error message, and carry on with your debugging.

    Note

    The Debugger stops at the breakpoint (1). The call stack (2) and the values of your variables (3) are displayed. When applicable, a URL showing how each request originated displays next to the request ID in your call stack details.

    Debug perspective, stopped at a breakpoint