ECE2220Slides(1.3 Intro Debugging)
ECE2220Slides(1.3 Intro Debugging)
Debugging Info
Now let’s look at compiling the program without using the the –g
switch.
This time, when we run gdb, we find that there are no symbols to be
loaded.
apollo13% gcc debug1.c –o debug1_no_g
apollo13% gdb debug1_no_g
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to redistribute it.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
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 debug1_no_g...(no debugging symbols found)
...done.
(gdb)
WJR, Clemson University, 2010-2018
ECE 2220 - System Programming Chapter 1.3 - Introduction - GDB Debugging 3
gdb Example 1
debug1.c
1 #include <stdio.h> apollo13% debug1_g
2 j = 5432
3 void main(void) j = 603
4 { int i, j; j = 75
j = 10
5 j = 1
6 j = 54321; j = 0
7 for (i=10;i>=0;i--) jj == 00
8 { j = j/i; j = 0
9 printf(“j=%d\n",j); j = 0
Floating exception (core dumped)
10 } apollo13%
11 }
Breakpoint 2, main () at
debug1.c:8
8 { j = j/i;
1: i = 8
WJR, Clemson(gdb)
University, 2010-2018
ECE 2220 - System Programming Chapter 1.3 - Introduction - GDB Debugging 10
gdb Example 2
debug2.c
1 #include <stdio.h>
apollo13% debug2
2
3 void main(void) Segmentation fault (core dumped)
4 { int i, j, k[5];
5
6 j = 54321;
7
8 for (i=10; i>=0; i--)
9 { k[j] = j/i;
10 printf(“k[j]=%d\n",k[j]);
11 }
12 }
gdb Example 3
debug3.c
1 #include <stdio.h>
apollo13% debug3_g
2
3 void main(void) i=4, j=618330
4 { int i, j; i=4, j=618335
i=4, j=618340
5 i=4, j=618345
6 for (i=0; i<10; i++) i=4, j=618350
7 { j += i; i=4, j=618355
8 if (j > 10) i=4, j=618360
9 { i--; i=4, j=618365
10 i=4, j=618370
}
i=4, j=618375
11 printf("i=%d, j=%d \n", i, j); i=4, j=618380
12 } i=4, j=618385
13 } ^C4, j=618390
apollo13%
IDEs
Integrated Development Environments are programs which contain
compilers, editors, and debuggers all in one package.
• Sun’s Net Beans
• Code::Blocks
• Eclipse CDT
• CodeLite
• Bluefish
• Atom
• JetBrains’ CLion
• Microsoft’s Visual Studio
• Bloodshed’s Dev C++
https://www.tecmint.com/best-linux-ide-editors-source-code-editors/
Shell Emulation
CYGWIN can be used to emulate a Linux
shell on a windows machine.