87 _hb_debug (
unsigned int level,
88 unsigned int max_level)
90 return level < max_level;
93 #define DEBUG_LEVEL_ENABLED(WHAT, LEVEL) (_hb_debug ((LEVEL), HB_DEBUG_##WHAT))
94 #define DEBUG_ENABLED(WHAT) (DEBUG_LEVEL_ENABLED (WHAT, 0))
97 _hb_print_func (
const char *
func)
109 const char *space = strchr (
func,
' ');
113 const char *paren = strchr (
func,
'(');
115 func_len = paren -
func;
116 fprintf (stderr,
"%.*s", func_len,
func);
120 template <
int max_level>
static inline void
121 _hb_debug_msg_va (
const char *what,
129 template <
int max_level>
static inline void
130 _hb_debug_msg_va (
const char *what,
139 if (!_hb_debug (
level, max_level))
142 fprintf (stderr,
"%-10s", what ? what :
"");
145 fprintf (stderr,
"(%*p) ", (
unsigned int) (2 *
sizeof (
void *)),
obj);
147 fprintf (stderr,
" %*s ", (
unsigned int) (2 *
sizeof (
void *)),
"");
150 #define VBAR "\342\224\202"
151 #define VRBAR "\342\224\234"
152 #define DLBAR "\342\225\256"
153 #define ULBAR "\342\225\257"
154 #define LBAR "\342\225\264"
155 static const char bars[] =
161 fprintf (stderr,
"%2u %s" VRBAR "%s",
163 bars +
sizeof (bars) - 1 - hb_min ((
unsigned int)
sizeof (bars) - 1, (
unsigned int) (
sizeof (
VBAR) - 1) *
level),
168 _hb_print_func (
func);
172 fprintf (stderr,
": ");
173 vfprintf (stderr,
message, ap);
176 fprintf (stderr,
"\n");
188 template <
int max_level>
static inline void
189 _hb_debug_msg (
const char *what,
198 _hb_debug_msg (
const char *what,
212 template <>
inline void
231 #define DEBUG_MSG_LEVEL(WHAT, OBJ, LEVEL, LEVEL_DIR, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), nullptr, true, (LEVEL), (LEVEL_DIR), __VA_ARGS__)
232 #define DEBUG_MSG(WHAT, OBJ, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), nullptr, false, 0, 0, __VA_ARGS__)
233 #define DEBUG_MSG_FUNC(WHAT, OBJ, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), HB_FUNC, false, 0, 0, __VA_ARGS__)
240 template <
typename T>
241 struct hb_printer_t {
242 const char *print (
const T&) {
return "something"; }
246 struct hb_printer_t<bool> {
247 const char *
print (
bool v) {
return v ?
"true" :
"false"; }
260 template <
typename T>
261 static inline void _hb_warn_no_return (
bool returned)
264 fprintf (stderr,
"OUCH, returned with no call to return_trace(). This is a bug, please report.\n");
271 template <
int max_level,
typename ret_t>
280 : plevel (plevel_), what (what_),
obj (obj_), returned (
false)
282 if (plevel) ++*plevel;
291 _hb_warn_no_return<ret_t> (returned);
293 _hb_debug_msg<max_level> (what,
obj,
nullptr,
true, plevel ? *plevel : 1, -1,
" ");
295 if (plevel) --*plevel;
298 template <
typename T>
300 const char *
func =
"",
301 unsigned int line = 0)
304 fprintf (stderr,
"OUCH, double calls to return_trace(). This is a bug, please report.\n");
305 return std::forward<T> (
v);
308 _hb_debug_msg<max_level> (what,
obj,
func,
true, plevel ? *plevel : 1, -1,
309 "return %s (line %d)",
311 if (plevel) --*plevel;
314 return std::forward<T> (
v);
318 unsigned int *plevel;
323 template <
typename ret_t>
333 template <
typename T>
341 template <
typename ret_t>
343 template <
typename T>
349 #define return_trace(RET) return trace.ret (RET, HB_FUNC, __LINE__)
356 #ifndef HB_DEBUG_ARABIC
357 #define HB_DEBUG_ARABIC (HB_DEBUG+0)
360 #ifndef HB_DEBUG_BLOB
361 #define HB_DEBUG_BLOB (HB_DEBUG+0)
364 #ifndef HB_DEBUG_CORETEXT
365 #define HB_DEBUG_CORETEXT (HB_DEBUG+0)
368 #ifndef HB_DEBUG_DIRECTWRITE
369 #define HB_DEBUG_DIRECTWRITE (HB_DEBUG+0)
373 #define HB_DEBUG_FT (HB_DEBUG+0)
376 #ifndef HB_DEBUG_OBJECT
377 #define HB_DEBUG_OBJECT (HB_DEBUG+0)
380 #ifndef HB_DEBUG_SHAPE_PLAN
381 #define HB_DEBUG_SHAPE_PLAN (HB_DEBUG+0)
384 #ifndef HB_DEBUG_UNISCRIBE
385 #define HB_DEBUG_UNISCRIBE (HB_DEBUG+0)
392 #ifndef HB_DEBUG_APPLY
393 #define HB_DEBUG_APPLY (HB_DEBUG+0)
396 #define TRACE_APPLY(this) \
397 hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace \
398 (&c->debug_depth, c->get_name (), this, HB_FUNC, \
399 "idx %d gid %u lookup %d", \
400 c->buffer->idx, c->buffer->cur().codepoint, (int) c->lookup_index)
402 #define TRACE_APPLY(this) hb_no_trace_t<bool> trace
405 #ifndef HB_DEBUG_SANITIZE
406 #define HB_DEBUG_SANITIZE (HB_DEBUG+0)
408 #if HB_DEBUG_SANITIZE
409 #define TRACE_SANITIZE(this) \
410 hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace \
411 (&c->debug_depth, c->get_name (), this, HB_FUNC, \
414 #define TRACE_SANITIZE(this) hb_no_trace_t<bool> trace
417 #ifndef HB_DEBUG_SERIALIZE
418 #define HB_DEBUG_SERIALIZE (HB_DEBUG+0)
420 #if HB_DEBUG_SERIALIZE
421 #define TRACE_SERIALIZE(this) \
422 hb_auto_trace_t<HB_DEBUG_SERIALIZE, bool> trace \
423 (&c->debug_depth, "SERIALIZE", c, HB_FUNC, \
426 #define TRACE_SERIALIZE(this) hb_no_trace_t<bool> trace
429 #ifndef HB_DEBUG_SUBSET
430 #define HB_DEBUG_SUBSET (HB_DEBUG+0)
433 #define TRACE_SUBSET(this) \
434 hb_auto_trace_t<HB_DEBUG_SUBSET, bool> trace \
435 (&c->debug_depth, c->get_name (), this, HB_FUNC, \
438 #define TRACE_SUBSET(this) hb_no_trace_t<bool> trace
441 #ifndef HB_DEBUG_SUBSET_REPACK
442 #define HB_DEBUG_SUBSET_REPACK (HB_DEBUG+0)
445 #ifndef HB_DEBUG_DISPATCH
446 #define HB_DEBUG_DISPATCH ( \
448 HB_DEBUG_SANITIZE + \
449 HB_DEBUG_SERIALIZE + \
453 #if HB_DEBUG_DISPATCH
454 #define TRACE_DISPATCH(this, format) \
455 hb_auto_trace_t<context_t::max_debug_depth, typename context_t::return_t> trace \
456 (&c->debug_depth, c->get_name (), this, HB_FUNC, \
457 "format %d", (int) format)
459 #define TRACE_DISPATCH(this, format) hb_no_trace_t<typename context_t::return_t> trace
small capitals from c petite p scientific f u
HB_INTERNAL hb_atomic_int_t _hb_options
void HB_PRINTF_FUNC(7, 0) _hb_debug_msg_va< 0 >(const char *what HB_UNUSED
_hb_debug_msg_va< max_level >(what, obj, func, indented, level, level_dir, message, ap)
void _hb_warn_no_return< hb_empty_t >(bool returned HB_UNUSED)
void _hb_debug_msg< 0 >(const char *what HB_UNUSED, const void *obj HB_UNUSED, const char *func HB_UNUSED, bool indented HB_UNUSED, unsigned int level HB_UNUSED, int level_dir HB_UNUSED, const char *message HB_UNUSED,...) HB_PRINTF_FUNC(7
static void const void const char bool unsigned int int level_dir
static void const void const char bool indented
HB_INTERNAL void _hb_options_init()
void const void *obj HB_UNUSED
static void const void const char * func
static void const void const char bool unsigned int int const char va_start(ap, message)
auto it unsigned count const
int PRIV() strncmp(PCRE2_SPTR str1, PCRE2_SPTR str2, size_t len)
PCRE2_SIZE PRIV() strlen(PCRE2_SPTR str)
GLenum GLuint GLenum GLsizei const GLchar * message
GLsizei const GLfloat * v
[13]
GLenum GLuint GLint level
hb_auto_trace_t(unsigned int *plevel_, const char *what_, const void *obj_, const char *func, const char *message,...) HB_PRINTF_FUNC(6
hb_auto_trace_t(unsigned int *plevel_, const char *what_, const void *obj_, const char *func, const char *message,...) HB_PRINTF_FUNC(6
T ret(T &&v, const char *func="", unsigned int line=0)
T ret(T &&v, const char *func HB_UNUSED=nullptr, unsigned int line HB_UNUSED=0)
bool uniscribe_bug_compatible
const char * print(bool v)
const char * print(hb_empty_t)