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
|
||||
#endif
|
||||
|
||||
static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
|
||||
_hb_trace (const char *what,
|
||||
const char *function,
|
||||
void *obj,
|
||||
unsigned int depth,
|
||||
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;
|
||||
}
|
||||
#define TRACE_SANITIZE() \
|
||||
HB_STMT_START { \
|
||||
if (HB_DEBUG_SANITIZE) \
|
||||
_hb_trace ("SANITIZE", __PRETTY_FUNCTION__, this, sanitize_depth, HB_DEBUG_SANITIZE); \
|
||||
} HB_STMT_END
|
||||
|
||||
|
||||
#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 \
|
||||
hb_sanitize_context_t *context TRACE_SANITIZE_ARG_DEF
|
||||
hb_sanitize_context_t *context, \
|
||||
unsigned int sanitize_depth HB_GNUC_UNUSED
|
||||
#define SANITIZE_ARG \
|
||||
context TRACE_SANITIZE_ARG
|
||||
context, \
|
||||
(HB_DEBUG_SANITIZE ? sanitize_depth + 1 : 0)
|
||||
#define SANITIZE_ARG_INIT \
|
||||
&context TRACE_SANITIZE_ARG_INIT
|
||||
&context, \
|
||||
1
|
||||
|
||||
typedef struct _hb_sanitize_context_t hb_sanitize_context_t;
|
||||
struct _hb_sanitize_context_t
|
||||
|
|
|
@ -35,24 +35,11 @@
|
|||
#define HB_DEBUG_APPLY HB_DEBUG+0
|
||||
#endif
|
||||
|
||||
static HB_GNUC_UNUSED inline hb_bool_t /* always returns TRUE */
|
||||
_hb_trace_apply (const char *obj,
|
||||
unsigned int apply_depth,
|
||||
const char *function)
|
||||
{
|
||||
/* 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 TRACE_APPLY() \
|
||||
HB_STMT_START { \
|
||||
if (HB_DEBUG_APPLY) \
|
||||
_hb_trace ("APPLY", __PRETTY_FUNCTION__, this, apply_depth, HB_DEBUG_APPLY); \
|
||||
} HB_STMT_END
|
||||
|
||||
|
||||
#define APPLY_ARG_DEF \
|
||||
|
|
|
@ -31,9 +31,7 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG
|
||||
#define HB_DEBUG 0
|
||||
#endif
|
||||
#include "hb-common.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -46,7 +44,18 @@
|
|||
#include <stdio.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 */
|
||||
|
@ -61,16 +70,6 @@
|
|||
# define HB_INTERNAL extern
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL ((void *) 0)
|
||||
#endif
|
||||
|
||||
#undef FALSE
|
||||
#define FALSE 0
|
||||
|
||||
#undef TRUE
|
||||
#define TRUE 1
|
||||
|
||||
#undef ARRAY_LENGTH
|
||||
#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_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond))
|
||||
|
||||
|
||||
/* Misc */
|
||||
|
||||
#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
|
||||
|
||||
/* 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])
|
||||
|
||||
|
||||
/* 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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue