SlideShare a Scribd company logo
www.techvilla.org.in
TECHVILLA
www.techvilla.org.in
www.techvilla.org.in
GCC and GDB
www.techvilla.org.in
What is GCC?
 Gcc is the GNU Project C compiler
 A command-line program
 Gcc takes C source files as input
 Outputs an executable: a.out
 You can specify a different output filename
 Available for you to use on spinlock/coredump
www.techvilla.org.in
Gcc example:
 “hello.c” is the name of the file with the following contents:
#include <stdio.h>
int main(void) {
printf(“Hellon“);
}
 To compile simply type: gcc –o hello hello.c –g -Wall
 ‘-o’ option tells the compiler to name the executable ‘HelloProg’
 ‘-g’ option adds symbolic information to Hello for debugging
 ‘–Wall’ tells it to print out all warnings (very useful!!!)
 Can also give ‘-O6’ to turn on full optimization
 To execute the program simply type: ./hello
 It should output “Hello” on the console
www.techvilla.org.in
What is Gdb?
 GDB is the GNU Project debugger
 Gdb provides some helpful functionality
 Allows you to stop your program at any given point.
 You can examine the state of your program when it’s stopped.
 Change things in your program, so you can experiment with
correcting the effects of a bug.
 Also a command-line program
 Is also available on spinlock/coredump
www.techvilla.org.in
Using Gdb:
 To start gdb with your hello program type: gdb
HelloProg
 When gdb starts, your program is not actually running.
 You have to use the run command to start execution.
 Before you do that, you should place some break points.
 Once you hit a break point, you can examine any
variable.
www.techvilla.org.in
Useful gdb commands
 run command-line-arguments
 Begin execution of your program with arguments
 break place
 place can be the name of a function or a line number
 For example: break main will stop execution at the first instruction
of your program
 delete N
 Removes breakpoints, where N is the number of the breakpoint
 step
 Executes current instruction and stops on the next one
www.techvilla.org.in
Gdb commands cont.
 next
 Same as step except this doesn’t step into functions
 print E
 Prints the value of any variable in your program when you are at
a breakpoint, where E is the name of the variable you want to
print
 help command
 Gives you more information about any command or all if you
leave out command
 quit
 Exit gdb
www.techvilla.org.in
Memory organization of a c
program
www.techvilla.org.in
Text segment
 A text segment , also known as a code segment or simply as text, is
one of the sections of a program in an object file or in memory,
which contains executable instructions.
 As a memory region, a text segment may be placed below the
heap or stack in order to prevent heaps and stack overflows from
overwriting it.
 Usually, the text segment is sharable so that only a single copy
needs to be in memory for frequently executed programs, such as
text editors, the C compiler, the shells, and so on. Also, the text
segment is often read-only, to prevent a program from accidentally
modifying its instructions.
www.techvilla.org.in
Initialized Data Segment
 Initialized data segment, usually called simply the Data Segment. A
data segment is a portion of virtual address space of a program,
which contains the global variables and static variables that are
initialized by the programmer.
 Note that, data segment is not read-only, since the values of the
variables can be altered at run time.
 This segment can be further classified into initialized read-only area
and initialized read-write area.
www.techvilla.org.in
Uninitialized Data Segment:
 Uninitialized data segment, often called the “bss” segment, named
after an ancient assembler operator that stood for “block started by
symbol.” Data in this segment is initialized by the kernel to arithmetic
0 before the program starts executing.
 uninitialized data starts at the end of the data segment and
contains all global variables and static variables that are initialized
to zero or do not have explicit initialization in source code.
For instance a variable declared static int i; would be contained in
the BSS segment.
For instance a global variable declared int j; would be contained in
the BSS segment.
www.techvilla.org.in
Stack:
 The stack area traditionally adjoined the heap area and grew the
opposite direction; when the stack pointer met the heap pointer,
free memory was exhausted.
 The stack area contains the program stack, a LIFO structure,
typically located in the higher parts of memory.
 Stack, where automatic variables are stored, along with information
that is saved each time a function is called. Each time a function is
called, the address of where to return to and certain information
about the caller’s environment, such as some of the machine
registers, are saved on the stack
www.techvilla.org.in
Heap:
 Heap is the segment where dynamic memory allocation usually
takes place.
 The heap area begins at the end of the BSS segment and grows to
larger addresses from there.
 The Heap area is managed by malloc, realloc, and free, which may
use the brk and sbrk system calls to adjust its size.
 The Heap area is shared by all shared libraries and dynamically
loaded modules in a process.

More Related Content

What's hot

UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN C
Raj vardhan
 
TDD in C - Recently Used List Kata
TDD in C - Recently Used List KataTDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
Olve Maudal
 
C programming on Ubuntu
C programming on UbuntuC programming on Ubuntu
C programming on Ubuntu
Binu Joy
 
Embedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersEmbedded c program and programming structure for beginners
Embedded c program and programming structure for beginners
Kamesh Mtec
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
Rumman Ansari
 
Introduction to C++,Computer Science
Introduction to C++,Computer ScienceIntroduction to C++,Computer Science
Introduction to C++,Computer Science
Abhinav Vishnoi
 
Semaphore
SemaphoreSemaphore
Semaphore
naniix21_3
 
Semaphore
SemaphoreSemaphore
Semaphore
naniix21_3
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
Programming Homework Help
 
Preprocessor
PreprocessorPreprocessor
Preprocessor
Võ Hòa
 
Embedded c programming22 for fdp
Embedded c programming22 for fdpEmbedded c programming22 for fdp
Embedded c programming22 for fdp
Pradeep Kumar TS
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
REHAN IJAZ
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
Mohammed A. Imran
 
Lesson 7 io statements
Lesson 7 io statementsLesson 7 io statements
Lesson 7 io statements
Dr. Rupinder Singh
 
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
MobileFest2018
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#
Bertrand Le Roy
 
Practical Example of grep command in unix
Practical Example of grep command in unixPractical Example of grep command in unix
Practical Example of grep command in unix
Javin Paul
 
Python lecture 02
Python lecture 02Python lecture 02
Python lecture 02
Tanwir Zaman
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
Programming Homework Help
 
test
testtest
test
aaro11
 

What's hot (20)

UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN C
 
TDD in C - Recently Used List Kata
TDD in C - Recently Used List KataTDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
 
C programming on Ubuntu
C programming on UbuntuC programming on Ubuntu
C programming on Ubuntu
 
Embedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersEmbedded c program and programming structure for beginners
Embedded c program and programming structure for beginners
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
 
Introduction to C++,Computer Science
Introduction to C++,Computer ScienceIntroduction to C++,Computer Science
Introduction to C++,Computer Science
 
Semaphore
SemaphoreSemaphore
Semaphore
 
Semaphore
SemaphoreSemaphore
Semaphore
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
 
Preprocessor
PreprocessorPreprocessor
Preprocessor
 
Embedded c programming22 for fdp
Embedded c programming22 for fdpEmbedded c programming22 for fdp
Embedded c programming22 for fdp
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
 
Lesson 7 io statements
Lesson 7 io statementsLesson 7 io statements
Lesson 7 io statements
 
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#
 
Practical Example of grep command in unix
Practical Example of grep command in unixPractical Example of grep command in unix
Practical Example of grep command in unix
 
Python lecture 02
Python lecture 02Python lecture 02
Python lecture 02
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
test
testtest
test
 

Similar to Rasperry pi Part 8

Let's Take A Look At The Boost Libraries
Let's Take A Look At The Boost LibrariesLet's Take A Look At The Boost Libraries
Let's Take A Look At The Boost Libraries
Thomas Pollak
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
Durga Padma
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
farishah
 
C tutorial
C tutorialC tutorial
C tutorial
Diwakar_singh1989
 
2. Consider the following C program #define M ... #define N ....pdf
2. Consider the following C program #define M ... #define N ....pdf2. Consider the following C program #define M ... #define N ....pdf
2. Consider the following C program #define M ... #define N ....pdf
SIGMATAX1
 
Embedded C.pptx
Embedded C.pptxEmbedded C.pptx
Embedded C.pptx
MusthafaKadersha
 
Stucture of c program
Stucture of c programStucture of c program
Stucture of c program
Vpmv
 
C Under Linux
C Under LinuxC Under Linux
C Under Linux
mohan43u
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
Muhammed Thanveer M
 
C tutorial
C tutorialC tutorial
C tutorial
Amit Dhiman
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Debugging Python with gdb
Debugging Python with gdbDebugging Python with gdb
Debugging Python with gdb
Roman Podoliaka
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
karmuhtam
 
C language industrial training report
C language industrial training reportC language industrial training report
C language industrial training report
Raushan Pandey
 
6 preprocessor macro header
6 preprocessor macro header6 preprocessor macro header
6 preprocessor macro header
hasan Mohammad
 
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxIIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
rajkumar490591
 
1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx
tarifarmarie
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
sidhantkulkarni1
 
Introduction
IntroductionIntroduction
Introduction
Kamran
 
Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008
guestd9065
 

Similar to Rasperry pi Part 8 (20)

Let's Take A Look At The Boost Libraries
Let's Take A Look At The Boost LibrariesLet's Take A Look At The Boost Libraries
Let's Take A Look At The Boost Libraries
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
C tutorial
C tutorialC tutorial
C tutorial
 
2. Consider the following C program #define M ... #define N ....pdf
2. Consider the following C program #define M ... #define N ....pdf2. Consider the following C program #define M ... #define N ....pdf
2. Consider the following C program #define M ... #define N ....pdf
 
Embedded C.pptx
Embedded C.pptxEmbedded C.pptx
Embedded C.pptx
 
Stucture of c program
Stucture of c programStucture of c program
Stucture of c program
 
C Under Linux
C Under LinuxC Under Linux
C Under Linux
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
 
C tutorial
C tutorialC tutorial
C tutorial
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
 
Debugging Python with gdb
Debugging Python with gdbDebugging Python with gdb
Debugging Python with gdb
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
 
C language industrial training report
C language industrial training reportC language industrial training report
C language industrial training report
 
6 preprocessor macro header
6 preprocessor macro header6 preprocessor macro header
6 preprocessor macro header
 
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxIIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
 
1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
 
Introduction
IntroductionIntroduction
Introduction
 
Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008
 

More from Techvilla

Raspberry pi Part 26
Raspberry pi Part 26Raspberry pi Part 26
Raspberry pi Part 26
Techvilla
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25
Techvilla
 
Raspberry pi Part 24
Raspberry pi Part 24Raspberry pi Part 24
Raspberry pi Part 24
Techvilla
 
Raspberry pi Part 23
Raspberry pi Part 23Raspberry pi Part 23
Raspberry pi Part 23
Techvilla
 
Raspberry pi Part 22
Raspberry pi Part 22Raspberry pi Part 22
Raspberry pi Part 22
Techvilla
 
Raspberry pi Part 21
Raspberry pi Part 21Raspberry pi Part 21
Raspberry pi Part 21
Techvilla
 
Raspberry pi Part 20
Raspberry pi Part 20Raspberry pi Part 20
Raspberry pi Part 20
Techvilla
 
Raspberry pi Part 19
Raspberry pi Part 19Raspberry pi Part 19
Raspberry pi Part 19
Techvilla
 
Raspberry pi Part 18
Raspberry pi Part 18Raspberry pi Part 18
Raspberry pi Part 18
Techvilla
 
Raspberry pi Part 17
Raspberry pi Part 17Raspberry pi Part 17
Raspberry pi Part 17
Techvilla
 
Raspberry pi Part 16
Raspberry pi Part 16Raspberry pi Part 16
Raspberry pi Part 16
Techvilla
 
Rasperry pi Part 15
Rasperry pi Part 15Rasperry pi Part 15
Rasperry pi Part 15
Techvilla
 
Rasperry pi Part 13
Rasperry pi Part 13Rasperry pi Part 13
Rasperry pi Part 13
Techvilla
 
Rasperry pi Part 12
Rasperry pi Part 12Rasperry pi Part 12
Rasperry pi Part 12
Techvilla
 
Rasperry pi Part 10
Rasperry pi Part 10Rasperry pi Part 10
Rasperry pi Part 10
Techvilla
 
Rasperry pi Part 9
Rasperry pi Part 9Rasperry pi Part 9
Rasperry pi Part 9
Techvilla
 
Rasperry pi Part 7
Rasperry pi Part 7Rasperry pi Part 7
Rasperry pi Part 7
Techvilla
 
Raspberry pi Part 6
Raspberry pi Part 6Raspberry pi Part 6
Raspberry pi Part 6
Techvilla
 
Raspberry pi Part 5
Raspberry pi Part 5Raspberry pi Part 5
Raspberry pi Part 5
Techvilla
 
Raspberry pi Part 4
Raspberry pi Part 4Raspberry pi Part 4
Raspberry pi Part 4
Techvilla
 

More from Techvilla (20)

Raspberry pi Part 26
Raspberry pi Part 26Raspberry pi Part 26
Raspberry pi Part 26
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25
 
Raspberry pi Part 24
Raspberry pi Part 24Raspberry pi Part 24
Raspberry pi Part 24
 
Raspberry pi Part 23
Raspberry pi Part 23Raspberry pi Part 23
Raspberry pi Part 23
 
Raspberry pi Part 22
Raspberry pi Part 22Raspberry pi Part 22
Raspberry pi Part 22
 
Raspberry pi Part 21
Raspberry pi Part 21Raspberry pi Part 21
Raspberry pi Part 21
 
Raspberry pi Part 20
Raspberry pi Part 20Raspberry pi Part 20
Raspberry pi Part 20
 
Raspberry pi Part 19
Raspberry pi Part 19Raspberry pi Part 19
Raspberry pi Part 19
 
Raspberry pi Part 18
Raspberry pi Part 18Raspberry pi Part 18
Raspberry pi Part 18
 
Raspberry pi Part 17
Raspberry pi Part 17Raspberry pi Part 17
Raspberry pi Part 17
 
Raspberry pi Part 16
Raspberry pi Part 16Raspberry pi Part 16
Raspberry pi Part 16
 
Rasperry pi Part 15
Rasperry pi Part 15Rasperry pi Part 15
Rasperry pi Part 15
 
Rasperry pi Part 13
Rasperry pi Part 13Rasperry pi Part 13
Rasperry pi Part 13
 
Rasperry pi Part 12
Rasperry pi Part 12Rasperry pi Part 12
Rasperry pi Part 12
 
Rasperry pi Part 10
Rasperry pi Part 10Rasperry pi Part 10
Rasperry pi Part 10
 
Rasperry pi Part 9
Rasperry pi Part 9Rasperry pi Part 9
Rasperry pi Part 9
 
Rasperry pi Part 7
Rasperry pi Part 7Rasperry pi Part 7
Rasperry pi Part 7
 
Raspberry pi Part 6
Raspberry pi Part 6Raspberry pi Part 6
Raspberry pi Part 6
 
Raspberry pi Part 5
Raspberry pi Part 5Raspberry pi Part 5
Raspberry pi Part 5
 
Raspberry pi Part 4
Raspberry pi Part 4Raspberry pi Part 4
Raspberry pi Part 4
 

Recently uploaded

spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 

Recently uploaded (20)

spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 

Rasperry pi Part 8

  • 3. www.techvilla.org.in What is GCC?  Gcc is the GNU Project C compiler  A command-line program  Gcc takes C source files as input  Outputs an executable: a.out  You can specify a different output filename  Available for you to use on spinlock/coredump
  • 4. www.techvilla.org.in Gcc example:  “hello.c” is the name of the file with the following contents: #include <stdio.h> int main(void) { printf(“Hellon“); }  To compile simply type: gcc –o hello hello.c –g -Wall  ‘-o’ option tells the compiler to name the executable ‘HelloProg’  ‘-g’ option adds symbolic information to Hello for debugging  ‘–Wall’ tells it to print out all warnings (very useful!!!)  Can also give ‘-O6’ to turn on full optimization  To execute the program simply type: ./hello  It should output “Hello” on the console
  • 5. www.techvilla.org.in What is Gdb?  GDB is the GNU Project debugger  Gdb provides some helpful functionality  Allows you to stop your program at any given point.  You can examine the state of your program when it’s stopped.  Change things in your program, so you can experiment with correcting the effects of a bug.  Also a command-line program  Is also available on spinlock/coredump
  • 6. www.techvilla.org.in Using Gdb:  To start gdb with your hello program type: gdb HelloProg  When gdb starts, your program is not actually running.  You have to use the run command to start execution.  Before you do that, you should place some break points.  Once you hit a break point, you can examine any variable.
  • 7. www.techvilla.org.in Useful gdb commands  run command-line-arguments  Begin execution of your program with arguments  break place  place can be the name of a function or a line number  For example: break main will stop execution at the first instruction of your program  delete N  Removes breakpoints, where N is the number of the breakpoint  step  Executes current instruction and stops on the next one
  • 8. www.techvilla.org.in Gdb commands cont.  next  Same as step except this doesn’t step into functions  print E  Prints the value of any variable in your program when you are at a breakpoint, where E is the name of the variable you want to print  help command  Gives you more information about any command or all if you leave out command  quit  Exit gdb
  • 10. www.techvilla.org.in Text segment  A text segment , also known as a code segment or simply as text, is one of the sections of a program in an object file or in memory, which contains executable instructions.  As a memory region, a text segment may be placed below the heap or stack in order to prevent heaps and stack overflows from overwriting it.  Usually, the text segment is sharable so that only a single copy needs to be in memory for frequently executed programs, such as text editors, the C compiler, the shells, and so on. Also, the text segment is often read-only, to prevent a program from accidentally modifying its instructions.
  • 11. www.techvilla.org.in Initialized Data Segment  Initialized data segment, usually called simply the Data Segment. A data segment is a portion of virtual address space of a program, which contains the global variables and static variables that are initialized by the programmer.  Note that, data segment is not read-only, since the values of the variables can be altered at run time.  This segment can be further classified into initialized read-only area and initialized read-write area.
  • 12. www.techvilla.org.in Uninitialized Data Segment:  Uninitialized data segment, often called the “bss” segment, named after an ancient assembler operator that stood for “block started by symbol.” Data in this segment is initialized by the kernel to arithmetic 0 before the program starts executing.  uninitialized data starts at the end of the data segment and contains all global variables and static variables that are initialized to zero or do not have explicit initialization in source code. For instance a variable declared static int i; would be contained in the BSS segment. For instance a global variable declared int j; would be contained in the BSS segment.
  • 13. www.techvilla.org.in Stack:  The stack area traditionally adjoined the heap area and grew the opposite direction; when the stack pointer met the heap pointer, free memory was exhausted.  The stack area contains the program stack, a LIFO structure, typically located in the higher parts of memory.  Stack, where automatic variables are stored, along with information that is saved each time a function is called. Each time a function is called, the address of where to return to and certain information about the caller’s environment, such as some of the machine registers, are saved on the stack
  • 14. www.techvilla.org.in Heap:  Heap is the segment where dynamic memory allocation usually takes place.  The heap area begins at the end of the BSS segment and grows to larger addresses from there.  The Heap area is managed by malloc, realloc, and free, which may use the brk and sbrk system calls to adjust its size.  The Heap area is shared by all shared libraries and dynamically loaded modules in a process.