summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwez <wez@1665872d-e22b-0410-9e5d-a57ad4215e6d>2007-03-17 22:46:01 +0000
committerwez <wez@1665872d-e22b-0410-9e5d-a57ad4215e6d>2007-03-17 22:46:01 +0000
commit3efa9de8c7a0a89024c07d41b6425b7633a61d74 (patch)
treea09c9dd26b7b0274bc157736d3a1bcd879e540db
parent82707c0f7d58a14511890552fcdf3e2d53d74282 (diff)
downloadportableumem-3efa9de8c7a0a89024c07d41b6425b7633a61d74.tar.gz
add gdb macros
git-svn-id: https://labs.omniti.com/portableumem/trunk@34 1665872d-e22b-0410-9e5d-a57ad4215e6d
-rw-r--r--gdb-macros117
1 files changed, 117 insertions, 0 deletions
diff --git a/gdb-macros b/gdb-macros
new file mode 100644
index 0000000..2b5419f
--- /dev/null
+++ b/gdb-macros
@@ -0,0 +1,117 @@
+# vim:ft=gdb:ts=2:sw=2:et:
+
+set $UMF_AUDIT = 1
+set $UMF_DEADBEEF = 2
+set $UMF_REDZONE = 4
+set $UMF_CONTENTS = 8
+set $UMF_CHECKSIGNAL = 16
+set $UMF_NOMAGAZINE = 32
+set $UMF_FIREWALL = 64
+set $UMF_LITE = 128
+set $UMF_HASH = 256
+set $UMF_RANDOMIZE = 512
+
+define umastat_cache
+ set $cp = $arg0
+ set $meminuse = ($cp->cache_slab_create - $cp->cache_slab_destroy) * $cp->cache_slabsize
+
+ if (($cp->cache_cpu[0].cc_magsize != 0) || ($cp->cache_flags & $UMF_NOMAGAZINE))
+ set $magsize = $cp->cache_cpu[0].cc_magsize
+ else
+ set $magsize = $cp->cache_magtype->mt_magsize
+ end
+
+ set $alloc = $cp->cache_slab_alloc + $cp->cache_full.ml_alloc
+ set $avail = $cp->cache_full.ml_total * $magsize
+ set $total = $cp->cache_buftotal
+
+ # walk the cpu caches
+ set $cpu_current = 0
+ while $cpu_current < umem_max_ncpus
+ set $cpu = umem_cpus[$cpu_current]
+ set $cpu_cache = (umem_cpu_cache_t*)((char*)$cp + $cpu->cpu_cache_offset)
+
+ if $cpu_cache->cc_rounds > 0
+ set $avail = $avail + $cpu_cache->cc_rounds
+ end
+ if $cpu_cache->cc_prounds > 0
+ set $avail = $avail + $cpu_cache->cc_prounds
+ end
+ set $alloc = $alloc + $cpu_cache->cc_alloc
+
+ set $cpu_current = $cpu_current + 1
+ end
+
+ # walk some slabs
+ set $slab = $cp->cache_nullslab.slab_next
+ while $slab != &$cp->cache_nullslab
+ set $avail = $avail + $slab->slab_chunks - $slab->slab_refcnt
+ set $slab = $slab->slab_next
+ end
+
+ printf "%-25s %6u %6u %6u %9u %9u %5llu\n", $cp->cache_name, $cp->cache_bufsize, $total - $avail, $total, $meminuse, $alloc, $cp->cache_alloc_fail
+end
+
+document umastat
+ umem allocator stats
+end
+
+define umastat
+ printf "cache buf buf buf memory alloc alloc\n"
+ printf "name size in use total in use succeed fail\n"
+ printf "---------------------------- ------ ------ ------ --------- --------- -----\n"
+ set $cp = umem_null_cache->cache_next
+ while $cp != &umem_null_cache
+ umastat_cache $cp
+ set $cp = $cp->cache_next
+ end
+ printf "---------------------------- ------ ------ ------ --------- --------- -----\n"
+ set $vmem = vmem_list
+ while $vmem != 0
+ set $meminuse = 0
+ set $alloc = 0
+ set $fail = 0
+ set $cp = umem_null_cache->cache_next
+ while $cp != &umem_null_cache
+ if $cp->cache_arena == $vmem
+ set $meminuse = $meminuse + (($cp->cache_slab_create - $cp->cache_slab_destroy) * $cp->cache_slabsize)
+
+ if (($cp->cache_cpu[0].cc_magsize != 0) || ($cp->cache_flags & $UMF_NOMAGAZINE))
+ set $magsize = $cp->cache_cpu[0].cc_magsize
+ else
+ set $magsize = $cp->cache_magtype->mt_magsize
+ end
+
+ set $alloc = $alloc + ($cp->cache_slab_alloc + $cp->cache_full.ml_alloc)
+ set $avail = $avail + ($cp->cache_full.ml_total * $magsize)
+ end
+ set $cp = $cp->cache_next
+ end
+ printf "Total %-25s %9u %9u %5u\n", $vmem->vm_name, $meminuse, $alloc, $fail
+ set $vmem = $vmem->vm_next
+ end
+end
+
+define umem_status
+ printf "Concurrency:\t%d\n", umem_max_ncpus
+ printf "Logs\t\t"
+ if umem_transaction_log != 0
+ printf "transaction=%d ", umem_transaction_log->lh_chunksize * umem_transaction_log->lh_nchunks
+ end
+ if umem_content_log != 0
+ printf "content=%d ", umem_content_log->lh_chunksize * umem_content_log->lh_nchunks
+ end
+ if umem_failure_log != 0
+ printf "fail=%d ", umem_failure_log->lh_chunksize * umem_failure_log->lh_nchunks
+ end
+ if umem_slab_log != 0
+ printf "slab=%d ", umem_slab_log->lh_chunksize * umem_slab_log->lh_nchunks
+ end
+ if umem_logging == 0
+ printf "(inactive)"
+ end
+ printf "\nMessage buffer:\n"
+ set $msg = &umem_error_buffer + umem_error_begin
+ printf "%s", $msg
+end
+