.gdbinit 7.0 KB

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