Change from dos to unix convention
[httpd-crcsyncproxy.git] / .gdbinit
blob6194156dd27f65c9353200c650209fb8630c60d1
1 # gdb macros which may be useful for folks using gdb to debug
2 # apache.  Delete it if it bothers you.
4 define dump_table
5     set $t = (apr_table_entry_t *)((apr_array_header_t *)$arg0)->elts
6     set $n = ((apr_array_header_t *)$arg0)->nelts
7     set $i = 0
8     while $i < $n
9         if $t[$i].val == (void *)0L
10            printf "[%u] '%s'=>NULL\n", $i, $t[$i].key
11         else
12            printf "[%u] '%s'='%s'\n", $i, $t[$i].key, $t[$i].val
13         end
14         set $i = $i + 1
15     end
16 end
17 document dump_table
18     Print the key/value pairs in a table.
19 end
21 define dump_string_hash
22     set $h = $arg0->array
23     set $n = $arg0->max
24     set $i = 0
25     while $i < $n
26         set $ent = $h[$i]       
27         while $ent != (void *)0L
28             printf "'%s' => '%p'\n", $ent->key, $ent->val
29             set $ent = $ent->next
30         end
31         set $i = $i + 1
32     end
33 end
34 document dump_string_hash
35     Print the entries in a hash table indexed by strings
36 end
38 define dump_string_shash
39     set $h = $arg0->array
40     set $n = $arg0->max
41     set $i = 0
42     while $i < $n
43         set $ent = $h[$i]       
44         while $ent != (void *)0L
45             printf "'%s' => '%s'\n", $ent->key, $ent->val
46             set $ent = $ent->next
47         end
48         set $i = $i + 1
49     end
50 end
51 document dump_string_shash
52     Print the entries in a hash table indexed by strings with string values
53 end
55 define ro
56         run -DONE_PROCESS
57 end
59 define dump_string_array
60     set $a = (char **)((apr_array_header_t *)$arg0)->elts
61     set $n = (int)((apr_array_header_t *)$arg0)->nelts
62     set $i = 0
63     while $i < $n
64         printf "[%u] '%s'\n", $i, $a[$i]
65         set $i = $i + 1
66     end
67 end
68 document dump_string_array
69     Print all of the elements in an array of strings.
70 end
72 define printmemn
73     set $i = 0
74     while $i < $arg1
75         if $arg0[$i] < 0x20 || $arg0[$i] > 0x7e
76             printf "~"
77         else
78             printf "%c", $arg0[$i]
79         end
80         set $i = $i + 1
81     end
82 end
84 define print_bkt_datacol
85     # arg0 == column name
86     # arg1 == format
87     # arg2 == value
88     # arg3 == suppress header?
89     set $suppressheader = $arg3
91     if !$suppressheader
92         printf " "
93         printf $arg0
94         printf "="
95     else
96         printf " | "
97     end
98     printf $arg1, $arg2
99 end
101 define dump_bucket_ex
102     # arg0 == bucket
103     # arg1 == suppress header?
104     set $bucket = (struct apr_bucket *)$arg0
105     set $sh = $arg1
106     set $refcount = -1
108     print_bkt_datacol "bucket" "%-9s" $bucket->type->name $sh
109     printf "(0x%08lx)", (unsigned long)$bucket
110     print_bkt_datacol "length" "%-6ld" (long)($bucket->length) $sh
111     print_bkt_datacol "data" "0x%08lx" $bucket->data $sh
113     if !$sh
114         printf "\n    "
115     end
117     if (($bucket->type == &apr_bucket_type_eos)   || \
118         ($bucket->type == &apr_bucket_type_flush))
120         # metadata buckets, no content
121         print_bkt_datacol "contents" "%c" ' ' $sh
122         printf "                     "
123         print_bkt_datacol "rc" "n/%c" 'a' $sh
125     else
126     if ($bucket->type == &ap_bucket_type_error)
128         # metadata bucket, no content but it does have an error code in it
129         print_bkt_datacol "contents" "%c" ' ' $sh
130         set $status = ((ap_bucket_error *)$bucket->data)->status
131         printf " (status=%3d)        ", $status
132         print_bkt_datacol "rc" "n/%c" 'a' $sh
134     else
135     if (($bucket->type == &apr_bucket_type_file) || \
136         ($bucket->type == &apr_bucket_type_pipe) || \
137         ($bucket->type == &apr_bucket_type_socket))
139         # buckets that contain data not in memory (ie not printable)
141         print_bkt_datacol "contents" "[**unprintable**%c" ']' $sh
142         printf "     "
143         if $bucket->type == &apr_bucket_type_file
144             set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
145             print_bkt_datacol "rc" "%d" $refcount $sh
146         end
148     else
149     if (($bucket->type == &apr_bucket_type_heap)      || \
150         ($bucket->type == &apr_bucket_type_pool)      || \
151         ($bucket->type == &apr_bucket_type_mmap)      || \
152         ($bucket->type == &apr_bucket_type_transient) || \
153         ($bucket->type == &apr_bucket_type_immortal))
155         # in-memory buckets
157         if $bucket->type == &apr_bucket_type_heap
158             set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
159             set $p = (apr_bucket_heap *)$bucket->data
160             set $data = $p->base+$bucket->start
162         else
163         if $bucket->type == &apr_bucket_type_pool
164             set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
165             set $p = (apr_bucket_pool *)$bucket->data
166             if !$p->pool
167                 set $p = (apr_bucket_heap *)$bucket->data
168             end
169             set $data = $p->base+$bucket->start
171         else
172         if $bucket->type == &apr_bucket_type_mmap
173             # is this safe if not APR_HAS_MMAP?
174             set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
175             set $p = (apr_bucket_mmap *)$bucket->data
176             set $data = ((char *)$p->mmap->mm)+$bucket->start
178         else
179         if (($bucket->type == &apr_bucket_type_transient) || \
180             ($bucket->type == &apr_bucket_type_immortal))
181             set $data = ((char *)$bucket->data)+$bucket->start
183         end
184         end
185         end
186         end
188         if $sh
189             printf " | ["
190         else
191             printf " contents=["
192         end
193         set $datalen = $bucket->length
194         if $datalen > 17
195             printmem $data 17
196             printf "..."
197             set $datalen = 20
198         else
199             printmemn $data $datalen
200         end
201         printf "]"
202         while $datalen < 20
203             printf " "
204             set $datalen = $datalen + 1
205         end
207         if $refcount != -1
208             print_bkt_datacol "rc" "%d" $refcount $sh
209         else
210             print_bkt_datacol "rc" "n/%c" 'a' $sh
211         end
213     else
214         # 3rd-party bucket type
215         print_bkt_datacol "contents" "[**unknown**%c" ']' $sh
216         printf "         "
217         print_bkt_datacol "rc" "n/%c" 'a' $sh
218     end
219     end
220     end
221     end
223     printf "\n"
227 define dump_bucket
228     dump_bucket_ex $arg0 0
230 document dump_bucket
231     Print bucket info
234 define dump_brigade
235     set $bb = (apr_bucket_brigade *)$arg0
236     set $bucket = $bb->list.next
237     set $sentinel = ((char *)((&($bb->list)) \
238                                - ((size_t) &((struct apr_bucket *)0)->link)))
239     printf "dump of brigade 0x%lx\n", (unsigned long)$bb
241     printf "   | type     (address)    | length | "
242     printf "data addr  | contents               | rc\n"
243     printf "----------------------------------------"
244     printf "----------------------------------------\n"
246     if $bucket == $sentinel
247         printf "brigade is empty\n"
248     end
250     set $j = 0
251     while $bucket != $sentinel
252         printf "%2d", $j
253         dump_bucket_ex $bucket 1
254         set $j = $j + 1
255         set $bucket = $bucket->link.next
256     end
257     printf "end of brigade\n"
259 document dump_brigade
260     Print bucket brigade info
263 define dump_filters
264     set $f = $arg0
265     while $f
266         printf "%s(0x%lx): ctx=0x%lx, r=0x%lx, c=0x%lx\n", \
267         $f->frec->name, (unsigned long)$f, (unsigned long)$f->ctx, \
268         $f->r, $f->c
269         set $f = $f->next
270     end
272 document dump_filters
273     Print filter chain info
276 define dump_process_rec
277     set $p = $arg0
278     printf "process_rec=0x%lx:\n", (unsigned long)$p
279     printf "   pool=0x%lx, pconf=0x%lx\n", \
280            (unsigned long)$p->pool, (unsigned long)$p->pconf
282 document dump_process_rec
283     Print process_rec info
286 define dump_server_rec
287     set $s = $arg0
288     printf "name=%s:%d\n", \
289             $s->server_hostname, $s->port
290     dump_process_rec($s->process)
292 document dump_server_rec
293     Print server_rec info
296 define dump_servers
297     set $s = $arg0
298     while $s
299         dump_server_rec($s)
300         printf "\n"
301         set $s = $s->next
302     end
304 document dump_servers
305     Print server_rec list info
308 define dump_allocator
309     printf "Allocator current_free_index = %d, max_free_index = %d\n", \
310             ($arg0)->current_free_index, ($arg0)->max_free_index
311     printf "Allocator free list:\n"
312     set $i = 0
313     set $max =(sizeof $arg0->free)/(sizeof $arg0->free[0])
314     while $i < $max
315         set $node = $arg0->free[$i]
316         if $node != 0
317             printf " #%2d: ", $i
318             while $node != 0
319                 printf "%d, ", $node->endp - $node->first_avail
320                 set $node = $node->next
321             end
322             printf "ends.\n"
323         end
324         set $i = $i + 1
325     end
327 document dump_allocator
328     Print status of an allocator and its freelists.
331 # Set sane defaults for common signals:
332 handle SIGPIPE noprint pass nostop
333 handle SIGUSR1 print pass nostop