diff options
author | phk <phk@FreeBSD.org> | 2004-03-10 08:49:08 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-03-10 08:49:08 +0000 |
commit | 9a7074f4cb924ae82908691b9014ec3046fa7a8a (patch) | |
tree | 3d29009688ec2443c80b12f054dff9ab4238ba22 /sys/geom/geom.h | |
parent | 7432091236a4f7e854963b7353bb9e33c7f126ad (diff) | |
download | FreeBSD-src-9a7074f4cb924ae82908691b9014ec3046fa7a8a.zip FreeBSD-src-9a7074f4cb924ae82908691b9014ec3046fa7a8a.tar.gz |
Rearrange some of the GEOM debugging tools to be more structured.
Retire g_sanity() and corresponding debugflag (0x8)
Retire g_{stall,release}_events().
Under #ifdef DIAGNOSTIC:
Make g_valid_obj() an official function and have it return an an
non-zero integer which indicates the kind of object when found.
Implement G_VALID_{CLASS,GEOM,CONSUMER,PROVIDER}() macros based
on g_valid_obj().
Sprinkle calls to these macros liberally over the infrastructure.
Always check that we do not free a live object.
Diffstat (limited to 'sys/geom/geom.h')
-rw-r--r-- | sys/geom/geom.h | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h index 63db46a..31002fe 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -221,13 +221,29 @@ int g_handleattr_off_t(struct bio *bp, const char *attribute, off_t val); struct g_consumer * g_new_consumer(struct g_geom *gp); struct g_geom * g_new_geomf(struct g_class *mp, const char *fmt, ...); struct g_provider * g_new_providerf(struct g_geom *gp, const char *fmt, ...); -void g_sanity(void const *ptr); void g_spoil(struct g_provider *pp, struct g_consumer *cp); int g_std_access(struct g_provider *pp, int dr, int dw, int de); void g_std_done(struct bio *bp); void g_std_spoiled(struct g_consumer *cp); void g_wither_geom(struct g_geom *gp, int error); +#ifdef DIAGNOSTIC +int g_valid_obj(void const *ptr); +#define G_VALID_CLASS(foo) \ + KASSERT(g_valid_obj(foo) == 1, ("%p is not a g_class", foo)) +#define G_VALID_GEOM(foo) \ + KASSERT(g_valid_obj(foo) == 2, ("%p is not a g_geom", foo)) +#define G_VALID_CONSUMER(foo) \ + KASSERT(g_valid_obj(foo) == 3, ("%p is not a g_consumer", foo)) +#define G_VALID_PROVIDER(foo) \ + KASSERT(g_valid_obj(foo) == 4, ("%p is not a g_provider", foo)) +#else +#define G_VALID_CLASS(foo) do { } while (0) +#define G_VALID_GEOM(foo) do { } while (0) +#define G_VALID_CONSUMER(foo) do { } while (0) +#define G_VALID_PROVIDER(foo) do { } while (0) +#endif + int g_modevent(module_t, int, void *); /* geom_io.c */ @@ -258,16 +274,17 @@ g_malloc(int size, int flags) void *p; p = malloc(size, M_GEOM, flags); - g_sanity(p); - /* printf("malloc(%d, %x) -> %p\n", size, flags, p); */ return (p); } static __inline void g_free(void *ptr) { - g_sanity(ptr); - /* printf("free(%p)\n", ptr); */ + +#ifdef DIAGNOSTIC + KASSERT(g_valid_obj(ptr) == 0, + ("g_free(%p) of live object, type %d", ptr, g_valid_obj(ptr))); +#endif free(ptr, M_GEOM); } @@ -281,19 +298,16 @@ extern struct sx topology_lock; #define g_topology_unlock() \ do { \ - g_sanity(NULL); \ sx_xunlock(&topology_lock); \ } while (0) #define g_topology_assert() \ do { \ - g_sanity(NULL); \ sx_assert(&topology_lock, SX_XLOCKED); \ } while (0) #define g_topology_assert_not() \ do { \ - g_sanity(NULL); \ sx_assert(&topology_lock, SX_UNLOCKED); \ } while (0) |