SlideShare uma empresa Scribd logo
1 de 15
Baixar para ler offline
© 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

Mais conteúdo relacionado

Semelhante a 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.
 

Semelhante a 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
 

Mais 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
 

Mais 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
 

Último

NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataSafe Software
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServicePicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServiceRenan Moreira de Oliveira
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdfJamie (Taka) Wang
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncObject Automation
 

Último (20)

NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServicePicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation Inc
 

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