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