diff options
author | Russell King <rmk@arm.linux.org.uk> | 2013-07-30 16:39:41 +0100 |
---|---|---|
committer | Russell King <rmk@arm.linux.org.uk> | 2013-07-30 16:39:41 +0100 |
commit | 4d7eb0ee6a8d1def909924d4ec735580a56366ed (patch) | |
tree | 647ded4fa5500e69f280713c972f6a4a23f3a0ae /bmm_lib.c | |
parent | aff67f5ea273187a6890e939db94d5c2e57e0338 (diff) |
Fix debugging
Use %z for sizeof() arguments
Extra debugging for conflicting RBtree entries
Diffstat (limited to 'bmm_lib.c')
-rw-r--r-- | bmm_lib.c | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -18,6 +18,7 @@ #include <assert.h> #include <fcntl.h> #include <pthread.h> +#include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -28,10 +29,9 @@ #undef DEBUG #ifdef DEBUG -#include <stdio.h> -#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); } |