#define TRACE_SANITIZE() \
- hb_auto_trace_t<HB_DEBUG_SANITIZE> trace (&c->debug_depth, "SANITIZE", this, HB_FUNC, "");
+ hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace \
+ (&c->debug_depth, "SANITIZE", this, HB_FUNC, \
+ "");
struct hb_sanitize_context_t
{
const char *p = (const char *) base;
- hb_auto_trace_t<HB_DEBUG_SANITIZE> trace (&this->debug_depth, "SANITIZE", this->blob, NULL,
- "check_range [%p..%p] (%d bytes) in [%p..%p]",
- p, p + len, len,
- this->start, this->end);
+ hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace
+ (&this->debug_depth, "SANITIZE", this->blob, NULL,
+ "check_range [%p..%p] (%d bytes) in [%p..%p]",
+ p, p + len, len,
+ this->start, this->end);
return TRACE_RETURN (likely (this->start <= p && p <= this->end && (unsigned int) (this->end - p) >= len));
}
const char *p = (const char *) base;
bool overflows = _hb_unsigned_int_mul_overflows (len, record_size);
- hb_auto_trace_t<HB_DEBUG_SANITIZE> trace (&this->debug_depth, "SANITIZE", this->blob, NULL,
- "check_array [%p..%p] (%d*%d=%ld bytes) in [%p..%p]",
- p, p + (record_size * len), record_size, len, (unsigned long) record_size * len,
- this->start, this->end);
+ hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace
+ (&this->debug_depth, "SANITIZE", this->blob, NULL,
+ "check_array [%p..%p] (%d*%d=%ld bytes) in [%p..%p]",
+ p, p + (record_size * len), record_size, len, (unsigned long) record_size * len,
+ this->start, this->end);
return TRACE_RETURN (likely (!overflows && this->check_range (base, record_size * len)));
}
const char *p = (const char *) base;
this->edit_count++;
- hb_auto_trace_t<HB_DEBUG_SANITIZE> trace (&this->debug_depth, "SANITIZE", this->blob, NULL,
- "may_edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s",
- this->edit_count,
- p, p + len, len,
- this->start, this->end);
+ hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace
+ (&this->debug_depth, "SANITIZE", this->blob, NULL,
+ "may_edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s",
+ this->edit_count,
+ p, p + len, len,
+ this->start, this->end);
return TRACE_RETURN (this->writable);
}
#define TRACE_SERIALIZE() \
- hb_auto_trace_t<HB_DEBUG_SERIALIZE> trace (&c->debug_depth, "SERIALIZE", c, HB_FUNC, "");
+ hb_auto_trace_t<HB_DEBUG_SERIALIZE, bool> trace \
+ (&c->debug_depth, "SERIALIZE", c, HB_FUNC, \
+ "");
struct hb_serialize_context_t
namespace OT {
+
#ifndef HB_DEBUG_CLOSURE
#define HB_DEBUG_CLOSURE (HB_DEBUG+0)
#endif
#define TRACE_CLOSURE() \
- hb_auto_trace_t<HB_DEBUG_CLOSURE> trace (&c->debug_depth, "CLOSURE", this, HB_FUNC, "");
+ hb_auto_trace_t<HB_DEBUG_CLOSURE, void_t> trace \
+ (&c->debug_depth, "CLOSURE", this, HB_FUNC, \
+ "");
struct hb_closure_context_t
{
#endif
#define TRACE_WOULD_APPLY() \
- hb_auto_trace_t<HB_DEBUG_WOULD_APPLY> trace (&c->debug_depth, "WOULD_APPLY", this, HB_FUNC, "%d glyphs", c->len);
-
+ hb_auto_trace_t<HB_DEBUG_WOULD_APPLY, bool> trace \
+ (&c->debug_depth, "WOULD_APPLY", this, HB_FUNC, \
+ "%d glyphs", c->len);
struct hb_would_apply_context_t
{
#endif
#define TRACE_COLLECT_GLYPHS() \
- hb_auto_trace_t<HB_DEBUG_COLLECT_GLYPHS> trace (&c->debug_depth, "COLLECT_GLYPHS", this, HB_FUNC, "");
-
+ hb_auto_trace_t<HB_DEBUG_COLLECT_GLYPHS, void_t> trace \
+ (&c->debug_depth, "COLLECT_GLYPHS", this, HB_FUNC, \
+ "");
struct hb_collect_glyphs_context_t
{
#endif
#define TRACE_APPLY() \
- hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", this, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
-
+ hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace \
+ (&c->debug_depth, "APPLY", this, HB_FUNC, \
+ "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
struct hb_apply_context_t
{
bool *p_is_mark_ligature = NULL,
unsigned int *p_total_component_count = NULL)
{
- hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", NULL, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
+ hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace
+ (&c->debug_depth, "APPLY", NULL, HB_FUNC,
+ "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, count - 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
match_func_t match_func,
const void *match_data)
{
- hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", NULL, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
+ hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace
+ (&c->debug_depth, "APPLY", NULL, HB_FUNC,
+ "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
hb_apply_context_t::mark_skipping_backward_iterator_t skippy_iter (c, c->buffer->backtrack_len (), count, true);
if (skippy_iter.has_no_chance ())
const void *match_data,
unsigned int offset)
{
- hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", NULL, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
+ hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace
+ (&c->debug_depth, "APPLY", NULL, HB_FUNC,
+ "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx + offset - 1, count, true);
if (skippy_iter.has_no_chance ())
unsigned int lookupCount,
const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */)
{
- hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", NULL, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
+ hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace
+ (&c->debug_depth, "APPLY", NULL, HB_FUNC,
+ "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
+
unsigned int end = c->buffer->len;
if (unlikely (count == 0 || c->buffer->idx + count > end))
return TRACE_RETURN (false);
* Trace
*/
-template <int max_level>
+template <typename T>
+static inline void _hb_warn_no_return (bool returned)
+{
+ if (unlikely (!returned)) {
+ fprintf (stderr, "OUCH, returned with no call to TRACE_RETURN. This is a bug, please report.\n");
+ }
+}
+template <>
+inline void _hb_warn_no_return<void_t> (bool returned)
+{}
+
+template <int max_level, typename ret_t>
struct hb_auto_trace_t {
explicit inline hb_auto_trace_t (unsigned int *plevel_,
const char *what_,
}
inline ~hb_auto_trace_t (void)
{
- if (unlikely (!returned)) {
- fprintf (stderr, "OUCH, returned with no call to TRACE_RETURN. This is a bug, please report. Level was %d.\n", plevel ? *plevel : -1);
+ _hb_warn_no_return<ret_t> (returned);
+ if (!returned) {
_hb_debug_msg<max_level> (what, obj, NULL, true, plevel ? *plevel : 1, -1, " ");
- return;
}
-
if (plevel) --*plevel;
}
- template <typename T>
- inline T ret (T v, unsigned int line = 0)
+ inline ret_t ret (ret_t v, unsigned int line = 0)
{
if (unlikely (returned)) {
fprintf (stderr, "OUCH, double calls to TRACE_RETURN. This is a bug, please report.\n");
return v;
}
- _hb_debug_msg<max_level> (what, obj, NULL, true, plevel ? *plevel : 1, -1, "return %s (line %d)", hb_printer_t<bool>().print (v), line);
+ _hb_debug_msg<max_level> (what, obj, NULL, true, plevel ? *plevel : 1, -1,
+ "return %s (line %d)",
+ hb_printer_t<ret_t>().print (v), line);
if (plevel) --*plevel;
plevel = NULL;
returned = true;
const void *obj;
bool returned;
};
-template <> /* Optimize when tracing is disabled */
-struct hb_auto_trace_t<0> {
+template <typename ret_t> /* Optimize when tracing is disabled */
+struct hb_auto_trace_t<0, ret_t> {
explicit inline hb_auto_trace_t (unsigned int *plevel_ HB_UNUSED,
const char *what HB_UNUSED,
const void *obj HB_UNUSED,