This site works best with JavaScript enabled
Sign In
Discussions
Activity
Sign In
All
Project.001: C Programming, Data Structures
Issues, queries and suggestions related to C, C programming, data structures using C and C based projects.
Project.001: C Programming, Data Structures
Dubugging using gdb
spatlou
October 2019
Debugging insertionSort.c Program using gdb
spatlou
October 2019
gcc -g insertionSort.c -o isort
...
-g compiles the insertionSort.c for debugging
-o gives optional name for the compiled program. isort in this case.
Now we are going to start gdb:
[root@localhost Arrays]# gdb isort
GNU gdb (GDB) Fedora 8.0.1-36.fc27
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <
http://gnu.org/licenses/gpl.html>
;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<
http://www.gnu.org/software/gdb/bugs/>
.
Find the GDB manual and other documentation resources online at:
<
http://www.gnu.org/software/gdb/documentation/>
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from isort...done.
(gdb)
spatlou
October 2019
(gdb)
...
This is the gdb prompt.
(gdb) break 25
Breakpoint 1 at 0x400699: file insertionSort.c, line 25.
...
... This puts the breakpoint at Line no 25 in out program.
... Now we can add commands to check variables in our program.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
... Commands will expect you to type in some commands that you would like to use at the break point where your program breaks.
>print j
>print p
>print e
>print i
>print k
>print arr[0]@10
>end
(gdb)
.. I gave these commands as i wanted to see these variables. followed by end
spatlou
October 2019
Now going to run
(gdb) run
Starting program: /home/EmbLogic/Training/Torsha/Arrays/isort
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.26-30.fc27.x86_64
Enter Values in The Array
22
44
66
88
99
77
55
33
11
65
Breakpoint 1, main () at insertionSort.c:25
25
printf("\n");
$1 = 0
$2 = 1
$3 = 44
$4 = 1
$5 = 0
$6 = {44, 44, 66, 88, 99, 77, 55, 33, 11, 65}
spatlou
October 2019
use cont
to continue
Add a Comment
Powered by
Vanilla
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
0
Module.101: Advanced Data Structures using C
16
Module.303: Linux System Programming
32
Project 22. Ethernet Network Device Driver Development
0
Project.14. Linux System and Network Administration
0
Project.10. Embedded Linux ARM, Configuring and Porting using Storage
0
Project.203 Linux System Programming. MySQL
0
Pravjot Sir Classes
108
Events at EmbLogic
2
Query
503
Module.000: Linux System Administration
21
Project.001: C Programming, Data Structures
74
Project.002: OOPs, C++, Eclipse, Linux
17
Project.003: Linux System Programming
31
Project.004: Linux Network Programming
7
Project.005: Character Device Drivers Development
16
Project.105: Parallel Port Device Drivers Development
5
Project.205: Serial Port Device Drivers Development
3
Project.008: Block Device Driver Development
3
Project.009: Embedded Linux-ARM. Storage
6
Module.011: Shell Scripting using Bash
6
Project 12: Linux Kernel Architecture and Internals
2
Project.015: Python with Eclipse on Linux
2
Project 16: SPI Device Driver Development
2
Project 17: I2C Device Driver Development
0
Project 18: PCI Device Driver Development
0
Project 19: Embedded Linux on ARM Using Network TFTP
0
Project 20: CAN Bus Protocol and Driver Development
0
Project 21: USB Device Drivers Development
0
Embedded Linux
0
ARM Embedded Processor
0
Training
2
Members Area
1
Word From Admin
1