From 4d7eb0ee6a8d1def909924d4ec735580a56366ed Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 30 Jul 2013 16:39:41 +0100 Subject: Fix debugging Use %z for sizeof() arguments Extra debugging for conflicting RBtree entries --- bmm_lib.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/bmm_lib.c b/bmm_lib.c index 4bc1e35..93c6182 100644 --- a/bmm_lib.c +++ b/bmm_lib.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -28,10 +29,9 @@ #undef DEBUG #ifdef DEBUG -#include -#define pr_debug(fmt, arg...) fprintf(stderr, fmt, ##arg) +#define pr_debug(fmt, arg...) do { fprintf(stderr, fmt, ##arg); } while (0) #else -#define pr_debug(fmt, arg...) do { } while(0) +#define pr_debug(fmt, arg...) do { if (0) fprintf(stderr, fmt, ##arg); } while (0) #endif #define API_FEAT_MIN 0x0000 @@ -82,7 +82,7 @@ static struct bmm_buffer *bmm_buf_find_virt(void *virt) if (found) { buf = rb_val(node); - pr_debug("rb: %s(%p) phys=0x%08lx virt=%p size=0x%08lx\n", + pr_debug("rb: %s(%p) phys=0x%08lx virt=%p size=0x%08zx\n", "find_virt", virt, buf->paddr, buf->vaddr, buf->size); } else { pr_debug("rb: %s(%p): not found\n", @@ -102,7 +102,7 @@ static struct bmm_buffer *bmm_buf_find_phys(unsigned long phys) if (found) { buf = rb_val(node); - pr_debug("rb: %s(0x%08lx) phys=0x%08lx virt=%p size=0x%08lx\n", + pr_debug("rb: %s(0x%08lx) phys=0x%08lx virt=%p size=0x%08zx\n", "find_phys", (unsigned long)phys, buf->paddr, buf->vaddr, buf->size); } else { pr_debug("rb: %s(0x%08lx): not found\n", @@ -117,7 +117,7 @@ static void bmm_buf_remove(struct bmm_buffer *buf) Rb_node node; int found = 0; - pr_debug("rb: %s phys=0x%08lx virt=%p size=0x%08lx\n", + pr_debug("rb: %s phys=0x%08lx virt=%p size=0x%08zx\n", "remove", buf->paddr, buf->vaddr, buf->size); node = rb_find_key_n(virt_rb, buf->vaddr, cmp_virt, &found); @@ -134,14 +134,24 @@ static void bmm_buf_insert(struct bmm_buffer *buf) Rb_node node; int found = 0; - pr_debug("rb: %s phys=0x%08lx virt=%p size=0x%08lx\n", + pr_debug("rb: %s phys=0x%08lx virt=%p size=0x%08zx\n", "insert", buf->paddr, buf->vaddr, buf->size); node = rb_find_key_n(virt_rb, buf->vaddr, cmp_virt, &found); + if (found) { + struct bmm_buffer *f = rb_val(node); + pr_debug("rb: found: %p\n", f); + pr_debug(" p0x%08lx v%p s0x%08zx\n", f->paddr, f->vaddr, f->size); + } assert(found == 0); rb_insert_b(node, buf); node = rb_find_key_n(phys_rb, (void *)buf->paddr, cmp_phys, &found); + if (found) { + struct bmm_buffer *f = rb_val(node); + pr_debug("rb: found: %p\n", f); + pr_debug(" p0x%08lx v%p s0x%08zx\n", f->paddr, f->vaddr, f->size); + } assert(found == 0); rb_insert_b(node, buf); } -- cgit