-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gdbinit
350 lines (308 loc) · 4.97 KB
/
.gdbinit
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#
##
### GDB Settings
##
#
set trace-commands on
set logging enabled on
# set print pretty on
# set print elements 2
set print array on
set unwindonsignal on
#
##
### Custom Commands
##
#
define rfr
refresh
end
define nr
next
refresh
end
# main.c
define main
display *input_list
display *stack_a@argc
display *stack_b@argc
display must_free
display error
end
define ft_get_elem
display *argc
display *argv
display *must_free
display *split_list@*argc
end
define ft_sort
display *stack_a@argc
display *stack_b@argc
display argc
end
# ft_errors.c
define ft_errors
display argc
display *input_list@argc
end
define ft_are_args_nbr
display i
display j
display argc
display *argv@argc
end
# ft_sort_three.c
define ft_sort_three
display *stack@(end+2)
display ft_stack_min(stack)
display ft_stack_max(stack, -1)
display start
display end
end
# ft_create_stack.c
define ft_create_stack
display argc
display argv
display select
display *stack@argc
display i
next
end
# ft_assert_stack.c
define ft_is_sorted
display *stack@ft_stack_end(stack-2)
display stack[i]
display stack[i+1]
display i
end
define ft_stack_start
display *stack
display *stack@start
display start
end
define ft_stack_end
display *stack
display *stack@end
display end
end
define ft_stack_min
display *stack
display *stack@start
display start
display end
display min_idx
end
define ft_stack_max
display *stack
display *stack@start
display start
display end
display max_idx
end
# ft_median.c
define ft_is_median
display *stack
display num
display start
display end
end
define ft_median
display *stack
display num
display start
display end
display min
display max
display diff
end
define ft_min_above_thresh
display *stack
display stack[start].num
display threshold
display start
display end
display ft_stack_min(stack)
display min_idx
display stack[min_idx]
end
# ft_order.c
define ft_check_order
display *stack_a
display *stack_b
display idx
display n_op_a
display n_op_b
display n_ops
display min
display ft_stack_min(stack_b).num
display ft_stack_max(stack_b, -1).num
end
define ft_order
display *stack_a
display *stack_b
display idx
display n_ops
end
define ft_getontop_ops
display *stack@(end+2)
display sign
display start
display end
display idx
display median
display n_ops
end
# ft_rotate.c
define ft_rotate
end
define ft_rev_rotate
end
define ft_rotate_top
display *stack@ft_stack_end(stack-2)
display stack[idx]
display idx
display op
display n_ops
display sign
end
# ft_sort_stack.c
define ft_sort_stack
display *stack_a@stack_len
display *stack_b@stack_len
display stack_len
display i
display median
# display ft_stack_start(stack_b)
display ft_stack_end(stack_b)
# display ft_best_op_idx(stack_b, stack_a, stack_len)
display stack_a[i].num
display stack_b[i].num
display ft_min_above_thresh(stack_a, stack_b[i].num).index
end
define ft_exec_move
display *stack_a@stack_len
display *stack_b@stack_len
display stack_len
display idx
display start
display ordered
display ft_stack_min(stack_a).num
display ft_stack_max(stack_a, -1).num
display stack_b[idx].num
display ft_min_above_thresh(stack_a, stack_b[idx].num).index
end
define ft_best_op_idx
display *stack_a@stack_len
display *stack_b@stack_len
display stack_len
display idx
display cost
display start
display min_ops
display stack_a[idx]
display stack_b[idx]
end
define ft_get_align_ops
display *stack_a@(ft_stack_end(stack_a)+2)
display *stack_b@(ft_stack_end(stack_b)+2)
display idx
display n_ops
display order
display min_n_behind
display ft_stack_min(stack_b).num
display ft_stack_max(stack_b, -1).num
display stack_a[idx].num
display stack_b[min_n_behind.index]
end
# Start debugging from main.c
# fs cmd
# break main.c:52
# break ft_exec_move
# info break
# run
# main
# rfr
# next
# Start at ft_sort()
# fs cmd
# break main.c:118
# run
# info break
# ft_sort
# rfr
# Start at ft_sort_three()
# fs cmd
# break ft_sort_three
# run "1 3 2"
# # run "3 2 1"
# # sorted example
# # run "1 2 3"
# ft_sort_three
# nr
# Start at ft_create_stack()
# fs cmd
# break main.c:52
# info break
# run
# main
# step
# ft_create_stack
# nr
# Start at ft_sort_stack() : test with 9 elements
fs cmd
break ft_sort_stack
break ft_calc_move
info break
run
# target record-full
ft_sort_stack
nr
###
### Checker DBG
###
# define main
# display argc
# display *argv
# display *(argv+1)
# display *(argv+2)
# display *input_list
# display *stack_a
# display *stack_b
# display must_free
# display error
# end
#
# define ft_errors
# display argc
# display **input_list
# display **(input_list+1)
# end
#
# define ft_are_args_nbr
# display i
# display j
# display argc
# display **argv
# display **(argv+1)
# end
# Start debugging from checker.c
# fs cmd
# break main
# run "" 1
# main
# rfr
# next
# Start at ft_errors()
# fs cmd
# break ft_errors
# run "" 1
# ft_errors
# rfr
# next
# Start at ft_are_args_nbr()
# fs cmd
# break ft_are_args_nbr
# run "" 1
# ft_are_args_nbr
# rfr
# next