Debugger always comes handy when you are writing complex program and you get stuck with logical bug in the program. Most programs scratch their mind when tracking bug. Sometimes its easy to catch problem sometimes it takes hours to figure it out. But if you know how to use debugger you can track the problem easily and quicker.
Having said that, We are glad to announce that now you can debug python program with OnlineGDB IDE. Some of python programmer would be knowing about PDB debugger module. We have built an easy to use web interface for debugging python program running under PDB debugger.
How to start python program in debug mode?
Goto OnlineGDB IDE. Click on “Debug” button on top bar. And there you go, it will open PDB debug console and other helping windows (e.g. call stack, local variables, breakpoints)
What can I do in debug mode?
1. Set/clear breakpoints
2. Step by step execution of program
3. See local variables
4. PDB console is available in debug mode, you can enter any pdb command in console
If you are new to programming world, then its possible that you may not have heard of debugger. Well, in this article I will explain OnlineGDB debugger usage in brief.
What is Debugger?
In general, debugger is utility that runs target program in controlled environment where you can control execution of program and see the state of program when program is paused. GDB is such debugger, which is used to debug C/C++ programs. OnlineGDB provides an interface to use GDB in cloud environment from your browser.
How can I control execution of program?
We can tell debugger when to pause a program by setting breakpoints.
To set a breakpoint, click on blank area seen on left side of line number in editor. When you click it, it should display red circle; which means breakpoint is set on that line number. Here is image of how it looks like.
Once you set breakpoint, when you start program in debug mode, it will pause execution when program reaches the line where breakpoint is set.
Now we can use stepping commands to execute program line by line.
1. continue – Resume program execution until next breakpoint is reached
2. step into – Execute program line by line stepping into function
3. step over – Execute program line by line but don’t go inside function call
4. step out – Resume program execution until current function is finished
What can I see when program is paused? You can see call stack and values of local variables of current function.call stack shows you chain of function calls. As seen in below image, “main” function is calling function “factorial” and “factorial” is calling function “multiply”.
Local variables window shows you values of local variables of current function. As shown in image below, value of “fact” is 1, “i” is 1.
Here is single image depicting usage of OnlineGDB debugger.
Now we have control and eye on program execution, so we can inspect program execution flow. Breakpoints, stepping commands and variables displays are basic feature of debugger. In future, I will post more features helpful for debugging.
We listened to our users those who wanted to run multifile C++ projects and here we are with support of multifile project. Now you can create multiple file for single project and can run as a single project.
You can create new file either by pressing “Ctrl + M” or “New file” button from control-bar on top.