2 * Worldvisions Weaver Software:
3 * Copyright (C) 2005 Net Integration Technologies, Inc.
5 * Helper classes and functions to add more information to WvCrashes.
15 // WvCrash allows you to print a programme's last will and testament.
16 // That is, a little note about what it was hoping to do before it
19 // This helper class lets you write a will, and when it gets
20 // destroyed, it will restore the old will from before. This lets you
25 // Leave a will behind.
26 WvCrashWill(const char *will
);
27 WvCrashWill(WVSTRING_FORMAT_DECL
);
29 // Restore the will that was there before you created this object.
32 // Rewrite the will you're leaving behind.
33 void rewrite(const char *will
);
34 void rewrite(WVSTRING_FORMAT_DECL
);
39 #if !defined(__GLIBC__)
41 # define wvassert(expr, args...) assert(expr)
42 # define wvassert_perror(errnum) perror(errnum)
46 # define wvassert(expr, args...) (__ASSERT_VOID_CAST (0))
47 # define wvassert_perror(errnum) (__ASSERT_VOID_CAST (0))
51 static inline void __wvcrash_leave_will()
55 static inline void __wvcrash_leave_will(const char *will
)
57 wvcrash_leave_will(will
);
60 static inline void __wvcrash_leave_will(WVSTRING_FORMAT_DECL
)
62 wvcrash_leave_will(WvFastString(WVSTRING_FORMAT_CALL
));
65 // Use this function instead of assert(). You may also leave parameters
66 // at the end, which allow you to log messages. For instance:
68 // wvassert(a == b, "a: '%s'\n b: '%s'", a, b);
69 # define wvassert(expr, args...) \
70 (__ASSERT_VOID_CAST ((expr) ? 0 : \
71 (__wvcrash_leave_will (args), \
72 (__assert_fail (__STRING(expr), __FILE__, __LINE__, \
73 __ASSERT_FUNCTION), 0))))
75 // Use this function instead of assert_perror(). You may also leave
76 // parameters at the end, which allow you to log messages. For instance:
78 // wvassert(errno, "Error trying to read file: '%s'", filename);
79 # define wvassert_perror(errnum, args...) \
80 (__ASSERT_VOID_CAST (!(errnum) ? 0 : \
81 (__wvcrash_leave_will (args), \
82 (__assert_perror_fail ((errnum), __FILE__, __LINE__, \
83 __ASSERT_FUNCTION), 0))))