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 | 6e3ad65 | 2019-01-09 09:05:01 -0800 | [diff] [blame] | 32 | #include "hb-algs.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; |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | union hb_options_union_t { |
| 52 | int i; |
| 53 | hb_options_t opts; |
| 54 | }; |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 55 | static_assert ((sizeof (hb_atomic_int_t) >= sizeof (hb_options_union_t)), ""); |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 56 | |
| 57 | HB_INTERNAL void |
Ebrahim Byagowi | e412008 | 2018-12-17 21:31:01 +0330 | [diff] [blame] | 58 | _hb_options_init (); |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 59 | |
| 60 | extern HB_INTERNAL hb_atomic_int_t _hb_options; |
| 61 | |
| 62 | static inline hb_options_t |
Ebrahim Byagowi | e412008 | 2018-12-17 21:31:01 +0330 | [diff] [blame] | 63 | hb_options () |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 64 | { |
Behdad Esfahbod | 227d85e | 2019-05-10 23:15:58 -0700 | [diff] [blame] | 65 | #ifdef HB_NO_GETENV |
Behdad Esfahbod | 2f4be4b | 2019-04-12 16:21:58 -0400 | [diff] [blame] | 66 | return hb_options_t (); |
| 67 | #endif |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 68 | /* Make a local copy, so we can access bitfield threadsafely. */ |
| 69 | hb_options_union_t u; |
| 70 | u.i = _hb_options.get_relaxed (); |
| 71 | |
| 72 | if (unlikely (!u.i)) |
Behdad Esfahbod | 24f1d96 | 2018-09-10 18:19:37 +0200 | [diff] [blame] | 73 | { |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 74 | _hb_options_init (); |
Behdad Esfahbod | 24f1d96 | 2018-09-10 18:19:37 +0200 | [diff] [blame] | 75 | u.i = _hb_options.get_relaxed (); |
| 76 | } |
Behdad Esfahbod | 4bc16ac | 2018-07-31 21:05:51 -0700 | [diff] [blame] | 77 | |
| 78 | return u.opts; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | /* |
| 83 | * Debug output (needs enabling at compile time.) |
| 84 | */ |
| 85 | |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 86 | static inline bool |
| 87 | _hb_debug (unsigned int level, |
| 88 | unsigned int max_level) |
| 89 | { |
| 90 | return level < max_level; |
| 91 | } |
| 92 | |
| 93 | #define DEBUG_LEVEL_ENABLED(WHAT, LEVEL) (_hb_debug ((LEVEL), HB_DEBUG_##WHAT)) |
| 94 | #define DEBUG_ENABLED(WHAT) (DEBUG_LEVEL_ENABLED (WHAT, 0)) |
| 95 | |
| 96 | static inline void |
| 97 | _hb_print_func (const char *func) |
| 98 | { |
| 99 | if (func) |
| 100 | { |
| 101 | unsigned int func_len = strlen (func); |
| 102 | /* Skip "static" */ |
| 103 | if (0 == strncmp (func, "static ", 7)) |
| 104 | func += 7; |
| 105 | /* Skip "typename" */ |
| 106 | if (0 == strncmp (func, "typename ", 9)) |
| 107 | func += 9; |
| 108 | /* Skip return type */ |
| 109 | const char *space = strchr (func, ' '); |
| 110 | if (space) |
| 111 | func = space + 1; |
| 112 | /* Skip parameter list */ |
| 113 | const char *paren = strchr (func, '('); |
| 114 | if (paren) |
| 115 | func_len = paren - func; |
| 116 | fprintf (stderr, "%.*s", func_len, func); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | template <int max_level> static inline void |
| 121 | _hb_debug_msg_va (const char *what, |
| 122 | const void *obj, |
| 123 | const char *func, |
| 124 | bool indented, |
| 125 | unsigned int level, |
| 126 | int level_dir, |
| 127 | const char *message, |
| 128 | va_list ap) HB_PRINTF_FUNC(7, 0); |
| 129 | template <int max_level> static inline void |
| 130 | _hb_debug_msg_va (const char *what, |
| 131 | const void *obj, |
| 132 | const char *func, |
| 133 | bool indented, |
| 134 | unsigned int level, |
| 135 | int level_dir, |
| 136 | const char *message, |
| 137 | va_list ap) |
| 138 | { |
| 139 | if (!_hb_debug (level, max_level)) |
| 140 | return; |
| 141 | |
| 142 | fprintf (stderr, "%-10s", what ? what : ""); |
| 143 | |
| 144 | if (obj) |
Behdad Esfahbod | 03b7a22 | 2017-12-05 13:12:11 -0800 | [diff] [blame] | 145 | fprintf (stderr, "(%*p) ", (unsigned int) (2 * sizeof (void *)), obj); |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 146 | else |
| 147 | fprintf (stderr, " %*s ", (unsigned int) (2 * sizeof (void *)), ""); |
| 148 | |
| 149 | if (indented) { |
| 150 | #define VBAR "\342\224\202" /* U+2502 BOX DRAWINGS LIGHT VERTICAL */ |
| 151 | #define VRBAR "\342\224\234" /* U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT */ |
| 152 | #define DLBAR "\342\225\256" /* U+256E BOX DRAWINGS LIGHT ARC DOWN AND LEFT */ |
| 153 | #define ULBAR "\342\225\257" /* U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT */ |
| 154 | #define LBAR "\342\225\264" /* U+2574 BOX DRAWINGS LIGHT LEFT */ |
| 155 | static const char bars[] = |
| 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 | VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR |
| 160 | VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR; |
| 161 | fprintf (stderr, "%2u %s" VRBAR "%s", |
| 162 | level, |
Behdad Esfahbod | 41248cc | 2019-05-07 20:54:31 -0700 | [diff] [blame] | 163 | bars + sizeof (bars) - 1 - hb_min ((unsigned int) sizeof (bars) - 1, (unsigned int) (sizeof (VBAR) - 1) * level), |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 164 | level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR); |
| 165 | } else |
| 166 | fprintf (stderr, " " VRBAR LBAR); |
| 167 | |
| 168 | _hb_print_func (func); |
| 169 | |
| 170 | if (message) |
| 171 | { |
| 172 | fprintf (stderr, ": "); |
| 173 | vfprintf (stderr, message, ap); |
| 174 | } |
| 175 | |
| 176 | fprintf (stderr, "\n"); |
| 177 | } |
Simon Tooke | 881e105 | 2018-10-30 14:16:23 -0400 | [diff] [blame] | 178 | template <> inline void HB_PRINTF_FUNC(7, 0) |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 179 | _hb_debug_msg_va<0> (const char *what HB_UNUSED, |
| 180 | const void *obj HB_UNUSED, |
| 181 | const char *func HB_UNUSED, |
| 182 | bool indented HB_UNUSED, |
| 183 | unsigned int level HB_UNUSED, |
| 184 | int level_dir HB_UNUSED, |
| 185 | const char *message HB_UNUSED, |
| 186 | va_list ap HB_UNUSED) {} |
| 187 | |
| 188 | template <int max_level> static inline void |
| 189 | _hb_debug_msg (const char *what, |
| 190 | const void *obj, |
| 191 | const char *func, |
| 192 | bool indented, |
| 193 | unsigned int level, |
| 194 | int level_dir, |
| 195 | const char *message, |
| 196 | ...) HB_PRINTF_FUNC(7, 8); |
Simon Tooke | 881e105 | 2018-10-30 14:16:23 -0400 | [diff] [blame] | 197 | template <int max_level> static inline void HB_PRINTF_FUNC(7, 8) |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 198 | _hb_debug_msg (const char *what, |
| 199 | const void *obj, |
| 200 | const char *func, |
| 201 | bool indented, |
| 202 | unsigned int level, |
| 203 | int level_dir, |
| 204 | const char *message, |
| 205 | ...) |
| 206 | { |
| 207 | va_list ap; |
| 208 | va_start (ap, message); |
| 209 | _hb_debug_msg_va<max_level> (what, obj, func, indented, level, level_dir, message, ap); |
| 210 | va_end (ap); |
| 211 | } |
| 212 | template <> inline void |
| 213 | _hb_debug_msg<0> (const char *what HB_UNUSED, |
| 214 | const void *obj HB_UNUSED, |
| 215 | const char *func HB_UNUSED, |
| 216 | bool indented HB_UNUSED, |
| 217 | unsigned int level HB_UNUSED, |
| 218 | int level_dir HB_UNUSED, |
| 219 | const char *message HB_UNUSED, |
| 220 | ...) HB_PRINTF_FUNC(7, 8); |
Simon Tooke | 881e105 | 2018-10-30 14:16:23 -0400 | [diff] [blame] | 221 | template <> inline void HB_PRINTF_FUNC(7, 8) |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 222 | _hb_debug_msg<0> (const char *what HB_UNUSED, |
| 223 | const void *obj HB_UNUSED, |
| 224 | const char *func HB_UNUSED, |
| 225 | bool indented HB_UNUSED, |
| 226 | unsigned int level HB_UNUSED, |
| 227 | int level_dir HB_UNUSED, |
| 228 | const char *message HB_UNUSED, |
| 229 | ...) {} |
| 230 | |
| 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__) |
Ebrahim Byagowi | ce114d6 | 2019-12-31 15:53:02 +0330 | [diff] [blame] | 232 | #define DEBUG_MSG(WHAT, OBJ, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), nullptr, false, 0, 0, __VA_ARGS__) |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 233 | #define DEBUG_MSG_FUNC(WHAT, OBJ, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), HB_FUNC, false, 0, 0, __VA_ARGS__) |
| 234 | |
| 235 | |
| 236 | /* |
| 237 | * Printer |
| 238 | */ |
| 239 | |
| 240 | template <typename T> |
| 241 | struct hb_printer_t { |
| 242 | const char *print (const T&) { return "something"; } |
| 243 | }; |
| 244 | |
| 245 | template <> |
| 246 | struct hb_printer_t<bool> { |
| 247 | const char *print (bool v) { return v ? "true" : "false"; } |
| 248 | }; |
| 249 | |
| 250 | template <> |
Behdad Esfahbod | 7df3ecf | 2019-05-10 20:43:26 -0700 | [diff] [blame] | 251 | struct hb_printer_t<hb_empty_t> { |
| 252 | const char *print (hb_empty_t) { return ""; } |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 253 | }; |
| 254 | |
| 255 | |
| 256 | /* |
| 257 | * Trace |
| 258 | */ |
| 259 | |
| 260 | template <typename T> |
| 261 | static inline void _hb_warn_no_return (bool returned) |
| 262 | { |
| 263 | if (unlikely (!returned)) { |
| 264 | fprintf (stderr, "OUCH, returned with no call to return_trace(). This is a bug, please report.\n"); |
| 265 | } |
| 266 | } |
| 267 | template <> |
Behdad Esfahbod | 7df3ecf | 2019-05-10 20:43:26 -0700 | [diff] [blame] | 268 | /*static*/ inline void _hb_warn_no_return<hb_empty_t> (bool returned HB_UNUSED) |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 269 | {} |
| 270 | |
| 271 | template <int max_level, typename ret_t> |
Behdad Esfahbod | ae2e2b0 | 2017-12-14 18:15:14 -0800 | [diff] [blame] | 272 | struct hb_auto_trace_t |
| 273 | { |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 274 | explicit inline hb_auto_trace_t (unsigned int *plevel_, |
| 275 | const char *what_, |
| 276 | const void *obj_, |
| 277 | const char *func, |
| 278 | const char *message, |
Behdad Esfahbod | fcd6c33 | 2017-11-14 14:40:21 -0800 | [diff] [blame] | 279 | ...) HB_PRINTF_FUNC(6, 7) |
| 280 | : plevel (plevel_), what (what_), obj (obj_), returned (false) |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 281 | { |
| 282 | if (plevel) ++*plevel; |
| 283 | |
| 284 | va_list ap; |
| 285 | va_start (ap, message); |
| 286 | _hb_debug_msg_va<max_level> (what, obj, func, true, plevel ? *plevel : 0, +1, message, ap); |
| 287 | va_end (ap); |
| 288 | } |
Ebrahim Byagowi | e412008 | 2018-12-17 21:31:01 +0330 | [diff] [blame] | 289 | ~hb_auto_trace_t () |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 290 | { |
| 291 | _hb_warn_no_return<ret_t> (returned); |
| 292 | if (!returned) { |
| 293 | _hb_debug_msg<max_level> (what, obj, nullptr, true, plevel ? *plevel : 1, -1, " "); |
| 294 | } |
| 295 | if (plevel) --*plevel; |
| 296 | } |
| 297 | |
Behdad Esfahbod | 569426d | 2019-08-23 11:54:20 -0700 | [diff] [blame] | 298 | template <typename T> |
| 299 | T ret (T&& v, |
Behdad Esfahbod | 4dcaca8 | 2019-08-23 12:24:15 -0700 | [diff] [blame] | 300 | const char *func = "", |
| 301 | unsigned int line = 0) |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 302 | { |
| 303 | if (unlikely (returned)) { |
| 304 | fprintf (stderr, "OUCH, double calls to return_trace(). This is a bug, please report.\n"); |
Behdad Esfahbod | 6d555ce | 2021-11-02 00:18:22 -0600 | [diff] [blame] | 305 | return std::forward<T> (v); |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 306 | } |
| 307 | |
Behdad Esfahbod | 1c2302b | 2018-11-24 22:32:17 -0500 | [diff] [blame] | 308 | _hb_debug_msg<max_level> (what, obj, func, true, plevel ? *plevel : 1, -1, |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 309 | "return %s (line %d)", |
Behdad Esfahbod | f54f5c1 | 2021-07-22 11:09:02 -0700 | [diff] [blame] | 310 | hb_printer_t<hb_decay<decltype (v)>>().print (v), line); |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 311 | if (plevel) --*plevel; |
| 312 | plevel = nullptr; |
| 313 | returned = true; |
Behdad Esfahbod | 6d555ce | 2021-11-02 00:18:22 -0600 | [diff] [blame] | 314 | return std::forward<T> (v); |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | private: |
| 318 | unsigned int *plevel; |
| 319 | const char *what; |
| 320 | const void *obj; |
| 321 | bool returned; |
| 322 | }; |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 323 | 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] | 324 | struct hb_auto_trace_t<0, ret_t> |
| 325 | { |
| 326 | explicit inline hb_auto_trace_t (unsigned int *plevel_, |
| 327 | const char *what_, |
| 328 | const void *obj_, |
| 329 | const char *func, |
| 330 | const char *message, |
| 331 | ...) HB_PRINTF_FUNC(6, 7) {} |
| 332 | |
Behdad Esfahbod | 7d497a3 | 2019-05-02 16:20:03 -0700 | [diff] [blame] | 333 | template <typename T> |
| 334 | T ret (T&& v, |
| 335 | const char *func HB_UNUSED = nullptr, |
Behdad Esfahbod | 6d555ce | 2021-11-02 00:18:22 -0600 | [diff] [blame] | 336 | unsigned int line HB_UNUSED = 0) { return std::forward<T> (v); } |
Behdad Esfahbod | ae2e2b0 | 2017-12-14 18:15:14 -0800 | [diff] [blame] | 337 | }; |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 338 | |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 339 | /* For disabled tracing; optimize out everything. |
ebraminio | 7c6937e | 2017-11-20 14:49:22 -0500 | [diff] [blame] | 340 | * https://github.com/harfbuzz/harfbuzz/pull/605 */ |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 341 | template <typename ret_t> |
| 342 | struct hb_no_trace_t { |
Behdad Esfahbod | 7d497a3 | 2019-05-02 16:20:03 -0700 | [diff] [blame] | 343 | template <typename T> |
| 344 | T ret (T&& v, |
| 345 | const char *func HB_UNUSED = nullptr, |
Behdad Esfahbod | 6d555ce | 2021-11-02 00:18:22 -0600 | [diff] [blame] | 346 | unsigned int line HB_UNUSED = 0) { return std::forward<T> (v); } |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 347 | }; |
| 348 | |
Behdad Esfahbod | 1c2302b | 2018-11-24 22:32:17 -0500 | [diff] [blame] | 349 | #define return_trace(RET) return trace.ret (RET, HB_FUNC, __LINE__) |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 350 | |
| 351 | |
| 352 | /* |
| 353 | * Instances. |
| 354 | */ |
| 355 | |
| 356 | #ifndef HB_DEBUG_ARABIC |
| 357 | #define HB_DEBUG_ARABIC (HB_DEBUG+0) |
| 358 | #endif |
| 359 | |
| 360 | #ifndef HB_DEBUG_BLOB |
| 361 | #define HB_DEBUG_BLOB (HB_DEBUG+0) |
| 362 | #endif |
| 363 | |
| 364 | #ifndef HB_DEBUG_CORETEXT |
| 365 | #define HB_DEBUG_CORETEXT (HB_DEBUG+0) |
| 366 | #endif |
| 367 | |
| 368 | #ifndef HB_DEBUG_DIRECTWRITE |
| 369 | #define HB_DEBUG_DIRECTWRITE (HB_DEBUG+0) |
| 370 | #endif |
| 371 | |
| 372 | #ifndef HB_DEBUG_FT |
| 373 | #define HB_DEBUG_FT (HB_DEBUG+0) |
| 374 | #endif |
| 375 | |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 376 | #ifndef HB_DEBUG_OBJECT |
| 377 | #define HB_DEBUG_OBJECT (HB_DEBUG+0) |
| 378 | #endif |
| 379 | |
| 380 | #ifndef HB_DEBUG_SHAPE_PLAN |
| 381 | #define HB_DEBUG_SHAPE_PLAN (HB_DEBUG+0) |
| 382 | #endif |
| 383 | |
| 384 | #ifndef HB_DEBUG_UNISCRIBE |
| 385 | #define HB_DEBUG_UNISCRIBE (HB_DEBUG+0) |
| 386 | #endif |
| 387 | |
| 388 | /* |
| 389 | * With tracing. |
| 390 | */ |
| 391 | |
| 392 | #ifndef HB_DEBUG_APPLY |
| 393 | #define HB_DEBUG_APPLY (HB_DEBUG+0) |
| 394 | #endif |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 395 | #if HB_DEBUG_APPLY |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 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", \ |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 400 | c->buffer->idx, c->buffer->cur().codepoint, (int) c->lookup_index) |
| 401 | #else |
| 402 | #define TRACE_APPLY(this) hb_no_trace_t<bool> trace |
| 403 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 404 | |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 405 | #ifndef HB_DEBUG_SANITIZE |
| 406 | #define HB_DEBUG_SANITIZE (HB_DEBUG+0) |
| 407 | #endif |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 408 | #if HB_DEBUG_SANITIZE |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 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, \ |
Behdad Esfahbod | 541f3c2 | 2019-08-23 12:25:58 -0700 | [diff] [blame] | 412 | " ") |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 413 | #else |
| 414 | #define TRACE_SANITIZE(this) hb_no_trace_t<bool> trace |
| 415 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 416 | |
| 417 | #ifndef HB_DEBUG_SERIALIZE |
| 418 | #define HB_DEBUG_SERIALIZE (HB_DEBUG+0) |
| 419 | #endif |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 420 | #if HB_DEBUG_SERIALIZE |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 421 | #define TRACE_SERIALIZE(this) \ |
| 422 | hb_auto_trace_t<HB_DEBUG_SERIALIZE, bool> trace \ |
| 423 | (&c->debug_depth, "SERIALIZE", c, HB_FUNC, \ |
Behdad Esfahbod | 541f3c2 | 2019-08-23 12:25:58 -0700 | [diff] [blame] | 424 | " ") |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 425 | #else |
| 426 | #define TRACE_SERIALIZE(this) hb_no_trace_t<bool> trace |
| 427 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 428 | |
Rod Sheeter | 8b80cbb | 2018-02-07 09:31:31 -0800 | [diff] [blame] | 429 | #ifndef HB_DEBUG_SUBSET |
| 430 | #define HB_DEBUG_SUBSET (HB_DEBUG+0) |
| 431 | #endif |
| 432 | #if HB_DEBUG_SUBSET |
| 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, \ |
Behdad Esfahbod | 541f3c2 | 2019-08-23 12:25:58 -0700 | [diff] [blame] | 436 | " ") |
Rod Sheeter | 8b80cbb | 2018-02-07 09:31:31 -0800 | [diff] [blame] | 437 | #else |
| 438 | #define TRACE_SUBSET(this) hb_no_trace_t<bool> trace |
| 439 | #endif |
| 440 | |
Garret Rieger | 75414e8 | 2020-11-05 16:39:23 -0800 | [diff] [blame] | 441 | #ifndef HB_DEBUG_SUBSET_REPACK |
| 442 | #define HB_DEBUG_SUBSET_REPACK (HB_DEBUG+0) |
| 443 | #endif |
| 444 | |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 445 | #ifndef HB_DEBUG_DISPATCH |
| 446 | #define HB_DEBUG_DISPATCH ( \ |
| 447 | HB_DEBUG_APPLY + \ |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 448 | HB_DEBUG_SANITIZE + \ |
| 449 | HB_DEBUG_SERIALIZE + \ |
Behdad Esfahbod | 90b60bd | 2019-03-29 22:12:42 -0700 | [diff] [blame] | 450 | HB_DEBUG_SUBSET + \ |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 451 | 0) |
| 452 | #endif |
| 453 | #if HB_DEBUG_DISPATCH |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 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, \ |
Behdad Esfahbod | 541f3c2 | 2019-08-23 12:25:58 -0700 | [diff] [blame] | 457 | "format %d", (int) format) |
Behdad Esfahbod | 5aad819 | 2017-11-03 17:16:26 -0400 | [diff] [blame] | 458 | #else |
| 459 | #define TRACE_DISPATCH(this, format) hb_no_trace_t<typename context_t::return_t> trace |
| 460 | #endif |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 461 | |
| 462 | |
Behdad Esfahbod | 59b0535 | 2022-07-24 17:14:09 -0600 | [diff] [blame] | 463 | #ifndef HB_BUFFER_MESSAGE_MORE |
| 464 | #define HB_BUFFER_MESSAGE_MORE (HB_DEBUG+1) |
| 465 | #endif |
| 466 | |
| 467 | |
Behdad Esfahbod | 40ec3bb | 2017-11-03 16:57:30 -0400 | [diff] [blame] | 468 | #endif /* HB_DEBUG_HH */ |