SlideShare une entreprise Scribd logo
1  sur  15
© Copyright 2013, wavedigitech.com.
Latest update: June 15, 2013,
http://www.wavedigitech.com/
Call us on : 91-9632839173
E-Mail : info@wavedigitech.com
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
Presentation on ARM Basics
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
Presentation on
GDB
Presentation on ARM Basics
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
The GNU Debugger, usually called just GDB it is a portable debugger that runs
on many Unix-like systems and works for many programming
languages, including Ada, C, C++, Objective-C, Free Pascal, Fortran, Java and
partially others.
GDB offers extensive facilities for tracing and altering the execution of
computer programs. The user can monitor and modify the values of programs'
internal variables, and even call functions independently of the program's
normal behavior.
Remote debugging
GDB offers a 'remote' mode often used when debugging embedded
systems. Remote operation is when GDB runs on one machine and the
program being debugged runs on another.
The GNU Debugger
Compiling for debugging
• We usually compile a program as
gcc [flags] <source files> -o <output file>
• A -g option is added to enable the built-in debugging support
(which gdb needs):
gcc [other flags] -g <source files> -o <output file>
Ex: gcc -Wall -Werror -ansi -pedantic-errors -g prog1.c -o prog1.x
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
Starting up gdb
• To get the gdb prompt, type “gdb”
• The program to be debugged now is loaded using
(gdb) file prog1.x
• Here, prog1.x is the program you want to load, and “file” is
the command to load it.
• To run the program, we use
(gdb) run
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
Setting breakpoints
• Breakpoints can be used to stop the program run in the middle,
at a designated point. The simplest way is the command
“break.” This sets a breakpoint at a specified file-line pair
(gdb) break file1.c:6
• This sets a breakpoint at line 6, of file1.c. Now, if the program
ever reaches that location when running, the program will
pause and prompt you for another command.
• To break at a particular function, we use
(gdb) break function
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
• We can proceed onto the next breakpoint by typing “continue”
(gdb) continue
• step Executes the current line of the program and stops on the next
statement to be executed
(gdb) step
• Like step, however, if the current line of the program contains a
function call, it executes the function and stops at the next line.
(gdb) next
• Until is like next, except that if you are at the end of a loop, until will
continue execution until the loop is exited, whereas next will just take
you back up to the beginning of the loop. This is convenient if you
want to see what happens after the loop, but don't want to step through
every iteration.
(gdb) until
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
Print and Watchpoints
• The print command prints the value of the variable specified, and
print/x prints the value in hexadecimal:
(gdb) print variable
(gdb) print/x variable
• We can also modify variables' values by
(gdb) set < variable > = <value>
• Whereas breakpoints interrupt the program at a particular line or
function, watchpoints act on variables. They pause the program
whenever a watched variable’s value is modified.
(gdb) watch variable
• Now, whenever my var’s value is modified, the program will
interrupt and print out the old and new values.
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
• backtrace - produces a stack trace of the function calls that
lead to a segmentation fault
• where - same as backtrace; you can think of this version as
working even when you’re still in the middle of the program
• finish - runs until the current function is finished
• delete N - deletes a specified N breakpoint
• info breakpoints - shows information about all declared
breakpoints
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
info commands for examining
runtime debugger state:
• gdb has a large set of info X commands for displaying information about
different types of runtime state and about debugger state. Here is how to list
all the info commands in help, and a description of what a few of the info
commands do:
• (gdb) help status lists a bunch of info X commands
• (gdb) info frame list information about the current stack
frame
• (gdb) info locals list local variable values of current stack
frame
• (gdb) info args list argument values of current stack frame
• (gdb) info registers list register values
• (gdb) info breakpoints list status of all breakpoints
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
.
• (gdb) up – Move to the function that called the present function. Useful if
your program crashes in a library function; use up to get to the last function
call in your program
• (gdb) down – Reverses the action of up
• (gdb) delete – Removes breakpoint by number (see example following). If
no number, all deleted.
• (gdb) kill – Terminates the program.
• (gdb) list – List 10 lines of the program being debugged. The sixth line is
the preset statement. Subsequent, consecutive entry of list will list the next
10 lines.
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
Breakpoints
• In this, we get to specify some criterion that must be met for
the breakpoint to trigger. We use the same break command as
before:
(gdb) break file1.c:6 if i >= ARRAYSIZE
• This command sets a breakpoint at line 6 of file file1.c, which
triggers only if the variable i is greater than or equal to the size
of the array
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
Using pointers with gdb
• Suppose we’re in gdb, and are at some point in the execution
after a line that looks like:
struct entry * e1 = <something>;
• To see the value (memory address) of the pointer:
(gdb) print e1
• To see a particular field of the struct the pointer is referencing:
(gdb) print e1->key
(gdb) print e1->name
(gdb) print e1->price
(gdb) print e1->serial number
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
• We can also use the dereference (*) and dot (.) operators in
place of the arrow operator (->):
(gdb) print (*e1).key
(gdb) print (*e1).name
(gdb) print (*e1).price
(gdb) print (*e1).serial number
• To see the entire contents of the struct the pointer references
(gdb) print *e1
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
Using pointers with gdb
Thank You
© Copyright 2013, wavedigitech.com.
Latest update: June 30, 2013,
http://www.wavedigitech.com/
Call us on : +91-91-9632839173
E-Mail : info@wavedigitech.com
E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173

Contenu connexe

Similaire à Wavedigitech gdb

Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handoutSuraj Kumar
 
gdb-tutorial.pdf
gdb-tutorial.pdfgdb-tutorial.pdf
gdb-tutorial.pdfligi14
 
Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbSenthilKumar Selvaraj
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDBDavid Khosid
 
Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01
Uwaga na buga! GDB w służbie programisty.  Barcamp Semihalf S09:E01Uwaga na buga! GDB w służbie programisty.  Barcamp Semihalf S09:E01
Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01Semihalf
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdbOwen Hsu
 
Process (OS),GNU,Introduction to Linux oS
Process (OS),GNU,Introduction to Linux oSProcess (OS),GNU,Introduction to Linux oS
Process (OS),GNU,Introduction to Linux oSHarrytoye2
 
Compiler design notes phases of compiler
Compiler design notes phases of compilerCompiler design notes phases of compiler
Compiler design notes phases of compilerovidlivi91
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applicationsRoman Podoliaka
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerPriyank Kapadia
 
Computer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming IComputer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming I💻 Anton Gerdelan
 
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdbPython Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdbP3 InfoTech Solutions Pvt. Ltd.
 

Similaire à Wavedigitech gdb (20)

GNU Debugger
GNU DebuggerGNU Debugger
GNU Debugger
 
Gnu debugger
Gnu debuggerGnu debugger
Gnu debugger
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handout
 
gdb-tutorial.pdf
gdb-tutorial.pdfgdb-tutorial.pdf
gdb-tutorial.pdf
 
Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with Gdb
 
gdb.ppt
gdb.pptgdb.ppt
gdb.ppt
 
lab1-ppt.pdf
lab1-ppt.pdflab1-ppt.pdf
lab1-ppt.pdf
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDB
 
Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01
Uwaga na buga! GDB w służbie programisty.  Barcamp Semihalf S09:E01Uwaga na buga! GDB w służbie programisty.  Barcamp Semihalf S09:E01
Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
 
Process (OS),GNU,Introduction to Linux oS
Process (OS),GNU,Introduction to Linux oSProcess (OS),GNU,Introduction to Linux oS
Process (OS),GNU,Introduction to Linux oS
 
Compiler design notes phases of compiler
Compiler design notes phases of compilerCompiler design notes phases of compiler
Compiler design notes phases of compiler
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
Debuging like a pro
Debuging like a proDebuging like a pro
Debuging like a pro
 
Gccgdb
GccgdbGccgdb
Gccgdb
 
05-Debug.pdf
05-Debug.pdf05-Debug.pdf
05-Debug.pdf
 
Computer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming IComputer Graphics - Lecture 01 - 3D Programming I
Computer Graphics - Lecture 01 - 3D Programming I
 
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdbPython Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdb
 
C tutorials
C tutorialsC tutorials
C tutorials
 

Plus de Wave Digitech

54 sms based irrigation system
54 sms based irrigation system54 sms based irrigation system
54 sms based irrigation systemWave Digitech
 
54 a automatic irrigation system
54 a automatic irrigation system54 a automatic irrigation system
54 a automatic irrigation systemWave Digitech
 
Implementation of solar illumination system with three-stage charging and dim...
Implementation of solar illumination system with three-stage charging and dim...Implementation of solar illumination system with three-stage charging and dim...
Implementation of solar illumination system with three-stage charging and dim...Wave Digitech
 
Zl embd045 wireless telemedia system based on arm and web server
Zl embd045 wireless telemedia system based on arm and web serverZl embd045 wireless telemedia system based on arm and web server
Zl embd045 wireless telemedia system based on arm and web serverWave Digitech
 
Zl embd029 arm and rfid based event management monitoring system
Zl embd029 arm and rfid based event management monitoring systemZl embd029 arm and rfid based event management monitoring system
Zl embd029 arm and rfid based event management monitoring systemWave Digitech
 
Projects wavedigitech-2013
Projects wavedigitech-2013Projects wavedigitech-2013
Projects wavedigitech-2013Wave Digitech
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Wave Digitech
 
Difference bw android4.2 to android 4.3
Difference bw android4.2 to android 4.3Difference bw android4.2 to android 4.3
Difference bw android4.2 to android 4.3Wave Digitech
 
Unix Process management
Unix Process managementUnix Process management
Unix Process managementWave Digitech
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013Wave Digitech
 
Android debug bridge
Android debug bridgeAndroid debug bridge
Android debug bridgeWave Digitech
 
Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbookWave Digitech
 
Wavedigitech training-broucher-june2013
Wavedigitech training-broucher-june2013Wavedigitech training-broucher-june2013
Wavedigitech training-broucher-june2013Wave Digitech
 
Wavedigitech presentation-2013-v1
Wavedigitech presentation-2013-v1Wavedigitech presentation-2013-v1
Wavedigitech presentation-2013-v1Wave Digitech
 
Wavedigitech presentation-2013
Wavedigitech presentation-2013Wavedigitech presentation-2013
Wavedigitech presentation-2013Wave Digitech
 

Plus de Wave Digitech (17)

54 sms based irrigation system
54 sms based irrigation system54 sms based irrigation system
54 sms based irrigation system
 
54 a automatic irrigation system
54 a automatic irrigation system54 a automatic irrigation system
54 a automatic irrigation system
 
Implementation of solar illumination system with three-stage charging and dim...
Implementation of solar illumination system with three-stage charging and dim...Implementation of solar illumination system with three-stage charging and dim...
Implementation of solar illumination system with three-stage charging and dim...
 
Zl embd045 wireless telemedia system based on arm and web server
Zl embd045 wireless telemedia system based on arm and web serverZl embd045 wireless telemedia system based on arm and web server
Zl embd045 wireless telemedia system based on arm and web server
 
Zl embd029 arm and rfid based event management monitoring system
Zl embd029 arm and rfid based event management monitoring systemZl embd029 arm and rfid based event management monitoring system
Zl embd029 arm and rfid based event management monitoring system
 
Arm
ArmArm
Arm
 
8051
80518051
8051
 
Projects wavedigitech-2013
Projects wavedigitech-2013Projects wavedigitech-2013
Projects wavedigitech-2013
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Difference bw android4.2 to android 4.3
Difference bw android4.2 to android 4.3Difference bw android4.2 to android 4.3
Difference bw android4.2 to android 4.3
 
Unix Process management
Unix Process managementUnix Process management
Unix Process management
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
Android debug bridge
Android debug bridgeAndroid debug bridge
Android debug bridge
 
Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbook
 
Wavedigitech training-broucher-june2013
Wavedigitech training-broucher-june2013Wavedigitech training-broucher-june2013
Wavedigitech training-broucher-june2013
 
Wavedigitech presentation-2013-v1
Wavedigitech presentation-2013-v1Wavedigitech presentation-2013-v1
Wavedigitech presentation-2013-v1
 
Wavedigitech presentation-2013
Wavedigitech presentation-2013Wavedigitech presentation-2013
Wavedigitech presentation-2013
 

Dernier

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 

Dernier (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Wavedigitech gdb

  • 1. © Copyright 2013, wavedigitech.com. Latest update: June 15, 2013, http://www.wavedigitech.com/ Call us on : 91-9632839173 E-Mail : info@wavedigitech.com E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 2. Presentation on ARM Basics E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173 Presentation on GDB
  • 3. Presentation on ARM Basics E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173 The GNU Debugger, usually called just GDB it is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C, C++, Objective-C, Free Pascal, Fortran, Java and partially others. GDB offers extensive facilities for tracing and altering the execution of computer programs. The user can monitor and modify the values of programs' internal variables, and even call functions independently of the program's normal behavior. Remote debugging GDB offers a 'remote' mode often used when debugging embedded systems. Remote operation is when GDB runs on one machine and the program being debugged runs on another. The GNU Debugger
  • 4. Compiling for debugging • We usually compile a program as gcc [flags] <source files> -o <output file> • A -g option is added to enable the built-in debugging support (which gdb needs): gcc [other flags] -g <source files> -o <output file> Ex: gcc -Wall -Werror -ansi -pedantic-errors -g prog1.c -o prog1.x E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 5. Starting up gdb • To get the gdb prompt, type “gdb” • The program to be debugged now is loaded using (gdb) file prog1.x • Here, prog1.x is the program you want to load, and “file” is the command to load it. • To run the program, we use (gdb) run E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 6. Setting breakpoints • Breakpoints can be used to stop the program run in the middle, at a designated point. The simplest way is the command “break.” This sets a breakpoint at a specified file-line pair (gdb) break file1.c:6 • This sets a breakpoint at line 6, of file1.c. Now, if the program ever reaches that location when running, the program will pause and prompt you for another command. • To break at a particular function, we use (gdb) break function E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 7. • We can proceed onto the next breakpoint by typing “continue” (gdb) continue • step Executes the current line of the program and stops on the next statement to be executed (gdb) step • Like step, however, if the current line of the program contains a function call, it executes the function and stops at the next line. (gdb) next • Until is like next, except that if you are at the end of a loop, until will continue execution until the loop is exited, whereas next will just take you back up to the beginning of the loop. This is convenient if you want to see what happens after the loop, but don't want to step through every iteration. (gdb) until E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 8. Print and Watchpoints • The print command prints the value of the variable specified, and print/x prints the value in hexadecimal: (gdb) print variable (gdb) print/x variable • We can also modify variables' values by (gdb) set < variable > = <value> • Whereas breakpoints interrupt the program at a particular line or function, watchpoints act on variables. They pause the program whenever a watched variable’s value is modified. (gdb) watch variable • Now, whenever my var’s value is modified, the program will interrupt and print out the old and new values. E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 9. • backtrace - produces a stack trace of the function calls that lead to a segmentation fault • where - same as backtrace; you can think of this version as working even when you’re still in the middle of the program • finish - runs until the current function is finished • delete N - deletes a specified N breakpoint • info breakpoints - shows information about all declared breakpoints E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 10. info commands for examining runtime debugger state: • gdb has a large set of info X commands for displaying information about different types of runtime state and about debugger state. Here is how to list all the info commands in help, and a description of what a few of the info commands do: • (gdb) help status lists a bunch of info X commands • (gdb) info frame list information about the current stack frame • (gdb) info locals list local variable values of current stack frame • (gdb) info args list argument values of current stack frame • (gdb) info registers list register values • (gdb) info breakpoints list status of all breakpoints E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 11. . • (gdb) up – Move to the function that called the present function. Useful if your program crashes in a library function; use up to get to the last function call in your program • (gdb) down – Reverses the action of up • (gdb) delete – Removes breakpoint by number (see example following). If no number, all deleted. • (gdb) kill – Terminates the program. • (gdb) list – List 10 lines of the program being debugged. The sixth line is the preset statement. Subsequent, consecutive entry of list will list the next 10 lines. E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 12. Breakpoints • In this, we get to specify some criterion that must be met for the breakpoint to trigger. We use the same break command as before: (gdb) break file1.c:6 if i >= ARRAYSIZE • This command sets a breakpoint at line 6 of file file1.c, which triggers only if the variable i is greater than or equal to the size of the array E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 13. Using pointers with gdb • Suppose we’re in gdb, and are at some point in the execution after a line that looks like: struct entry * e1 = <something>; • To see the value (memory address) of the pointer: (gdb) print e1 • To see a particular field of the struct the pointer is referencing: (gdb) print e1->key (gdb) print e1->name (gdb) print e1->price (gdb) print e1->serial number E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173
  • 14. • We can also use the dereference (*) and dot (.) operators in place of the arrow operator (->): (gdb) print (*e1).key (gdb) print (*e1).name (gdb) print (*e1).price (gdb) print (*e1).serial number • To see the entire contents of the struct the pointer references (gdb) print *e1 E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173 Using pointers with gdb
  • 15. Thank You © Copyright 2013, wavedigitech.com. Latest update: June 30, 2013, http://www.wavedigitech.com/ Call us on : +91-91-9632839173 E-Mail : info@wavedigitech.com E-mail: info@wavedigitech.com; http://www.wavedigitech.com Phone : 91-9632839173