Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2017 Google, Inc. |
| 3 | * |
| 4 | * This is part of HarfBuzz, a text shaping library. |
| 5 | * |
| 6 | * Permission is hereby granted, without written agreement and without |
| 7 | * license or royalty fees, to use, copy, modify, and distribute this |
| 8 | * software and its documentation for any purpose, provided that the |
| 9 | * above copyright notice and the following two paragraphs appear in |
| 10 | * all copies of this software. |
| 11 | * |
| 12 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 13 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 14 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| 15 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 16 | * DAMAGE. |
| 17 | * |
| 18 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 21 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 22 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 23 | * |
| 24 | * Google Author(s): Behdad Esfahbod |
| 25 | */ |
| 26 | |
| 27 | #ifndef HB_DEBUG_HH |
| 28 | #define HB_DEBUG_HH |
| 29 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 30 | #include "hb.hh" |
| 31 | #include "hb-atomic.hh" |
Behdad Esfahbod | 491d93b | 2018-07-10 16:03:31 +0200 | [diff] [blame] | 32 | #include "hb-dsalgs.hh" |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 33 | |
| 34 | |
| 35 | #ifndef HB_DEBUG |
| 36 | #define HB_DEBUG 0 |
| 37 | #endif |
| 38 | |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 39 | |
| 40 | /* |
| 41 | * Global runtime options. |
| 42 | */ |
| 43 | |
| 44 | struct hb_options_t |
| 45 | { |
Behdad Esfahbod | 38a7a8a | 2018-10-10 17:44:46 -0400 | [diff] [blame^] | 46 | bool unused : 1; /* In-case sign bit is here. */ |
| 47 | bool initialized : 1; |
| 48 | bool uniscribe_bug_compatible : 1; |
| 49 | bool aat : 1; |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | union hb_options_union_t { |
| 53 | int i; |
| 54 | hb_options_t opts; |
| 55 | }; |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 56 | static_assert ((sizeof (hb_atomic_int_t) >= sizeof (hb_options_union_t)), ""); |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 57 | |
| 58 | HB_INTERNAL void |
| 59 | _hb_options_init (void); |
| 60 | |
| 61 | extern HB_INTERNAL hb_atomic_int_t _hb_options; |
| 62 | |
| 63 | static inline hb_options_t |
| 64 | hb_options (void) |
| 65 | { |
| 66 | /* Make a local copy, so we can access bitfield threadsafely. */ |
| 67 | hb_options_union_t u; |
| 68 | u.i = _hb_options.get_relaxed (); |
| 69 | |
| 70 | if (unlikely (!u.i)) |
Behdad Esfahbod | 24f1d96 | 2018-09-10 18:19:37 +0200 | [diff] [blame] | 71 | { |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 72 | _hb_options_init (); |
Behdad Esfahbod | 24f1d96 | 2018-09-10 18:19:37 +0200 | [diff] [blame] | 73 | u.i = _hb_options.get_relaxed (); |
| 74 | } |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 75 | |
| 76 | return u.opts; |
| 77 | } |
| 78 | |
| 79 | |
| 80 | /* |
| 81 | * Debug output (needs enabling at compile time.) |
| 82 | */ |
| 83 | |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 84 | static inline bool |
| 85 | _hb_debug (unsigned int level, |
| 86 | unsigned int max_level) |
| 87 | { |
| 88 | return level < max_level; |
| 89 | } |
| 90 | |
| 91 | #define DEBUG_LEVEL_ENABLED(WHAT, LEVEL) (_hb_debug ((LEVEL), HB_DEBUG_##WHAT)) |
| 92 | #define DEBUG_ENABLED(WHAT) (DEBUG_LEVEL_ENABLED (WHAT, 0)) |
| 93 | |
| 94 | static inline void |
| 95 | _hb_print_func (const char *func) |
| 96 | { |
| 97 | if (func) |
| 98 | { |
| 99 | unsigned int func_len = strlen (func); |
| 100 | /* Skip "static" */ |
| 101 | if (0 == strncmp (func, "static ", 7)) |
| 102 | func += 7; |
| 103 | /* Skip "typename" */ |
| 104 | if (0 == strncmp (func, "typename ", 9)) |
| 105 | func += 9; |
| 106 | /* Skip return type */ |
| 107 | const char *space = strchr (func, ' '); |
| 108 | if (space) |
| 109 | func = space + 1; |
| 110 | /* Skip parameter list */ |
| 111 | const char *paren = strchr (func, '('); |
| 112 | if (paren) |
| 113 | func_len = paren - func; |
| 114 | fprintf (stderr, "%.*s", func_len, func); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | template <int max_level> static inline void |
| 119 | _hb_debug_msg_va (const char *what, |
| 120 | const void *obj, |
| 121 | const char *func, |
| 122 | bool indented, |
| 123 | unsigned int level, |
| 124 | int level_dir, |
| 125 | const char *message, |
| 126 | va_list ap) HB_PRINTF_FUNC(7, 0); |
| 127 | template <int max_level> static inline void |
| 128 | _hb_debug_msg_va (const char *what, |
| 129 | const void *obj, |
| 130 | const char *func, |
| 131 | bool indented, |
| 132 | unsigned int level, |
| 133 | int level_dir, |
| 134 | const char *message, |
| 135 | va_list ap) |
| 136 | { |
| 137 | if (!_hb_debug (level, max_level)) |
| 138 | return; |
| 139 | |
| 140 | fprintf (stderr, "%-10s", what ? what : ""); |
| 141 | |
| 142 | if (obj) |
Behdad Esfahbod | 03b7a22 | 2017-12-05 13:12:11 -0800 | [diff] [blame] | 143 | fprintf (stderr, "(%*p) ", (unsigned int) (2 * sizeof (void *)), obj); |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 144 | else |
| 145 | fprintf (stderr, " %*s ", (unsigned int) (2 * sizeof (void *)), ""); |
| 146 | |
| 147 | if (indented) { |
| 148 | #define VBAR "\342\224\202" /* U+2502 BOX DRAWINGS LIGHT VERTICAL */ |
| 149 | #define VRBAR "\342\224\234" /* U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT */ |
| 150 | #define DLBAR "\342\225\256" /* U+256E BOX DRAWINGS LIGHT ARC DOWN AND LEFT */ |
| 151 | #define ULBAR "\342\225\257" /* U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT */ |
| 152 | #define LBAR "\342\225\264" /* U+2574 BOX DRAWINGS LIGHT LEFT */ |
| 153 | static const char bars[] = |
| 154 | VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR |
| 155 | VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR |
| 156 | VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR |
| 157 | VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR |
| 158 | VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR; |
| 159 | fprintf (stderr, "%2u %s" VRBAR "%s", |
| 160 | level, |
| 161 | bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars) - 1, (unsigned int) (sizeof (VBAR) - 1) * level), |
| 162 | level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR); |
| 163 | } else |
| 164 | fprintf (stderr, " " VRBAR LBAR); |
| 165 | |
| 166 | _hb_print_func (func); |
| 167 | |
| 168 | if (message) |
| 169 | { |
| 170 | fprintf (stderr, ": "); |
| 171 | vfprintf (stderr, message, ap); |
| 172 | } |
| 173 | |
| 174 | fprintf (stderr, "\n"); |
| 175 | } |
| 176 | template <> inline void |
| 177 | _hb_debug_msg_va<0> (const char *what HB_UNUSED, |
| 178 | const void *obj HB_UNUSED, |
| 179 | const char *func HB_UNUSED, |
| 180 | bool indented HB_UNUSED, |
| 181 | unsigned int level HB_UNUSED, |
| 182 | int level_dir HB_UNUSED, |
| 183 | const char *message HB_UNUSED, |
| 184 | va_list ap HB_UNUSED) {} |
| 185 | |
| 186 | template <int max_level> static inline void |
| 187 | _hb_debug_msg (const char *what, |
| 188 | const void *obj, |
| 189 | const char *func, |
| 190 | bool indented, |
| 191 | unsigned int level, |
| 192 | int level_dir, |
| 193 | const char *message, |
| 194 | ...) HB_PRINTF_FUNC(7, 8); |
| 195 | template <int max_level> static inline void |
| 196 | _hb_debug_msg (const char *what, |
| 197 | const void *obj, |
| 198 | const char *func, |
| 199 | bool indented, |
| 200 | unsigned int level, |
| 201 | int level_dir, |
| 202 | const char *message, |
| 203 | ...) |
| 204 | { |
| 205 | va_list ap; |
| 206 | va_start (ap, message); |
| 207 | _hb_debug_msg_va<max_level> (what, obj, func, indented, level, level_dir, message, ap); |
| 208 | va_end (ap); |
| 209 | } |
| 210 | template <> inline void |
| 211 | _hb_debug_msg<0> (const char *what HB_UNUSED, |
| 212 | const void *obj HB_UNUSED, |
| 213 | const char *func HB_UNUSED, |
| 214 | bool indented HB_UNUSED, |
| 215 | unsigned int level HB_UNUSED, |
| 216 | int level_dir HB_UNUSED, |
| 217 | const char *message HB_UNUSED, |
| 218 | ...) HB_PRINTF_FUNC(7, 8); |
| 219 | template <> inline void |
| 220 | _hb_debug_msg<0> (const char *what HB_UNUSED, |
| 221 | const void *obj HB_UNUSED, |
| 222 | const char *func HB_UNUSED, |
| 223 | bool indented HB_UNUSED, |
| 224 | unsigned int level HB_UNUSED, |
| 225 | int level_dir HB_UNUSED, |
| 226 | const char *message HB_UNUSED, |
| 227 | ...) {} |
| 228 | |
| 229 | #define DEBUG_MSG_LEVEL(WHAT, OBJ, LEVEL, LEVEL_DIR, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), nullptr, true, (LEVEL), (LEVEL_DIR), __VA_ARGS__) |
| 230 | #define DEBUG_MSG(WHAT, OBJ, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), nullptr, false, 0, 0, __VA_ARGS__) |
| 231 | #define DEBUG_MSG_FUNC(WHAT, OBJ, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), HB_FUNC, false, 0, 0, __VA_ARGS__) |
| 232 | |
| 233 | |
| 234 | /* |
| 235 | * Printer |
| 236 | */ |
| 237 | |
| 238 | template <typename T> |
| 239 | struct hb_printer_t { |
| 240 | const char *print (const T&) { return "something"; } |
| 241 | }; |
| 242 | |
| 243 | template <> |
| 244 | struct hb_printer_t<bool> { |
| 245 | const char *print (bool v) { return v ? "true" : "false"; } |
| 246 | }; |
| 247 | |
| 248 | template <> |
| 249 | struct hb_printer_t<hb_void_t> { |
| 250 | const char *print (hb_void_t) { return ""; } |
| 251 | }; |
| 252 | |
| 253 | |
| 254 | /* |
| 255 | * Trace |
| 256 | */ |
| 257 | |
| 258 | template <typename T> |
| 259 | static inline void _hb_warn_no_return (bool returned) |
| 260 | { |
| 261 | if (unlikely (!returned)) { |
| 262 | fprintf (stderr, "OUCH, returned with no call to return_trace(). This is a bug, please report.\n"); |
| 263 | } |
| 264 | } |
| 265 | template <> |
| 266 | /*static*/ inline void _hb_warn_no_return<hb_void_t> (bool returned HB_UNUSED) |
| 267 | {} |
| 268 | |
| 269 | template <int max_level, typename ret_t> |
Behdad Esfahbod | ae2e2b0 | 2017-12-14 18:15:14 -0800 | [diff] [blame] | 270 | struct hb_auto_trace_t |
| 271 | { |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 272 | explicit inline hb_auto_trace_t (unsigned int *plevel_, |
| 273 | const char *what_, |
| 274 | const void *obj_, |
| 275 | const char *func, |
| 276 | const char *message, |
Behdad Esfahbod | fcd6c33 | 2017-11-14 14:40:21 -0800 | [diff] [blame] | 277 | ...) HB_PRINTF_FUNC(6, 7) |
| 278 | : plevel (plevel_), what (what_), obj (obj_), returned (false) |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 279 | { |
| 280 | if (plevel) ++*plevel; |
| 281 | |
| 282 | va_list ap; |
| 283 | va_start (ap, message); |
| 284 | _hb_debug_msg_va<max_level> (what, obj, func, true, plevel ? *plevel : 0, +1, message, ap); |
| 285 | va_end (ap); |
| 286 | } |
| 287 | inline ~hb_auto_trace_t (void) |
| 288 | { |
| 289 | _hb_warn_no_return<ret_t> (returned); |
| 290 | if (!returned) { |
| 291 | _hb_debug_msg<max_level> (what, obj, nullptr, true, plevel ? *plevel : 1, -1, " "); |
| 292 | } |
| 293 | if (plevel) --*plevel; |
| 294 | } |
| 295 | |
| 296 | inline ret_t ret (ret_t v, unsigned int line = 0) |
| 297 | { |
| 298 | if (unlikely (returned)) { |
| 299 | fprintf (stderr, "OUCH, double calls to return_trace(). This is a bug, please report.\n"); |
| 300 | return v; |
| 301 | } |
| 302 | |
| 303 | _hb_debug_msg<max_level> (what, obj, nullptr, true, plevel ? *plevel : 1, -1, |
| 304 | "return %s (line %d)", |
| 305 | hb_printer_t<ret_t>().print (v), line); |
| 306 | if (plevel) --*plevel; |
| 307 | plevel = nullptr; |
| 308 | returned = true; |
| 309 | return v; |
| 310 | } |
| 311 | |
| 312 | private: |
| 313 | unsigned int *plevel; |
| 314 | const char *what; |
| 315 | const void *obj; |
| 316 | bool returned; |
| 317 | }; |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 318 | template <typename ret_t> /* Make sure we don't use hb_auto_trace_t when not tracing. */ |
Behdad Esfahbod | ae2e2b0 | 2017-12-14 18:15:14 -0800 | [diff] [blame] | 319 | struct hb_auto_trace_t<0, ret_t> |
| 320 | { |
| 321 | explicit inline hb_auto_trace_t (unsigned int *plevel_, |
| 322 | const char *what_, |
| 323 | const void *obj_, |
| 324 | const char *func, |
| 325 | const char *message, |
| 326 | ...) HB_PRINTF_FUNC(6, 7) {} |
| 327 | |
| 328 | inline ret_t ret (ret_t v, unsigned int line HB_UNUSED = 0) { return v; } |
| 329 | }; |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 330 | |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 331 | /* For disabled tracing; optimize out everything. |
ebraminio | 7c6937e | 2017-11-20 14:49:22 -0500 | [diff] [blame] | 332 | * https://github.com/harfbuzz/harfbuzz/pull/605 */ |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 333 | template <typename ret_t> |
| 334 | struct hb_no_trace_t { |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 335 | inline ret_t ret (ret_t v, unsigned int line HB_UNUSED = 0) { return v; } |
| 336 | }; |
| 337 | |
| 338 | #define return_trace(RET) return trace.ret (RET, __LINE__) |
| 339 | |
| 340 | |
| 341 | /* |
| 342 | * Instances. |
| 343 | */ |
| 344 | |
| 345 | #ifndef HB_DEBUG_ARABIC |
| 346 | #define HB_DEBUG_ARABIC (HB_DEBUG+0) |
| 347 | #endif |
| 348 | |
| 349 | #ifndef HB_DEBUG_BLOB |
| 350 | #define HB_DEBUG_BLOB (HB_DEBUG+0) |
| 351 | #endif |
| 352 | |
| 353 | #ifndef HB_DEBUG_CORETEXT |
| 354 | #define HB_DEBUG_CORETEXT (HB_DEBUG+0) |
| 355 | #endif |
| 356 | |
| 357 | #ifndef HB_DEBUG_DIRECTWRITE |
| 358 | #define HB_DEBUG_DIRECTWRITE (HB_DEBUG+0) |
| 359 | #endif |
| 360 | |
| 361 | #ifndef HB_DEBUG_FT |
| 362 | #define HB_DEBUG_FT (HB_DEBUG+0) |
| 363 | #endif |
| 364 | |
| 365 | #ifndef HB_DEBUG_GET_COVERAGE |
| 366 | #define HB_DEBUG_GET_COVERAGE (HB_DEBUG+0) |
| 367 | #endif |
| 368 | |
| 369 | #ifndef HB_DEBUG_OBJECT |
| 370 | #define HB_DEBUG_OBJECT (HB_DEBUG+0) |
| 371 | #endif |
| 372 | |
| 373 | #ifndef HB_DEBUG_SHAPE_PLAN |
| 374 | #define HB_DEBUG_SHAPE_PLAN (HB_DEBUG+0) |
| 375 | #endif |
| 376 | |
| 377 | #ifndef HB_DEBUG_UNISCRIBE |
| 378 | #define HB_DEBUG_UNISCRIBE (HB_DEBUG+0) |
| 379 | #endif |
| 380 | |
| 381 | /* |
| 382 | * With tracing. |
| 383 | */ |
| 384 | |
| 385 | #ifndef HB_DEBUG_APPLY |
| 386 | #define HB_DEBUG_APPLY (HB_DEBUG+0) |
| 387 | #endif |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 388 | #if HB_DEBUG_APPLY |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 389 | #define TRACE_APPLY(this) \ |
| 390 | hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace \ |
| 391 | (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
| 392 | "idx %d gid %u lookup %d", \ |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 393 | c->buffer->idx, c->buffer->cur().codepoint, (int) c->lookup_index) |
| 394 | #else |
| 395 | #define TRACE_APPLY(this) hb_no_trace_t<bool> trace |
| 396 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 397 | |
| 398 | #ifndef HB_DEBUG_CLOSURE |
| 399 | #define HB_DEBUG_CLOSURE (HB_DEBUG+0) |
| 400 | #endif |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 401 | #if HB_DEBUG_CLOSURE |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 402 | #define TRACE_CLOSURE(this) \ |
| 403 | hb_auto_trace_t<HB_DEBUG_CLOSURE, hb_void_t> trace \ |
| 404 | (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
Behdad Esfahbod | fcd6c33 | 2017-11-14 14:40:21 -0800 | [diff] [blame] | 405 | " ") |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 406 | #else |
Ebrahim Byagowi | 48f0204 | 2018-04-24 08:11:13 +0430 | [diff] [blame] | 407 | #define TRACE_CLOSURE(this) hb_no_trace_t<hb_void_t> trace HB_UNUSED |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 408 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 409 | |
| 410 | #ifndef HB_DEBUG_COLLECT_GLYPHS |
| 411 | #define HB_DEBUG_COLLECT_GLYPHS (HB_DEBUG+0) |
| 412 | #endif |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 413 | #if HB_DEBUG_COLLECT_GLYPHS |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 414 | #define TRACE_COLLECT_GLYPHS(this) \ |
| 415 | hb_auto_trace_t<HB_DEBUG_COLLECT_GLYPHS, hb_void_t> trace \ |
| 416 | (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
Behdad Esfahbod | fcd6c33 | 2017-11-14 14:40:21 -0800 | [diff] [blame] | 417 | " ") |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 418 | #else |
Ebrahim Byagowi | 48f0204 | 2018-04-24 08:11:13 +0430 | [diff] [blame] | 419 | #define TRACE_COLLECT_GLYPHS(this) hb_no_trace_t<hb_void_t> trace HB_UNUSED |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 420 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 421 | |
| 422 | #ifndef HB_DEBUG_SANITIZE |
| 423 | #define HB_DEBUG_SANITIZE (HB_DEBUG+0) |
| 424 | #endif |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 425 | #if HB_DEBUG_SANITIZE |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 426 | #define TRACE_SANITIZE(this) \ |
| 427 | hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace \ |
| 428 | (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
Behdad Esfahbod | fcd6c33 | 2017-11-14 14:40:21 -0800 | [diff] [blame] | 429 | " "); |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 430 | #else |
| 431 | #define TRACE_SANITIZE(this) hb_no_trace_t<bool> trace |
| 432 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 433 | |
| 434 | #ifndef HB_DEBUG_SERIALIZE |
| 435 | #define HB_DEBUG_SERIALIZE (HB_DEBUG+0) |
| 436 | #endif |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 437 | #if HB_DEBUG_SERIALIZE |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 438 | #define TRACE_SERIALIZE(this) \ |
| 439 | hb_auto_trace_t<HB_DEBUG_SERIALIZE, bool> trace \ |
| 440 | (&c->debug_depth, "SERIALIZE", c, HB_FUNC, \ |
Behdad Esfahbod | fcd6c33 | 2017-11-14 14:40:21 -0800 | [diff] [blame] | 441 | " "); |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 442 | #else |
| 443 | #define TRACE_SERIALIZE(this) hb_no_trace_t<bool> trace |
| 444 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 445 | |
Rod Sheeter | 8b80cbb | 2018-02-07 09:31:31 -0800 | [diff] [blame] | 446 | #ifndef HB_DEBUG_SUBSET |
| 447 | #define HB_DEBUG_SUBSET (HB_DEBUG+0) |
| 448 | #endif |
| 449 | #if HB_DEBUG_SUBSET |
| 450 | #define TRACE_SUBSET(this) \ |
| 451 | hb_auto_trace_t<HB_DEBUG_SUBSET, bool> trace \ |
| 452 | (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
| 453 | " "); |
| 454 | #else |
| 455 | #define TRACE_SUBSET(this) hb_no_trace_t<bool> trace |
| 456 | #endif |
| 457 | |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 458 | #ifndef HB_DEBUG_WOULD_APPLY |
| 459 | #define HB_DEBUG_WOULD_APPLY (HB_DEBUG+0) |
| 460 | #endif |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 461 | #if HB_DEBUG_WOULD_APPLY |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 462 | #define TRACE_WOULD_APPLY(this) \ |
| 463 | hb_auto_trace_t<HB_DEBUG_WOULD_APPLY, bool> trace \ |
| 464 | (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
| 465 | "%d glyphs", c->len); |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 466 | #else |
| 467 | #define TRACE_WOULD_APPLY(this) hb_no_trace_t<bool> trace |
| 468 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 469 | |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 470 | #ifndef HB_DEBUG_DISPATCH |
| 471 | #define HB_DEBUG_DISPATCH ( \ |
| 472 | HB_DEBUG_APPLY + \ |
| 473 | HB_DEBUG_CLOSURE + \ |
| 474 | HB_DEBUG_COLLECT_GLYPHS + \ |
| 475 | HB_DEBUG_SANITIZE + \ |
| 476 | HB_DEBUG_SERIALIZE + \ |
Rod Sheeter | 8b80cbb | 2018-02-07 09:31:31 -0800 | [diff] [blame] | 477 | HB_DEBUG_SUBSET + \ |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 478 | HB_DEBUG_WOULD_APPLY + \ |
| 479 | 0) |
| 480 | #endif |
| 481 | #if HB_DEBUG_DISPATCH |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 482 | #define TRACE_DISPATCH(this, format) \ |
| 483 | hb_auto_trace_t<context_t::max_debug_depth, typename context_t::return_t> trace \ |
| 484 | (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
| 485 | "format %d", (int) format); |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 486 | #else |
| 487 | #define TRACE_DISPATCH(this, format) hb_no_trace_t<typename context_t::return_t> trace |
| 488 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 489 | |
| 490 | |
| 491 | #endif /* HB_DEBUG_HH */ |