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.
22 set $sl = (apr_skiplist *)$arg0
24 printf "skiplist@%p: size=%lu: height=%d\n", $sl, $sl->size, $sl->height
26 printf "(%p,%.12lx)", $m, $m->data
29 printf " (%p,%.12lx)", $u, $u->data
36 document dump_skiplist
37 Print the nodes/values in a skiplist
40 define dump_string_hash
46 while $ent != (void *)0L
47 printf "'%s' => '%p'\n", $ent->key, $ent->val
53 document dump_string_hash
54 Print the entries in a hash table indexed by strings
57 define dump_string_shash
63 while $ent != (void *)0L
64 printf "'%s' => '%s'\n", $ent->key, $ent->val
70 document dump_string_shash
71 Print the entries in a hash table indexed by strings with string values
78 define dump_string_array
79 set $a = (char **)((apr_array_header_t *)$arg0)->elts
80 set $n = (int)((apr_array_header_t *)$arg0)->nelts
83 printf "[%u] '%s'\n", $i, $a[$i]
87 document dump_string_array
88 Print all of the elements in an array of strings.
94 if $arg0[$i] < 0x20 || $arg0[$i] > 0x7e
97 printf "%c", $arg0[$i]
103 define print_bkt_datacol
104 # arg0 == column name
107 # arg3 == suppress header?
108 set $suppressheader = $arg3
120 define dump_bucket_ex
122 # arg1 == suppress header?
123 set $bucket = (struct apr_bucket *)$arg0
127 print_bkt_datacol "bucket" "%-9s" $bucket->type->name $sh
128 printf "(0x%08lx)", (unsigned long)$bucket
129 print_bkt_datacol "length" "%-6ld" (long)($bucket->length) $sh
130 print_bkt_datacol "data" "0x%08lx" $bucket->data $sh
136 if (($bucket->type == &apr_bucket_type_eos) || \
137 ($bucket->type == &apr_bucket_type_flush))
139 # metadata buckets, no content
140 print_bkt_datacol "contents" "%c" ' ' $sh
142 print_bkt_datacol "rc" "n/%c" 'a' $sh
145 if ($bucket->type == &ap_bucket_type_error)
147 # metadata bucket, no content but it does have an error code in it
148 print_bkt_datacol "contents" "%c" ' ' $sh
149 set $status = ((ap_bucket_error *)$bucket->data)->status
150 printf " (status=%3d) ", $status
151 print_bkt_datacol "rc" "n/%c" 'a' $sh
154 if (($bucket->type == &apr_bucket_type_file) || \
155 ($bucket->type == &apr_bucket_type_pipe) || \
156 ($bucket->type == &apr_bucket_type_socket))
158 # buckets that contain data not in memory (ie not printable)
160 print_bkt_datacol "contents" "[**unprintable**%c" ']' $sh
162 if $bucket->type == &apr_bucket_type_file
163 set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
164 print_bkt_datacol "rc" "%d" $refcount $sh
168 if (($bucket->type == &apr_bucket_type_heap) || \
169 ($bucket->type == &apr_bucket_type_pool) || \
170 ($bucket->type == &apr_bucket_type_mmap) || \
171 ($bucket->type == &apr_bucket_type_transient) || \
172 ($bucket->type == &apr_bucket_type_immortal))
176 if $bucket->type == &apr_bucket_type_heap
177 set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
178 set $p = (apr_bucket_heap *)$bucket->data
179 set $data = $p->base+$bucket->start
182 if $bucket->type == &apr_bucket_type_pool
183 set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
184 set $p = (apr_bucket_pool *)$bucket->data
186 set $p = (apr_bucket_heap *)$bucket->data
188 set $data = $p->base+$bucket->start
191 if $bucket->type == &apr_bucket_type_mmap
192 # is this safe if not APR_HAS_MMAP?
193 set $refcount = ((apr_bucket_refcount *)$bucket->data)->refcount
194 set $p = (apr_bucket_mmap *)$bucket->data
195 set $data = ((char *)$p->mmap->mm)+$bucket->start
198 if (($bucket->type == &apr_bucket_type_transient) || \
199 ($bucket->type == &apr_bucket_type_immortal))
200 set $data = ((char *)$bucket->data)+$bucket->start
212 set $datalen = $bucket->length
218 printmemn $data $datalen
223 set $datalen = $datalen + 1
227 print_bkt_datacol "rc" "%d" $refcount $sh
229 print_bkt_datacol "rc" "n/%c" 'a' $sh
233 # 3rd-party bucket type
234 print_bkt_datacol "contents" "[**unknown**%c" ']' $sh
236 print_bkt_datacol "rc" "n/%c" 'a' $sh
247 dump_bucket_ex $arg0 0
254 set $bb = (apr_bucket_brigade *)$arg0
255 set $bucket = $bb->list.next
256 set $sentinel = ((char *)((&($bb->list)) \
257 - ((size_t) &((struct apr_bucket *)0)->link)))
258 printf "dump of brigade 0x%lx\n", (unsigned long)$bb
260 printf " | type (address) | length | "
261 printf "data addr | contents | rc\n"
262 printf "----------------------------------------"
263 printf "----------------------------------------\n"
265 if $bucket == $sentinel
266 printf "brigade is empty\n"
270 while $bucket != $sentinel
272 dump_bucket_ex $bucket 1
274 set $bucket = $bucket->link.next
276 printf "end of brigade\n"
278 document dump_brigade
279 Print bucket brigade info
285 printf "%s(0x%lx): ctx=0x%lx, r=0x%lx, c=0x%lx\n", \
286 $f->frec->name, (unsigned long)$f, (unsigned long)$f->ctx, \
291 document dump_filters
292 Print filter chain info
295 define dump_filter_chain
297 set $f = $r->output_filters
299 if $f == $r->output_filters
300 printf "r->output_filters =>\n"
302 if $f == $r->proto_output_filters
303 printf "r->proto_output_filters =>\n"
305 if $f == $r->connection->output_filters
306 printf "r->connection->output_filters =>\n"
309 printf " %s(0x%lx): type=%d, ctx=0x%lx, r=%s(0x%lx), c=0x%lx\n", \
310 $f->frec->name, (unsigned long)$f, $f->frec->ftype, (unsigned long)$f->ctx, \
311 $f->r == $r ? "r" : ($f->r == 0L ? "null" : \
312 ($f->r == $r->main ? "r->main" : \
313 ($r->main && $f->r == $r->main->main ? "r->main->main" : "????"))), \
319 document dump_filter_chain
320 Print filter chain info given a request_rec pointer
323 define dump_process_rec
325 printf "process_rec=0x%lx:\n", (unsigned long)$p
326 printf " pool=0x%lx, pconf=0x%lx\n", \
327 (unsigned long)$p->pool, (unsigned long)$p->pconf
329 document dump_process_rec
330 Print process_rec info
333 define dump_server_rec
335 printf "name=%s:%d\n", \
336 $s->server_hostname, $s->port
337 dump_process_rec($s->process)
339 document dump_server_rec
340 Print server_rec info
351 document dump_servers
352 Print server_rec list info
355 define dump_request_tree
359 printf "r=(0x%lx): uri=%s, handler=%s, r->main=0x%lx\n", \
360 $r, $r->unparsed_uri, $r->handler ? $r->handler : "(none)", $r->main
365 define dump_allocator
366 printf "Allocator current_free_index = %d, max_free_index = %d\n", \
367 ($arg0)->current_free_index, ($arg0)->max_free_index
368 printf "Allocator free list:\n"
370 set $max =(sizeof $arg0->free)/(sizeof $arg0->free[0])
373 set $node = $arg0->free[$i]
377 printf "%d, ", 4096 << $node->index
378 set $kb = $kb + (4 << $node->index)
379 set $node = $node->next
385 printf "Sum of free blocks: %dkiB\n", $kb
387 document dump_allocator
388 Print status of an allocator and its freelists.
396 set $node = $arg0->active
399 set $size = $size + (4096 << $node->index)
400 set $free = $free + ($node->endp - $node->first_avail)
401 set $nodes = $nodes + 1
402 set $node = $node->next
403 if $node == $arg0->active
407 printf "Pool '%s' [%p]: %d/%d free (%d blocks)\n", $p->tag, $p, $free, $size, $nodes
410 # Set sane defaults for common signals:
411 handle SIGPIPE noprint pass nostop
412 handle SIGUSR1 print pass nostop