IDEs and Debugging
Arash Bakhtiari
[email protected]
2012-11-06 Tue
Outline
IDEs
Introduction To Eclipse CDT
Debugging Concepts And Vocabulary
What are IDEs
IDE( Integrated development environment ):
I collection of facilities with graphical interface ( Text
Editor, Compile and Build, Debugging Tools )
I examples: Eclipse, Code::Blocks, NetBeans, Qt Creator,
MS Visual Studio
Advantages and Disadvantages
Advantages:
I
less time and effort: helps you organize resources,
prevent mistakes, and provide shortcuts
project management: ( documentation tools, visual
presentation of resources )
Disadvantage:
I
using graphical interface requires more memory and
processing power
will not fix bad code, practices, or design( sometimes
cause bad code!!! )
Installing Eclipse CDT
Eclipse CDT: provides a fully functional C and C++ IDE
based on the Eclipse platform.
Installing on Ubuntu:
I
sudo apt-get install eclipse-cdt
Installing on Windows:
I
I
go to the link: http://www.eclipse.org/downloads/
download Eclipse IDE for C/C++ Developers
Eclipse User Interface Overview
Perspective
I
I
I
I
Perspective: a visual container for a set of window parts.
eclipse uses perspectives to arrange windows parts for
different development tasks
switch Perspectives via the Window Open Perspective
change the layout and content within a Perspective
Toolbar
I
contains actions which you typically perform
Project Explorer
I
browse the structure of your projects and to open files via
double-click
change the structure of your project, e.g. you can rename
files or move files or folder via drag and drop.
Outline View
I
shows the structure of the currently selected source file
Some Cool Features of Eclipse
I
I
I
I
I
Code Auto-completion: Ctrl - Space
Code Formatting: Ctrl - Shift - f
Code Refactoring (Renaming): Shift - Alt - r
Commenting a block of code: Ctrl - /
and many others ...
Create Your First C++ Program in Eclipse
DEMO
What is Debugging?
debugging is the process of locating and fixing bugs
(errors)
normally no way to see the source code of a program
while the program is running!!!!
by using debuggers we can look under the covers while
the program is running
Why we need debuggers?
A debugger enables you:
I seeing the source code during the execution of a
statement
I pause the execution at any place in the source code
I see and change the internal state of the program while
the program is paused
I continue the execution
I Some of the basic debugging concepts: call stack,
(conditional) breakpoint, stepping
Call Stack
I
I
I
I
programs generally call functions
one function can call another, or a function can call itself
(recursion)
chain of called functions as a stack of executing functions
( call stack )
currently running function is the topmost one on the stack
For each function on the call stack, the system maintains
a data area stack frame
I
contains the functions parameters, local variables, return
value and information needed to manage the call stack
Breakpoint
I
I
a breakpoint is where the execution of the program
should break off (stop)
you can take over control of the programs execution after
the program reached the breakpoint
you can add and remove as many breakpoints as you like
in addition to normal breakpoints: conitional breakpoints
and watchpoints
Conditional Breakpoints
I
Normal Breakpoints: program execution should stop
when a certain point in the code is reached
Watchpoints: program execution should stop when a data
value is changed
I
useful when a variable receives a wrong value and its
hard to track down where this happens just by looking at
the code
Conditional Breakpoints: program execution should stop
at the breakpoint only if a certain condition is met (for
example X > 100)
I
useful for example in a loop: allow a loop to run 100
times before breaking.
Stepping
I
Stepping is the process of running one statement at a
time
Step Into: Executes the current statement if the current
statement is a function, then the debugger steps into that
function otherwise it stops at the next statement
Step Over: Executes the current statement If the current
statement is a function, then the debugger executes the
whole function, and it stops at the next statement after
the function call.
Step Out: Steps out of the current function and up one
level if the function is nested
Continue: Continues execution to the end, or to the next
breakpoint
Using Eclipse For Debugging