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' [%p]\n", $i, $t[$i].key, $t[$i].val, $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_filter_chain
278 set $f = $r->output_filters
280 if $f == $r->output_filters
281 printf "r->output_filters =>\n"
283 if $f == $r->proto_output_filters
284 printf "r->proto_output_filters =>\n"
286 if $f == $r->connection->output_filters
287 printf "r->connection->output_filters =>\n"
290 printf " %s(0x%lx): type=%d, ctx=0x%lx, r=%s(0x%lx), c=0x%lx\n", \
291 $f->frec->name, (unsigned long)$f, $f->frec->ftype, (unsigned long)$f->ctx, \
292 $f->r == $r ? "r" : ($f->r == 0L ? "null" : \
293 ($f->r == $r->main ? "r->main" : \
294 ($r->main && $f->r == $r->main->main ? "r->main->main" : "????"))), \
300 document dump_filter_chain
301 Print filter chain info given a request_rec pointer
304 define dump_process_rec
306 printf "process_rec=0x%lx:\n", (unsigned long)$p
307 printf " pool=0x%lx, pconf=0x%lx\n", \
308 (unsigned long)$p->pool, (unsigned long)$p->pconf
310 document dump_process_rec
311 Print process_rec info
314 define dump_server_rec
316 printf "name=%s:%d\n", \
317 $s->server_hostname, $s->port
318 dump_process_rec($s->process)
320 document dump_server_rec
321 Print server_rec info
332 document dump_servers
333 Print server_rec list info
336 define dump_request_tree
340 printf "r=(0x%lx): uri=%s, handler=%s, r->main=0x%lx\n", \
341 $r, $r->unparsed_uri, $r->handler ? $r->handler : "(none)", $r->main
346 define dump_allocator
347 printf "Allocator current_free_index = %d, max_free_index = %d\n", \
348 ($arg0)->current_free_index, ($arg0)->max_free_index
349 printf "Allocator free list:\n"
351 set $max =(sizeof $arg0->free)/(sizeof $arg0->free[0])
354 set $node = $arg0->free[$i]
358 printf "%d, ", 4096 << $node->index
359 set $kb = $kb + (4 << $node->index)
360 set $node = $node->next
366 printf "Sum of free blocks: %dkiB\n", $kb
368 document dump_allocator
369 Print status of an allocator and its freelists.
377 set $node = $arg0->active
380 set $size = $size + (4096 << $node->index)
381 set $free = $free + ($node->endp - $node->first_avail)
382 set $nodes = $nodes + 1
383 set $node = $node->next
384 if $node == $arg0->active
388 printf "Pool '%s' [%p]: %d/%d free (%d blocks)\n", $p->tag, $p, $free, $size, $nodes
391 # Set sane defaults for common signals:
392 handle SIGPIPE noprint pass nostop
393 handle SIGUSR1 print pass nostop