-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgdb
66 lines (39 loc) · 1.77 KB
/
gdb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
GDB:
----
To pass command line args to gdb:
use gdb with --args parameter.
ex : gdb --args executable_name arg1 arg2 arg3
If we want to pass parameters inside gdb
(gdb) r arg1 arg2 arg3
Watch points:
------------
Watch points are similar to break points, but they are set on the variable not on the functions/lines of the code.
when the watch variable is written or read, the watchpoint gets triggerred and the program execution stops.
To set watch point on a non global variable, we must set a break point that will stop the program in the
scope of the variable to be watched.
The watch point can be set after the program stop at the above break point.
To get notified on a write of a set variable we need gdb command watch.
When the watch point is trigerred, it prints the old and new value.
CORE-DUMP:
----------
It is a file that records the memory image of a running process and its status (register values).
A program that crashes automatically produces a core dump file.
It is also known as core file.
Its primary use is postmortem of a program thar crashed while a ran outside a debuugger.
Gdb can read the core dump and give the line number of the crash, the arguments that we are passed and more.
To findoutthe size of core file
run : ulimit -a
If the core file size is zero
set core file size using
ulimit -c unlimited
pass gdb the core file
Ex : gdb executable_name core
Multithread debugging:
----------------------
info threads :
list all the existing threads in program.
thread threadnum // switch to thread num context
break linenum thread threadnum :
put a break point at particular thread given line number.
set print thread-events :
this will printout thread start and exit events.