-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.h
executable file
·51 lines (40 loc) · 2.18 KB
/
debug.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* This file is part of the Zephir.
*
* (c) Phalcon Team <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. If you did not receive
* a copy of the license it is available through the world-wide-web at the
* following url: https://docs.zephir-lang.com/en/latest/license
*/
#ifndef ZEPHIR_KERNEL_DEBUG_H
#define ZEPHIR_KERNEL_DEBUG_H
#ifndef ZEPHIR_RELEASE
#include <php.h>
void zephir_vdump(zval *var, const char *func);
#define PHV(v) zephir_vdump(zval *var, const char *func)
#define PHPR(v) zephir_print_r(v)
typedef struct _zephir_debug_entry {
struct _zephir_debug_entry *prev;
struct _zephir_debug_entry *next;
char *class_name;
char *method_name;
int lineno;
} zephir_debug_entry;
/** The zval's reference count dump */
#define RC_DUMP(zv) \
do { \
char *_n = (strrchr((#zv), '&') ? strrchr((#zv), '&') + 1 : (#zv)); \
char *_f = (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__); \
zval *_z = (zv); \
if (Z_REFCOUNTED_P(_z)) { \
fprintf(stderr, "[DUMP]: %s:%d %s (%p) refcount=%d, type=%d\n", _f, __LINE__, _n, _z, Z_REFCOUNT_P(_z), Z_TYPE_P(_z)); \
} else { \
fprintf(stderr, "[DUMP]: %s:%d %s (%p) is not reference-counted, type=%d\n", _f, __LINE__, _n, _z, Z_TYPE_P(_z)); \
} \
} while (0)
#else
#define RC_DUMP(zv)
#endif /* ZEPHIR_RELEASE */
#endif /* ZEPHIR_KERNEL_DEBUG_H */