-
Notifications
You must be signed in to change notification settings - Fork 0
/
gdb.txt
178 lines (136 loc) · 4.64 KB
/
gdb.txt
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
handle SIG32 nostop
# Usage
# --------
gdb a.out
enter repeat last command
# Breakpoints and watchpoints
# ------------------------------
b main set breakpoint at main
b 21 if val==v1 break on line 21 when (val==v1)
wa var1==var2 break when the expression (var1==var2) becomes true
wa var1 break when var1 changes
# Execute commands when a breakpoint is reached
command 2 # specify commands for breakpoint 2
printf "x is %d\n",x
cont # auto continue
end # end of commands entry
info break # List all breakpoints
ignore 3 10 # Dont stop at breakpoint nr 3 the next 10 times
dis[able] # Disable all break points
en[able] 3 4 # Enable breakpts num. 3 and 4
clear foo.c:21 # Delete breakpoint at line nr 21 of foo.c
del[ete] 1 # Delete breakpoint/watchpoint no. 1. If no args: delete all breakpoints
# Examin Code:
# ------------
set listsize 20 Print 20 lines (default is 10)
l list
l line
l function
l file:line
l file:function
l *address
edit edit the source
shell make compile
# Debug Location
# ------------
bt # show frame stack
frame # show info about current frame
fram frame-number # chanage frame to operate on
up, down # move up down the stack
thread thread-number # change thread to operate on
# Examin Data:
# ------------
inf locals # print all local variables
info macro expression # show macro definition (define)
# Print values of expressions.
p $register
p variable
p *address
p *(int *)address
p *(char **)address
p myfunc(p1, p2) # will actually execute it and return result!
p *a = 123 # will actually change *a value and return 123!
p file::variable
p function::variable
set print elements 0 # print the whole string, not just the first bytes
p *array@len # print array of length len
x pointerVar # print memory at address
x/20b pointerVar # print 20 bytes at address
x/xb <location> # print byte in hexadecimal
x/s <location> # print the string starting at location
x/<count><fmt letter><size letter>
fmt letters: o,x,d,u,t,f,a,i,c,s,z
size letters: b,h,w,g
ptype a # print definition of struct
print *(structPointr) # print struct
set print pretty on # print structs in readable form
print /t var # print in binary
print /x var # print in hex
# Disassembly
disassemble
disassemble file:line
# Run
# -----------------
r agr1 arg2 run with command line args: arg1, arg2
n step over
s step into
finish step out
c continue
# Manipulate Data
# ---------------
set var=1 change the value of a variable
info functions -- All function names
info macros -- Show the definitions of all macros at LINESPEC
info scope -- List the variables local to a scope
info sharedlibrary -- Status of loaded shared object libraries
info source -- Information about the current source file
info sources -- Source files in the program
info stack -- Backtrace of the stack
info symbol -- Describe what symbol is at location ADDR
info threads -- Display currently known threads
info variables -- All global and static variable names
info vtbl -- Show the virtual function table for a C++ object
sharedlibrary libnl
show environment [varname]
set environment varname [=value]
set solib-search-path ~/project/host_tt/snapgear/lib/libnl-1.1/lib
# Source path
# --------------------------------------
# attach
gdb pan_task <pid>
set substitute-path /opt/build/panos-devel/slave/main-vm /home/aawais/pan
# GUI
# --------------------------------------
Ctrl-x Ctrl a
# Examine core file
# --------------------------------------
gdb path/to/the/binary path/to/the/core
.gz core files
first untar them: tar xzvf
on 5060
1. untar on mp (/var/cores)
tar xzvf all_pktproc_4_8.1.11_1.tar.gz
2. copy to /opt/var.dp1/cores:
cp all_pktproc_4_8.1.11_1 /opt/var.dp0/cores
3. telnet to dp1:
telent dp1
cd /var/cores
4. gdb pan_task all_pktproc_4_8.1.11_1
5. bt
Shared Library
--------------
if shared library is not found look at LD_LIBRARY_PATH
gdb with c source
----------------------------------------------------------------------
On the Dev server:
- Tar up the directories you need
tar -Pczvf ~/tmp/code.tar.gz /home/aawais/pan_git/panos/src/libs/dp/{flow/src,flow/include,detector/src,detector/include,ctd/src,ctd/include}
- copy archive to target:
fw_copy_scripts.sh ~/tmp/code.tar.gz
On the FW device:
- untar on root
cd /
tar -xzvf /tmp/code.tar.gz
- Other options
set directories
set substitute-path