]> granicus.if.org Git - apache/blob - .gdbinit
Another experimental MPM derived from worker:
[apache] / .gdbinit
1 # gdb macros which may be useful for folks using gdb to debug
2 # apache.  Delete it if it bothers you.
3
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         printf "[%u] '%s'='%s'\n", $i, $t[$i].key, $t[$i].val
10         set $i = $i + 1
11     end
12 end
13 document dump_table
14     Print the key/value pairs in a table.
15 end
16
17
18 define rh
19         run -f /home/dgaudet/ap2/conf/mpm.conf
20 end
21
22 define ro
23         run -DONE_PROCESS
24 end
25
26 define dump_string_array
27     set $a = (char **)((apr_array_header_t *)$arg0)->elts
28     set $n = (int)((apr_array_header_t *)$arg0)->nelts
29     set $i = 0
30     while $i < $n
31         printf "[%u] '%s'\n", $i, $a[$i]
32         set $i = $i + 1
33     end
34 end
35 document dump_string_array
36     Print all of the elements in an array of strings.
37 end
38
39 define printmemn
40     set $i = 0
41     while $i < $arg1
42         if $arg0[$i] < 0x20 || $arg0[$i] > 0x7e
43             printf "~"
44         else
45             printf "%c", $arg0[$i]
46         end
47         set $i = $i + 1
48     end
49 end
50
51 define print_bkt_datacol
52     # arg0 == column name
53     # arg1 == format
54     # arg2 == value
55     # arg3 == suppress header?
56     set $suppressheader = $arg3
57
58     if !$suppressheader
59         printf " "
60         printf $arg0
61         printf "="
62     else
63         printf " | "
64     end
65     printf $arg1, $arg2
66 end
67
68 define dump_bucket_ex
69     # arg0 == bucket
70     # arg1 == suppress header?
71     set $bucket = (apr_bucket *)$arg0
72     set $sh = $arg1
73     set $refcount = -1
74
75     print_bkt_datacol "bucket" "%-9s" $bucket->type->name $sh
76     printf "(0x%08lx)", (unsigned long)$bucket
77     print_bkt_datacol "length" "%-6ld" (long)($bucket->length) $sh
78     print_bkt_datacol "data" "0x%08lx" $bucket->data $sh
79
80     if !$sh
81         printf "\n    "
82     end
83
84     if (($bucket->type == &apr_bucket_type_eos)   || \
85         ($bucket->type == &apr_bucket_type_flush))
86
87         # metadata buckets, no content
88         print_bkt_datacol "contents" "%c" ' ' $sh
89         printf "                     "
90         print_bkt_datacol "rc" "n/%c" 'a' $sh
91
92     else
93     if ($bucket->type == &ap_bucket_type_error)
94
95         # metadata bucket, no content but it does have an error code in it
96         print_bkt_datacol "contents" "%c" ' ' $sh
97         set $status = ((ap_bucket_error *)$bucket->data)->status
98         printf " (status=%3d)        ", $status
99         print_bkt_datacol "rc" "n/%c" 'a' $sh
100
101     else
102     if (($bucket->type == &apr_bucket_type_file) || \
103         ($bucket->type == &apr_bucket_type_pipe) || \
104         ($bucket->type == &apr_bucket_type_socket))
105
106         # buckets that contain data not in memory (ie not printable)
107
108         print_bkt_datacol "contents" "[**unprintable**%c" ']' $sh
109         if $bucket->type == &apr_bucket_type_file
110             set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
111             print_bkt_datacol "rc" "%d" $refcount $sh
112         end
113
114     else
115     if (($bucket->type == &apr_bucket_type_heap)      || \
116         ($bucket->type == &apr_bucket_type_pool)      || \
117         ($bucket->type == &apr_bucket_type_mmap)      || \
118         ($bucket->type == &apr_bucket_type_transient) || \
119         ($bucket->type == &apr_bucket_type_immortal))
120
121         # in-memory buckets
122
123         if $bucket->type == &apr_bucket_type_heap
124             set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
125             set $p = (apr_bucket_heap *)$bucket->data
126             set $data = $p->base+$bucket->start
127
128         else
129         if $bucket->type == &apr_bucket_type_pool
130             set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
131             set $p = (apr_bucket_pool *)$bucket->data
132             if $p->pool != NULL
133                 set $p = (apr_bucket_heap *)$bucket->data
134             end
135             set $data = $p->base+$bucket->start
136
137         else
138         if $bucket->type == &apr_bucket_type_mmap
139             # is this safe if not APR_HAS_MMAP?
140             set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
141             set $p = (apr_bucket_mmap *)$bucket->data
142             set $data = ((char *)$p->mmap->mm)+$bucket->start
143
144         else
145         if (($bucket->type == &apr_bucket_type_transient) || \
146             ($bucket->type == &apr_bucket_type_immortal))
147             set $data = ((char *)$bucket->data)+$bucket->start
148
149         end
150         end
151         end
152         end
153
154         if $sh
155             printf " | ["
156         else
157             printf " contents=["
158         end
159         set $datalen = $bucket->length
160         if $datalen > 17
161             printmem $data 17
162             printf "..."
163             set $datalen = 20
164         else
165             printmemn $data $datalen
166         end
167         printf "]"
168         while $datalen < 20
169             printf " "
170             set $datalen = $datalen + 1
171         end
172
173         if $refcount != -1
174             print_bkt_datacol "rc" "%d" $refcount $sh
175         else
176             print_bkt_datacol "rc" "n/%c" 'a' $sh
177         end
178
179     else
180         # 3rd-party bucket type
181         print_bkt_datacol "contents" "[**unknown**%c" ']' $sh
182         printf "         "
183         print_bkt_datacol "rc" "n/%c" 'a' $sh
184     end
185     end
186     end
187     end
188
189     printf "\n"
190
191 end
192
193 define dump_bucket
194     dump_bucket_ex $arg0 0
195 end
196 document dump_bucket
197     Print bucket info
198 end
199
200 define dump_brigade
201     set $bb = (apr_bucket_brigade *)$arg0
202     set $bucket = $bb->list.next
203     set $sentinel = ((char *)((&($bb->list)) \
204                                - ((size_t) &((apr_bucket *)0)->link)))
205     printf "dump of brigade 0x%lx\n", (unsigned long)$bb
206
207     printf "   | type     (address)    | length | "
208     printf "data addr  | contents               | rc\n"
209     printf "----------------------------------------"
210     printf "----------------------------------------\n"
211
212     if $bucket == $sentinel
213         printf "brigade is empty\n"
214     end
215
216     set $j = 0
217     while $bucket != $sentinel
218         printf "%2d", $j
219         dump_bucket_ex $bucket 1
220         set $j = $j + 1
221         set $bucket = $bucket->link.next
222     end
223     printf "end of brigade\n"
224 end
225 document dump_brigade
226     Print bucket brigade info
227 end
228
229 define dump_filters
230     set $f = $arg0
231     while $f
232         printf "%s(0x%lx): ctx=0x%lx, r=0x%lx, c=0x%lx\n", \
233         $f->frec->name, (unsigned long)$f, (unsigned long)$f->ctx, \
234         $f->r, $f->c
235         set $f = $f->next
236     end
237 end
238 document dump_filters
239     Print filter chain info
240 end
241
242 define dump_process_rec
243     set $p = $arg0
244     printf "process_rec=0x%lx:\n", (unsigned long)$p
245     printf "   pool=0x%lx, pconf=0x%lx\n", \
246            (unsigned long)$p->pool, (unsigned long)$p->pconf
247 end
248 document dump_process_rec
249     Print process_rec info
250 end
251
252 define dump_server_rec
253     set $s = $arg0
254     printf "name=%s:%d\n", \
255             $s->server_hostname, $s->port
256     dump_process_rec($s->process)
257 end
258 document dump_server_rec
259     Print server_rec info
260 end
261
262 define dump_servers
263     set $s = $arg0
264     while $s
265         dump_server_rec($s)
266         printf "\n"
267         set $s = $s->next
268     end
269 end
270 document dump_servers
271     Print server_rec list info
272 end