Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is debugging better in an IDE? [closed]

Tags:

debugging

ide

People also ask

How do Ides make debugging easier?

An IDE debugger lets you change the values of variables at run-time. An IDE debugger lets you see the value of variables you didn't know you wanted to see when execution began. An IDE debugger lets you conditionally break execution at any point in code, based on a condition, not a line number.

How does an IDE help debug?

The debugger component of an IDE typically provides the programmer with the capability to view memory and see variables, run the program to the next breakpoint, execute just the next line of code, and, in some cases, change the value of variables or even change the contents of the line of code about to be executed.

Why is debugging so hard in software testing?

Debugging itself is a very difficult process because of the involvement of humans. Another reason due to which it is considered as difficult because it consumes a large amount of time and resources too.


Some examples of some abilities that an IDE debugger will give you over trace messages in code:

  • View the call stack at any point in time, giving you a context for your current stack frame.
  • Step into libraries that you are not able to re-compile for the purposes of adding traces (assuming you have access to the debug symbols)
  • Change variable values while the program is running
  • Edit and continue - the ability to change code while it is running and immediately see the results of the change
  • Be able to watch variables, seeing when they change
  • Be able to skip or repeat sections of code, to see how the code will perform. This allows you to test out theoretical changes before making them.
  • Examine memory contents in real-time
  • Alert you when certain exceptions are thrown, even if they are handled by the application.
  • Conditional breakpointing; stopping the application only in exceptional circumstances to allow you to analyse the stack and variables.
  • View the thread context in multi-threaded applications, which can be difficult to achieve with tracing (as the traces from different threads will be interleaved in the output).

In summary, print statements are (generally) static and you'll need to re-compile to get additional information if your original statements weren't detailed enough. The IDE removes this static barrier, giving you a dynamic toolkit at your fingertips.

When I first started coding, I couldn't understand what the big deal with debuggers was and I thought I could achieve anything with tracing (granted, that was on unix and the debugger was GDB). But once you learn how to properly use a graphical debugger, you don't want to go back to print statements.


  • An IDE debugger lets you change the values of variables at run-time.

  • An IDE debugger lets you see the value of variables you didn't know you wanted to see when execution began.

  • An IDE debugger lets you see the call stack and examine the state of the function passed weird values. (think this function is called from hundreds of places, you don't know where these weird values are coming from)

  • An IDE debugger lets you conditionally break execution at any point in code, based on a condition, not a line number.

  • An IDE debugger will let you examine the state of the program in the case of an unhandled exception instead of just crapping out.


Here's one thing that you definitely cannot debug with "print" statement, which is when a customer brings you memory dump and says "your program crashed, can you tell me why?"


  • Print statements all through your code reduces readability.
  • Adding and removing them for debug purposes only is time consuming
  • Debuggers track the call stack making it easy to see where you are
  • Variables can be modified on the fly
  • Adhoc commands can be executed during a pause in execution to assist diagnosing
  • Can be used IN CONJUNCTION with print statements : Debug.Write("...")

I think debugging using print statements is a lost art, and very important for every developer to learn. Once you know how to do that, certain classes of bugs become much easier to debug that way than through an IDE. Programmers who know this technique also have a really good feel of what's useful information to put in a log message (not to mention you'll actually end up reading the log) for non-debugging purposes as well.

That said, you really should know how to use the step-through debugger, since for a different class of bugs it is WAY easier. I'll leave it up to the other excellent answers already posted to explain why :)


Off the top of my head:

  1. Debugging complex objects - Debuggers allow you to step deep into an object's innards. If your object has, say, an array of array of complex objects, print statements will only get you so far.
  2. The ability to step past code - Debuggers will also allow you to skip past code you don't want to execute. True, you could do this manually as well, but it's that much more code you have to inject.

As alternative to debug in IDE you can try great Google Chrome extension PHP Console with php library that allows to:

  • See errors & exception in Chrome JavaScript console & in notification popups.
  • Dump any type variable.
  • Execute PHP code remotely.
  • Protect access by password.
  • Group console logs by request.
  • Jump to error file:line in your text editor.
  • Copy error/debug data to clipboard (for testers).