CSE 351
GDB Introduction
CSE 351 GDB Introduction Lab 2 Reading and understanding x86_64 - - PowerPoint PPT Presentation
CSE 351 GDB Introduction Lab 2 Reading and understanding x86_64 assembly Debugging and disassembling programs Today: General debugging for C with GDB 2 scanf and sscanf() Lab 2 uses sscanf ( s tring scan f ormat), which parses
GDB Introduction
2
string into values Example:
char *mystring = “123, 456” int a, b; sscanf(mystring, “%d, %d”, &a, &b);
printf(“Variable a=%d and b=%d\n”, a, b);
– “%d”, signed int – “%u”, unsigned int – “%c”, char – “%f”, float – “%s”, string (match until it finds white-space) – “%x”, hexadecimal int – “%p”, pointer
stopped
make GDB a great resource for you this quarter
5
machine or find someone next to you who is doing so.
page.
symbols included. To do this, we must use the -g flag in GCC:
gcc -Wall -std=gnu99 -g calculator.c -o calculator
useful.
6
the name of the executable to the gdb program.
information.
symbol loading status.
you may have a problem.
7
understand how to exit GDB.
their first letter.
just use Ctrl-C.
8
program in GDB.
until it hits a critical error or the program finishes.
and break at the beginning of main()
when you want to just start stepping through main().
pass those to run or start.
9
(l for short) command.
main() function.
list 45
lines 30-70, enter list 30,70
10
programs in Eclipse or jGRASP.
11
at a time, stepping over function calls.
then calls to that library will look confusing when you step into them.
a call to printf(), and then enter step to step into the call to printf().
symbols
continue (c for short) command.
12
formats.
command line arguments.
holding your arguments (a, b, operator) by typing the following:
13
in different formats.
14
runtime errors.
throw an arithmetic exception, and GDB will tell you exactly that.
for short) and it will show you the chain of function calls that led to the error.
15
advanced topics to get you through Lab 2
those now, but if not feel free to start messing with those on your own.
16