SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
1/20
Outline Introduction Debugging Common Acronymes
Debugging
Debugging with NetBeans IDE
Andreas Ruppen
andreas.ruppen@unifr.ch
University of Fribourg
Department of Informatics
Software Engineering Group
April 18, 2014
2/20
Outline Introduction Debugging Common Acronymes
1 Introduction
2 Debugging
3 Common Acronymes
3/20
Outline Introduction Debugging Common Acronymes
Generalities I
Definition (Debugging)
Debugging is the process of identifying and eliminating bugs in
a software system. Debugging can be a quite complex process
especially when systems are distributed, deployed or tightly
coupled.
Generalities
In general debugging is done with the aid of some software.
This is what we call interactive debugging. This software can
control the program flow, watch log files or memory dumps and
much more.
4/20
Outline Introduction Debugging Common Acronymes
Generalities II
Origin (Wikipedia)
The terms "bug" and "debugging" are both popularly attributed
to Admiral Grace Hopper in the 1940s. While she was working
on a Mark II Computer at Harvard University, her associates
discovered a moth stuck in a relay and thereby impeding
operation, whereupon she remarked that they were "debugging"
the system. However the term "bug" in the meaning of technical
error dates back at least to 1878 and Thomas Edison.
5/20
Outline Introduction Debugging Common Acronymes
Generalities III
Figure : First Bug (from wikipedia.org)
6/20
Outline Introduction Debugging Common Acronymes
Difficulties I
The debugging skills of the programmer are a major factor
when it comes to eliminating bugs.
Software tends to become more and more complex which
makes debugging harder.
Mobile devices also introduces new challenges for
debugging. The code is run and developed on different
machines.
High-level languages such as Java are easier to debug
than low level languages like C.
Bugs may occur through memory corruption which is
difficult to track. This comes from the fact that the thrown
error is not necessary the origin of the problem.
7/20
Outline Introduction Debugging Common Acronymes
Types of Debugging
Interactive Debugging Software
Debugging software monitors the flow of the program. It can
also modify this flow, inspect and change attribute values,
pausing the execution at predefined locations, influence the
outcome of branches and switch statements etc. . .
Static Debugging Software
Instead of running the software and closely observe its
execution, some tools look statically at the code to identify
potential problems. These static code analysis tools come
handy to identify problems which are hard to reproduce like
memory leaks. It is most useful to pinpoint erroneous pointers,
infinite recursive structures.
8/20
Outline Introduction Debugging Common Acronymes
Debugging techniques I
for interactive debugging
A first step in debugging is to reproduce the problem. This
sounds trivial but can become quite complex in the case of
memory leaks, distributed systems, multithreaded systems
etc. . . A good bug report always includes the precise steps
to reproduce the problem.
Once the problem reproduced, to make debugging easier,
the input is simplified (the bug could come from a too large
input file for example, if the smaller file passes the problem
is found). These simplifications are the most time made
manually (divide-and-conquer). Smaller input also allows
faster debugging (think of a large for-loop iterating over
each line of a file).
9/20
Outline Introduction Debugging Common Acronymes
Debugging techniques II
for interactive debugging
From this point on, a developer has several choices to
precisely identify the problem:
He can use a debugging tool (like gdb or one integrated in
the IDE) to examine the memory and the local variables at
some interesting points of the program.
Another method is to use tracing (think about last weeks
logging).
Post-mortem debugging, which consists of memory dump
analysis
Remote debugging for deployed applications.
10/20
Outline Introduction Debugging Common Acronymes
Debugging in NetBeans IDE
Use Case
What is debugging?
Run through the code with the interpreter.
Allows to see whether the execution path is as expected.
Using the Debugger
We can use the debugger:
to verify if a programm behaves as we except.
to identify the nature of a runtime-error.
to force the programm entering a given state.
11/20
Outline Introduction Debugging Common Acronymes
Debugging in NetBeans IDE
Howto
Fist steps
Open a project in NetBeans IDE.
Define the Breakpoints at some interesting points.
Start the Debugger
Debugging mode
Runs the code with the Java virtual machine.
Everything that is possible in normal mode, should also be
possible in debugging mode.
Execution stops for user action at the defined breakpoints.
12/20
Outline Introduction Debugging Common Acronymes
Breakpoints I
Defining Breakpoints
Definition (Breakpoint)
A Breakpoint is an indication for the Java Debugger. They are
ignored by the Java virtual machine when running in normal
mode. However when running in debug mode, the execution
stops at every breakpoint and waits for a user action before it
continues to the next break points.
13/20
Outline Introduction Debugging Common Acronymes
Breakpoints II
Defining Breakpoints
Actions
When the execution of the programm stops at a breakpoint
following actions are possible:
Inspection or modification of dynamic variables.
Step-by-step execution.
Go to the next breakpoint (or to the end of the application if
there are no more breakpoints).
14/20
Outline Introduction Debugging Common Acronymes
Breakpoints in NetBeans IDE
Defining breakpoints
Example (Usage)
Define a Breakpoint by
clicking on the
corresponding line.
The line number is
replaced by a red
square.
It’s not possible to define
breakpoints on non
executable lines (i.e.
commentary lines)
15/20
Outline Introduction Debugging Common Acronymes
Running the Debugger
The ANT way
Debug Target
The ANT file which comes with the exercises provides a
debug target.
This target can be launched manually (by right clicking on
the build.xml file in NetBeans IDE).
It is possible to launch the debugger from command line
with the following arguments
1 −Xrunjdwp : transport =dt_socket , server=y , suspend=n , address=5432
which makes it listening on port 5432 for a debugging tool
like the one integrated in NetBeans IDE.
16/20
Outline Introduction Debugging Common Acronymes
Running the Debugger
The NetBeans IDE way
Debugging with and IDE
It is possible (and even recommended) to do the
debugging tasks directly from the IDE.
NetBeans IDE offers a great debugging support.
To launch the debugger, either click the debug icon in the
launch bar (the 6th one), or select the debug target from
the ANT script or select debug from the right click on the
project.
Once started the program starts as normal but the
execution stops at the first breakpoint.
17/20
Outline Introduction Debugging Common Acronymes
The debugging console
NetBeans IDE layout
When the debugger is
started in NetBeans IDE
a new tab becomes
visible.
This tab is updated on
each step of the
debugger.
It shows the value of all fields of the current class.
Besides inspecting the value of each field, it is also
possible to change them.
18/20
Outline Introduction Debugging Common Acronymes
Using the NetBeans IDE Debugger
Associated GUI Elements
When the debugger stops
on a line, this line is
highlighted green.
All other debugging GUI elements relate to this line or the
class containing this line.
19/20
Outline Introduction Debugging Common Acronymes
Using the NetBeans IDE Debugger
Associated GUI Elements
When everyhting seems ok to continue, NetBeans IDE offers
several buttons for going on:
Stop (the debugger)
Pause
Continue (to next
Breakpoint)
Step Over
Step over Expression
Step into
Step out
Run to cursor
Apply Code Change
Take GUI Snapshot
20/20
Outline Introduction Debugging Common Acronymes
Used acronyms
IDE Integrated Development Environment
gdb GNU Debugger
GNU GNU is not Unix

Contenu connexe

Tendances

Netbeans
NetbeansNetbeans
Netbeansacosdt
 
Software Engineering tools
Software Engineering tools Software Engineering tools
Software Engineering tools imran khan
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
Debugging in visual studio (basic level)
Debugging in visual studio (basic level)Debugging in visual studio (basic level)
Debugging in visual studio (basic level)Larry Nung
 
Software Engineering - chp8- deployment
Software Engineering - chp8- deploymentSoftware Engineering - chp8- deployment
Software Engineering - chp8- deploymentLilia Sfaxi
 
Java collections concept
Java collections conceptJava collections concept
Java collections conceptkumar gaurav
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Sandeep Rawat
 
Java Introduction
Java IntroductionJava Introduction
Java Introductionjaveed_mhd
 
Web Engineering - Web Application Testing
Web Engineering - Web Application TestingWeb Engineering - Web Application Testing
Web Engineering - Web Application TestingNosheen Qamar
 
Project Planning in Software Engineering
Project Planning in Software EngineeringProject Planning in Software Engineering
Project Planning in Software EngineeringFáber D. Giraldo
 
Chapter 5 software design
Chapter 5 software designChapter 5 software design
Chapter 5 software designPiyush Gogia
 
Eclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONEclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONAYESHA JAVED
 
Event handling
Event handlingEvent handling
Event handlingswapnac12
 
Jetpack Navigation Component
Jetpack Navigation ComponentJetpack Navigation Component
Jetpack Navigation ComponentJames Shvarts
 
Five Common Mistakes made when Conducting a Software FMECA
Five Common Mistakes made when Conducting a Software FMECAFive Common Mistakes made when Conducting a Software FMECA
Five Common Mistakes made when Conducting a Software FMECAAnn Marie Neufelder
 

Tendances (20)

Netbeans
NetbeansNetbeans
Netbeans
 
Software Engineering tools
Software Engineering tools Software Engineering tools
Software Engineering tools
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Debugging in visual studio (basic level)
Debugging in visual studio (basic level)Debugging in visual studio (basic level)
Debugging in visual studio (basic level)
 
Software Engineering - chp8- deployment
Software Engineering - chp8- deploymentSoftware Engineering - chp8- deployment
Software Engineering - chp8- deployment
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Android UI
Android UIAndroid UI
Android UI
 
Web Engineering - Web Application Testing
Web Engineering - Web Application TestingWeb Engineering - Web Application Testing
Web Engineering - Web Application Testing
 
Project Planning in Software Engineering
Project Planning in Software EngineeringProject Planning in Software Engineering
Project Planning in Software Engineering
 
Chapter 5 software design
Chapter 5 software designChapter 5 software design
Chapter 5 software design
 
Eclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONEclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATION
 
Java API
Java APIJava API
Java API
 
Event handling
Event handlingEvent handling
Event handling
 
Jetpack Navigation Component
Jetpack Navigation ComponentJetpack Navigation Component
Jetpack Navigation Component
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
Software testing
Software testingSoftware testing
Software testing
 
Five Common Mistakes made when Conducting a Software FMECA
Five Common Mistakes made when Conducting a Software FMECAFive Common Mistakes made when Conducting a Software FMECA
Five Common Mistakes made when Conducting a Software FMECA
 
Applet programming
Applet programming Applet programming
Applet programming
 

Similaire à Debugging with NetBeans IDE

debuggingSession.pptx
debuggingSession.pptxdebuggingSession.pptx
debuggingSession.pptxmarawanwael
 
Gui based debuggers
Gui based debuggers Gui based debuggers
Gui based debuggers Mysa Vijay
 
Debuggers in system software
Debuggers in system softwareDebuggers in system software
Debuggers in system softwaregayathri ravi
 
How to debugging
How to debuggingHow to debugging
How to debuggingSiya Lee
 
Reverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentalsReverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentalsEran Goldstein
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyBrian Lyttle
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmerLeylimYaln
 
Stnotes doc 5
Stnotes doc 5Stnotes doc 5
Stnotes doc 5Alok Jain
 
WhitePaperTemplate
WhitePaperTemplateWhitePaperTemplate
WhitePaperTemplateJo Marques
 
debugging (1).ppt
debugging (1).pptdebugging (1).ppt
debugging (1).pptjerlinS1
 
An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...jeyasrig
 
Anti-Debugging - A Developers View
Anti-Debugging - A Developers ViewAnti-Debugging - A Developers View
Anti-Debugging - A Developers ViewTyler Shields
 
UNIT 3.1 INTRODUCTON TO IDA.ppt
UNIT 3.1 INTRODUCTON TO IDA.pptUNIT 3.1 INTRODUCTON TO IDA.ppt
UNIT 3.1 INTRODUCTON TO IDA.pptManjuAppukuttan2
 

Similaire à Debugging with NetBeans IDE (20)

debuggingSession.pptx
debuggingSession.pptxdebuggingSession.pptx
debuggingSession.pptx
 
Gui based debuggers
Gui based debuggers Gui based debuggers
Gui based debuggers
 
Debuggers in system software
Debuggers in system softwareDebuggers in system software
Debuggers in system software
 
Debugging
DebuggingDebugging
Debugging
 
Ss debuggers
Ss debuggersSs debuggers
Ss debuggers
 
How to debugging
How to debuggingHow to debugging
How to debugging
 
Reverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentalsReverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentals
 
Jdj Foss Java Tools
Jdj Foss Java ToolsJdj Foss Java Tools
Jdj Foss Java Tools
 
Debugging in .Net
Debugging in .NetDebugging in .Net
Debugging in .Net
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp Philly
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmer
 
PROBLEM SOLVING
PROBLEM SOLVINGPROBLEM SOLVING
PROBLEM SOLVING
 
Stnotes doc 5
Stnotes doc 5Stnotes doc 5
Stnotes doc 5
 
WhitePaperTemplate
WhitePaperTemplateWhitePaperTemplate
WhitePaperTemplate
 
Intro To AOP
Intro To AOPIntro To AOP
Intro To AOP
 
debugging (1).ppt
debugging (1).pptdebugging (1).ppt
debugging (1).ppt
 
An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...
 
Anti-Debugging - A Developers View
Anti-Debugging - A Developers ViewAnti-Debugging - A Developers View
Anti-Debugging - A Developers View
 
Debugging
DebuggingDebugging
Debugging
 
UNIT 3.1 INTRODUCTON TO IDA.ppt
UNIT 3.1 INTRODUCTON TO IDA.pptUNIT 3.1 INTRODUCTON TO IDA.ppt
UNIT 3.1 INTRODUCTON TO IDA.ppt
 

Plus de Andreas Ruppen

A component based architecture for the Web of Things
A component based architecture for the Web of ThingsA component based architecture for the Web of Things
A component based architecture for the Web of ThingsAndreas Ruppen
 
Thesis Defence: A Model Driven Architecture for the Web of Things
Thesis Defence: A Model Driven Architecture for the Web of ThingsThesis Defence: A Model Driven Architecture for the Web of Things
Thesis Defence: A Model Driven Architecture for the Web of ThingsAndreas Ruppen
 
A Model-Driven, Component Generation Approach for the Web of Things
A Model-Driven, Component Generation Approach for the Web of ThingsA Model-Driven, Component Generation Approach for the Web of Things
A Model-Driven, Component Generation Approach for the Web of ThingsAndreas Ruppen
 
A proof of concept implementation of a secure e-commerce authentication scheme
A proof of concept implementation of a secure e-commerce authentication schemeA proof of concept implementation of a secure e-commerce authentication scheme
A proof of concept implementation of a secure e-commerce authentication schemeAndreas Ruppen
 
A model-driven, component generation approach for the xWoT
A model-driven, component generation approach for the xWoTA model-driven, component generation approach for the xWoT
A model-driven, component generation approach for the xWoTAndreas Ruppen
 
An Approach for a Mutual Integration of the WoT with Business Processes
An Approach for a Mutual Integration of the WoT with Business ProcessesAn Approach for a Mutual Integration of the WoT with Business Processes
An Approach for a Mutual Integration of the WoT with Business ProcessesAndreas Ruppen
 
A WoT Approach to eHealth
A WoT Approach to eHealthA WoT Approach to eHealth
A WoT Approach to eHealthAndreas Ruppen
 
A RESTful architecture for integrating decomposable delayed services within t...
A RESTful architecture for integrating decomposable delayed services within t...A RESTful architecture for integrating decomposable delayed services within t...
A RESTful architecture for integrating decomposable delayed services within t...Andreas Ruppen
 

Plus de Andreas Ruppen (10)

A component based architecture for the Web of Things
A component based architecture for the Web of ThingsA component based architecture for the Web of Things
A component based architecture for the Web of Things
 
Thesis Defence: A Model Driven Architecture for the Web of Things
Thesis Defence: A Model Driven Architecture for the Web of ThingsThesis Defence: A Model Driven Architecture for the Web of Things
Thesis Defence: A Model Driven Architecture for the Web of Things
 
Presentation evrythng
Presentation evrythngPresentation evrythng
Presentation evrythng
 
A Model-Driven, Component Generation Approach for the Web of Things
A Model-Driven, Component Generation Approach for the Web of ThingsA Model-Driven, Component Generation Approach for the Web of Things
A Model-Driven, Component Generation Approach for the Web of Things
 
A proof of concept implementation of a secure e-commerce authentication scheme
A proof of concept implementation of a secure e-commerce authentication schemeA proof of concept implementation of a secure e-commerce authentication scheme
A proof of concept implementation of a secure e-commerce authentication scheme
 
A model-driven, component generation approach for the xWoT
A model-driven, component generation approach for the xWoTA model-driven, component generation approach for the xWoT
A model-driven, component generation approach for the xWoT
 
REST and eHealth
REST and eHealthREST and eHealth
REST and eHealth
 
An Approach for a Mutual Integration of the WoT with Business Processes
An Approach for a Mutual Integration of the WoT with Business ProcessesAn Approach for a Mutual Integration of the WoT with Business Processes
An Approach for a Mutual Integration of the WoT with Business Processes
 
A WoT Approach to eHealth
A WoT Approach to eHealthA WoT Approach to eHealth
A WoT Approach to eHealth
 
A RESTful architecture for integrating decomposable delayed services within t...
A RESTful architecture for integrating decomposable delayed services within t...A RESTful architecture for integrating decomposable delayed services within t...
A RESTful architecture for integrating decomposable delayed services within t...
 

Dernier

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 

Dernier (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

Debugging with NetBeans IDE

  • 1. 1/20 Outline Introduction Debugging Common Acronymes Debugging Debugging with NetBeans IDE Andreas Ruppen andreas.ruppen@unifr.ch University of Fribourg Department of Informatics Software Engineering Group April 18, 2014
  • 2. 2/20 Outline Introduction Debugging Common Acronymes 1 Introduction 2 Debugging 3 Common Acronymes
  • 3. 3/20 Outline Introduction Debugging Common Acronymes Generalities I Definition (Debugging) Debugging is the process of identifying and eliminating bugs in a software system. Debugging can be a quite complex process especially when systems are distributed, deployed or tightly coupled. Generalities In general debugging is done with the aid of some software. This is what we call interactive debugging. This software can control the program flow, watch log files or memory dumps and much more.
  • 4. 4/20 Outline Introduction Debugging Common Acronymes Generalities II Origin (Wikipedia) The terms "bug" and "debugging" are both popularly attributed to Admiral Grace Hopper in the 1940s. While she was working on a Mark II Computer at Harvard University, her associates discovered a moth stuck in a relay and thereby impeding operation, whereupon she remarked that they were "debugging" the system. However the term "bug" in the meaning of technical error dates back at least to 1878 and Thomas Edison.
  • 5. 5/20 Outline Introduction Debugging Common Acronymes Generalities III Figure : First Bug (from wikipedia.org)
  • 6. 6/20 Outline Introduction Debugging Common Acronymes Difficulties I The debugging skills of the programmer are a major factor when it comes to eliminating bugs. Software tends to become more and more complex which makes debugging harder. Mobile devices also introduces new challenges for debugging. The code is run and developed on different machines. High-level languages such as Java are easier to debug than low level languages like C. Bugs may occur through memory corruption which is difficult to track. This comes from the fact that the thrown error is not necessary the origin of the problem.
  • 7. 7/20 Outline Introduction Debugging Common Acronymes Types of Debugging Interactive Debugging Software Debugging software monitors the flow of the program. It can also modify this flow, inspect and change attribute values, pausing the execution at predefined locations, influence the outcome of branches and switch statements etc. . . Static Debugging Software Instead of running the software and closely observe its execution, some tools look statically at the code to identify potential problems. These static code analysis tools come handy to identify problems which are hard to reproduce like memory leaks. It is most useful to pinpoint erroneous pointers, infinite recursive structures.
  • 8. 8/20 Outline Introduction Debugging Common Acronymes Debugging techniques I for interactive debugging A first step in debugging is to reproduce the problem. This sounds trivial but can become quite complex in the case of memory leaks, distributed systems, multithreaded systems etc. . . A good bug report always includes the precise steps to reproduce the problem. Once the problem reproduced, to make debugging easier, the input is simplified (the bug could come from a too large input file for example, if the smaller file passes the problem is found). These simplifications are the most time made manually (divide-and-conquer). Smaller input also allows faster debugging (think of a large for-loop iterating over each line of a file).
  • 9. 9/20 Outline Introduction Debugging Common Acronymes Debugging techniques II for interactive debugging From this point on, a developer has several choices to precisely identify the problem: He can use a debugging tool (like gdb or one integrated in the IDE) to examine the memory and the local variables at some interesting points of the program. Another method is to use tracing (think about last weeks logging). Post-mortem debugging, which consists of memory dump analysis Remote debugging for deployed applications.
  • 10. 10/20 Outline Introduction Debugging Common Acronymes Debugging in NetBeans IDE Use Case What is debugging? Run through the code with the interpreter. Allows to see whether the execution path is as expected. Using the Debugger We can use the debugger: to verify if a programm behaves as we except. to identify the nature of a runtime-error. to force the programm entering a given state.
  • 11. 11/20 Outline Introduction Debugging Common Acronymes Debugging in NetBeans IDE Howto Fist steps Open a project in NetBeans IDE. Define the Breakpoints at some interesting points. Start the Debugger Debugging mode Runs the code with the Java virtual machine. Everything that is possible in normal mode, should also be possible in debugging mode. Execution stops for user action at the defined breakpoints.
  • 12. 12/20 Outline Introduction Debugging Common Acronymes Breakpoints I Defining Breakpoints Definition (Breakpoint) A Breakpoint is an indication for the Java Debugger. They are ignored by the Java virtual machine when running in normal mode. However when running in debug mode, the execution stops at every breakpoint and waits for a user action before it continues to the next break points.
  • 13. 13/20 Outline Introduction Debugging Common Acronymes Breakpoints II Defining Breakpoints Actions When the execution of the programm stops at a breakpoint following actions are possible: Inspection or modification of dynamic variables. Step-by-step execution. Go to the next breakpoint (or to the end of the application if there are no more breakpoints).
  • 14. 14/20 Outline Introduction Debugging Common Acronymes Breakpoints in NetBeans IDE Defining breakpoints Example (Usage) Define a Breakpoint by clicking on the corresponding line. The line number is replaced by a red square. It’s not possible to define breakpoints on non executable lines (i.e. commentary lines)
  • 15. 15/20 Outline Introduction Debugging Common Acronymes Running the Debugger The ANT way Debug Target The ANT file which comes with the exercises provides a debug target. This target can be launched manually (by right clicking on the build.xml file in NetBeans IDE). It is possible to launch the debugger from command line with the following arguments 1 −Xrunjdwp : transport =dt_socket , server=y , suspend=n , address=5432 which makes it listening on port 5432 for a debugging tool like the one integrated in NetBeans IDE.
  • 16. 16/20 Outline Introduction Debugging Common Acronymes Running the Debugger The NetBeans IDE way Debugging with and IDE It is possible (and even recommended) to do the debugging tasks directly from the IDE. NetBeans IDE offers a great debugging support. To launch the debugger, either click the debug icon in the launch bar (the 6th one), or select the debug target from the ANT script or select debug from the right click on the project. Once started the program starts as normal but the execution stops at the first breakpoint.
  • 17. 17/20 Outline Introduction Debugging Common Acronymes The debugging console NetBeans IDE layout When the debugger is started in NetBeans IDE a new tab becomes visible. This tab is updated on each step of the debugger. It shows the value of all fields of the current class. Besides inspecting the value of each field, it is also possible to change them.
  • 18. 18/20 Outline Introduction Debugging Common Acronymes Using the NetBeans IDE Debugger Associated GUI Elements When the debugger stops on a line, this line is highlighted green. All other debugging GUI elements relate to this line or the class containing this line.
  • 19. 19/20 Outline Introduction Debugging Common Acronymes Using the NetBeans IDE Debugger Associated GUI Elements When everyhting seems ok to continue, NetBeans IDE offers several buttons for going on: Stop (the debugger) Pause Continue (to next Breakpoint) Step Over Step over Expression Step into Step out Run to cursor Apply Code Change Take GUI Snapshot
  • 20. 20/20 Outline Introduction Debugging Common Acronymes Used acronyms IDE Integrated Development Environment gdb GNU Debugger GNU GNU is not Unix