DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > Effective and Faster Debugging With Conditional Breakpoints

Effective and Faster Debugging With Conditional Breakpoints

Check out these awesome ways to use breakpoints in Eclipse and Chrome to debug your Java and Javascript apps.

Ali Kemal TASCI user avatar by
Ali Kemal TASCI
·
May. 24, 16 · DevOps Zone · Tutorial
Like (5)
Save
Tweet
2.35K Views

Join the DZone community and get the full member experience.

Join For Free

In order to find and resolve defects that prevent correct operation of our code, we mostly use debugging process. Through this process, in a sense, we "tease out" the code and observe the values of variables in runtime. Sometimes, this life-saving process can be time consuming.

Today, most IDEs and even browsers make debugging possible. With the effective use of these tools we can make the debugging process faster and easier.

Below, I want to share some methods that help us make the debugging process fast and effective. You will see Eclipse IDE and Chrome browser samples, but you can implement these methods to other IDEs and browsers, too.

In order to debug our Java code in Eclipse, we put a breakpoint to the line which we want to observe:

Image title

When we run our code in debug mode, the execution of code suspends in every iteration of line which we put breakpoint on. We can also observe the instant values of variables, when the exceution suspends.

Image title

When we know the reason of a defect, instead of observing the instant values of variables in every iteration, we can just specify the condition in the properties of breakpoint. This makes the execution suspended only when the condition  is met. By this way, we can observe the condition we expected quickly:

Image title

Image title

Image title

With the help of this property, we can even run any code when the execution passes the breakpoint, without suspending the execution.

Image title

We can also, change the instant value of variables when the execution passes the breakpoint. So, we can prevent the case which makes a code throw exception.

Image title

With the help of this property, we can also throw any exception from the breakpoint. By this way, it is possible to observe the handling of a rare exception.

Image title

It is possible to debug this in Chrome, too. This time, we will debug our Javascript code. To do this, we can press F12 or open the "Sources" menu under Tools>Developer Tools menu and select the code which we want to debug and add breakpoint. After that, we can also specify a condition to suspend the execution only when the condition meets.

Image title


Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Amazon Lightsail: Virtual Cloud Server
  • Mocking the java.time API for Better Testability
  • Pull Request vs. Merge Request
  • Exploring a Paradigm Shift for Relational Database Schema Changes

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo