GDB Flashcards

Tips and tricks for GDB

1
Q

Start gdb quietly

A

gdb -q ./helloworld

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to view the functions in a binary?

A

info functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to get an entry point of a particular binary?

A

shell readelf -h

info files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you change or set a disassembly flavor?

A

set disassembly-flavor intel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to check all the variables and symbols within a binary?

A

info variables

Note: This only displays global variables and static variables. Local variables aren’t printed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between stepi and nexti?

A

nexti will execute one machine instruction, but if it is a function call then it will proceed until the function returns. stepi is more verbose executing one machine instruction, stopping, and returns the debugger.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the different debug symbols file types?

A

DWARF2
COFF
XCOFF
Stabs

Note: That a flag to include debug symbols must be explicitly specified at compile time.
If the flag is -g is included gcc will include the native operating systems native format for debugging symbols.
The -ggdb will compile the binary with gdb specific symbols.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What do symbols files actually tell us?

A
info sources
info variables
info scope function_name
info functions
main print symbols filename_to_store
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain the diff symbol types within the nm utility output.

A
A - Absolute symbol
B - In the uninitialized data section
D - In the initialized data section
N - Debug symbol
T - In the text section
U - Undefined symbol right now
Note: Lower case is local symbol while upper case is external symbol
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to disable/enable/purge breakpoints once set?

A

disable 1
enable 1
delete 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to create vars to hold data during debugging?

A

set $i = 10

These are called convenience variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you view the stack?

A

$esp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the different eflags?

A

AF - Auxiliary carry flag
ID - ID flag
IF - Interrupt enable flag
SF - Sign flag

How well did you know this?
1
Not at all
2
3
4
5
Perfectly