Simplify trace code
This commit is contained in:
parent
807c5b03a2
commit
bc20045743
|
@ -124,41 +124,22 @@ ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
|
||||||
#define HB_DEBUG_SANITIZE HB_DEBUG+0
|
#define HB_DEBUG_SANITIZE HB_DEBUG+0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
|
#define TRACE_SANITIZE() \
|
||||||
_hb_trace (const char *what,
|
HB_STMT_START { \
|
||||||
const char *function,
|
if (HB_DEBUG_SANITIZE) \
|
||||||
void *obj,
|
_hb_trace ("SANITIZE", __PRETTY_FUNCTION__, this, sanitize_depth, HB_DEBUG_SANITIZE); \
|
||||||
unsigned int depth,
|
} HB_STMT_END
|
||||||
unsigned int max_depth)
|
|
||||||
{
|
|
||||||
if (depth < max_depth)
|
|
||||||
fprintf (stderr, "%s(%p) %-*d-> %s\n",
|
|
||||||
what,
|
|
||||||
(obj == CharP(&_NullPool)) ? 0 : obj,
|
|
||||||
depth, depth,
|
|
||||||
function);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if HB_DEBUG_SANITIZE
|
|
||||||
#define TRACE_SANITIZE() _hb_trace ("SANITIZE", __PRETTY_FUNCTION__, this, sanitize_depth, HB_DEBUG_SANITIZE)
|
|
||||||
#define TRACE_SANITIZE_ARG_DEF , unsigned int sanitize_depth HB_GNUC_UNUSED
|
|
||||||
#define TRACE_SANITIZE_ARG , sanitize_depth + 1
|
|
||||||
#define TRACE_SANITIZE_ARG_INIT , 1
|
|
||||||
#else
|
|
||||||
#define TRACE_SANITIZE() _hb_trace ("SANITIZE", __PRETTY_FUNCTION__, this, 0, HB_DEBUG_SANITIZE)
|
|
||||||
#define TRACE_SANITIZE_ARG_DEF
|
|
||||||
#define TRACE_SANITIZE_ARG
|
|
||||||
#define TRACE_SANITIZE_ARG_INIT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SANITIZE_ARG_DEF \
|
#define SANITIZE_ARG_DEF \
|
||||||
hb_sanitize_context_t *context TRACE_SANITIZE_ARG_DEF
|
hb_sanitize_context_t *context, \
|
||||||
|
unsigned int sanitize_depth HB_GNUC_UNUSED
|
||||||
#define SANITIZE_ARG \
|
#define SANITIZE_ARG \
|
||||||
context TRACE_SANITIZE_ARG
|
context, \
|
||||||
|
(HB_DEBUG_SANITIZE ? sanitize_depth + 1 : 0)
|
||||||
#define SANITIZE_ARG_INIT \
|
#define SANITIZE_ARG_INIT \
|
||||||
&context TRACE_SANITIZE_ARG_INIT
|
&context, \
|
||||||
|
1
|
||||||
|
|
||||||
typedef struct _hb_sanitize_context_t hb_sanitize_context_t;
|
typedef struct _hb_sanitize_context_t hb_sanitize_context_t;
|
||||||
struct _hb_sanitize_context_t
|
struct _hb_sanitize_context_t
|
||||||
|
|
|
@ -35,24 +35,11 @@
|
||||||
#define HB_DEBUG_APPLY HB_DEBUG+0
|
#define HB_DEBUG_APPLY HB_DEBUG+0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
|
#define TRACE_APPLY() \
|
||||||
_hb_trace_apply (const char *obj,
|
HB_STMT_START { \
|
||||||
unsigned int apply_depth,
|
if (HB_DEBUG_APPLY) \
|
||||||
const char *function)
|
_hb_trace ("APPLY", __PRETTY_FUNCTION__, this, apply_depth, HB_DEBUG_APPLY); \
|
||||||
{
|
} HB_STMT_END
|
||||||
/* The following check is written in such a skewed way just
|
|
||||||
* to quiet compiler warning. The simple version would have been:
|
|
||||||
* if (apply_depth < HB_DEBUG_APPLY)
|
|
||||||
*/
|
|
||||||
if (HB_DEBUG_APPLY && (int) apply_depth < HB_DEBUG_APPLY)
|
|
||||||
fprintf (stderr, "APPLY(%p) %-*d-> %s\n",
|
|
||||||
(obj == CharP(&_NullPool)) ? 0 : obj,
|
|
||||||
apply_depth, apply_depth,
|
|
||||||
function);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define TRACE_APPLY() _hb_trace_apply (CharP(this), apply_depth, __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
|
|
||||||
#define APPLY_ARG_DEF \
|
#define APPLY_ARG_DEF \
|
||||||
|
@ -70,7 +57,7 @@ _hb_trace_apply (const char *obj,
|
||||||
nesting_level_left, \
|
nesting_level_left, \
|
||||||
lookup_flag, \
|
lookup_flag, \
|
||||||
property, \
|
property, \
|
||||||
(HB_DEBUG_APPLY ? apply_depth+1 : 0)
|
(HB_DEBUG_APPLY ? apply_depth + 1 : 0)
|
||||||
#define APPLY_ARG_INIT \
|
#define APPLY_ARG_INIT \
|
||||||
context, \
|
context, \
|
||||||
buffer, \
|
buffer, \
|
||||||
|
|
|
@ -31,9 +31,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HB_DEBUG
|
#include "hb-common.h"
|
||||||
#define HB_DEBUG 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -46,7 +44,18 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "hb-common.h"
|
|
||||||
|
/* Essentials */
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
# define NULL ((void *) 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef FALSE
|
||||||
|
#define FALSE 0
|
||||||
|
|
||||||
|
#undef TRUE
|
||||||
|
#define TRUE 1
|
||||||
|
|
||||||
|
|
||||||
/* Basics */
|
/* Basics */
|
||||||
|
@ -61,16 +70,6 @@
|
||||||
# define HB_INTERNAL extern
|
# define HB_INTERNAL extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NULL
|
|
||||||
# define NULL ((void *) 0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef FALSE
|
|
||||||
#define FALSE 0
|
|
||||||
|
|
||||||
#undef TRUE
|
|
||||||
#define TRUE 1
|
|
||||||
|
|
||||||
#undef ARRAY_LENGTH
|
#undef ARRAY_LENGTH
|
||||||
#define ARRAY_LENGTH(__array) ((signed int) (sizeof (__array) / sizeof (__array[0])))
|
#define ARRAY_LENGTH(__array) ((signed int) (sizeof (__array) / sizeof (__array[0])))
|
||||||
|
|
||||||
|
@ -81,6 +80,9 @@
|
||||||
#define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond))
|
#define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond))
|
||||||
#define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond))
|
#define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond))
|
||||||
|
|
||||||
|
|
||||||
|
/* Misc */
|
||||||
|
|
||||||
#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
|
#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
|
||||||
|
|
||||||
/* Size signifying variable-sized array */
|
/* Size signifying variable-sized array */
|
||||||
|
@ -223,6 +225,24 @@ typedef int hb_mutex_t;
|
||||||
#define hb_be_uint32_cmp(a,b) (a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3])
|
#define hb_be_uint32_cmp(a,b) (a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3])
|
||||||
|
|
||||||
|
|
||||||
|
/* Debug */
|
||||||
|
|
||||||
|
#ifndef HB_DEBUG
|
||||||
|
#define HB_DEBUG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
|
||||||
|
_hb_trace (const char *what,
|
||||||
|
const char *function,
|
||||||
|
const void *obj,
|
||||||
|
unsigned int depth,
|
||||||
|
unsigned int max_depth)
|
||||||
|
{
|
||||||
|
if (depth < max_depth)
|
||||||
|
fprintf (stderr, "%s(%p) %-*d-> %s\n", what, obj, depth, depth, function);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "hb-object-private.h"
|
#include "hb-object-private.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue