1 # gdb macros which may be useful for folks using gdb to debug
2 # apache. Delete it if it bothers you.
5 set $t = (apr_table_entry_t *)((apr_array_header_t *)$arg0)->elts
6 set $n = ((apr_array_header_t *)$arg0)->nelts
9 if $t[$i].val == (void *)0L
10 printf "[%u] '%s'=>NULL\n", $i, $t[$i].key
12 printf "[%u] '%s'='%s'\n", $i, $t[$i].key, $t[$i].val
18 Print the key/value pairs in a table.
21 define dump_string_hash
27 while $ent != (void *)0L
28 printf "'%s' => '%p'\n", $ent->key, $ent->val
34 document dump_string_hash
35 Print the entries in a hash table indexed by strings
38 define dump_string_shash
44 while $ent != (void *)0L
45 printf "'%s' => '%s'\n", $ent->key, $ent->val
51 document dump_string_shash
52 Print the entries in a hash table indexed by strings with string values
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
64 printf "[%u] '%s'\n", $i, $a[$i]
68 document dump_string_array
69 Print all of the elements in an array of strings.
75 if $arg0[$i] < 0x20 || $arg0[$i] > 0x7e
78 printf "%c", $arg0[$i]
84 define print_bkt_datacol
88 # arg3 == suppress header?
89 set $suppressheader = $arg3
101 define dump_bucket_ex
103 # arg1 == suppress header?
104 set $bucket = (struct apr_bucket *)$arg0
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
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
123 print_bkt_datacol "rc" "n/%c" 'a' $sh
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
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
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
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))
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
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
167 set $p = (apr_bucket_heap *)$bucket->data
169 set $data = $p->base+$bucket->start
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
179 if (($bucket->type == &apr_bucket_type_transient) || \
180 ($bucket->type == &apr_bucket_type_immortal))
181 set $data = ((char *)$bucket->data)+$bucket->start
193 set $datalen = $bucket->length
199 printmemn $data $datalen
204 set $datalen = $datalen + 1
208 print_bkt_datacol "rc" "%d" $refcount $sh
210 print_bkt_datacol "rc" "n/%c" 'a' $sh
214 # 3rd-party bucket type
215 print_bkt_datacol "contents" "[**unknown**%c" ']' $sh
217 print_bkt_datacol "rc" "n/%c" 'a' $sh
228 dump_bucket_ex $arg0 0
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"
251 while $bucket != $sentinel
253 dump_bucket_ex $bucket 1
255 set $bucket = $bucket->link.next
257 printf "end of brigade\n"
259 document dump_brigade
260 Print bucket brigade info
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, \
272 document dump_filters
273 Print filter chain info
276 define dump_process_rec
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
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
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"
313 set $max =(sizeof $arg0->free)/(sizeof $arg0->free[0])
315 set $node = $arg0->free[$i]
319 printf "%d, ", $node->endp - $node->first_avail
320 set $node = $node->next
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