php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
phpdbg_utils.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Felipe Pena <felipe@php.net> |
14 | Authors: Joe Watkins <joe.watkins@live.co.uk> |
15 | Authors: Bob Weinand <bwoebi@php.net> |
16 +----------------------------------------------------------------------+
17*/
18
19#ifndef PHPDBG_UTILS_H
20#define PHPDBG_UTILS_H
21
25PHPDBG_API int phpdbg_is_numeric(const char*);
26PHPDBG_API int phpdbg_is_empty(const char*);
27PHPDBG_API int phpdbg_is_addr(const char*);
28PHPDBG_API int phpdbg_is_class_method(const char*, size_t, char**, char**);
29PHPDBG_API const char *phpdbg_current_file(void);
30PHPDBG_API char *phpdbg_resolve_path(const char*);
31PHPDBG_API char *phpdbg_trim(const char*, size_t, size_t*);
32PHPDBG_API const zend_function *phpdbg_get_function(const char*, const char*);
33
34/* {{{ Color Management */
35#define PHPDBG_COLOR_LEN 12
36#define PHPDBG_COLOR_D(color, code) \
37 {color, sizeof(color)-1, code}
38#define PHPDBG_COLOR_END \
39 {NULL, 0L, {0}}
40#define PHPDBG_ELEMENT_LEN 3
41#define PHPDBG_ELEMENT_D(name, id) \
42 {name, sizeof(name)-1, id}
43#define PHPDBG_ELEMENT_END \
44 {NULL, 0L, 0}
45
46#define PHPDBG_COLOR_INVALID -1
47#define PHPDBG_COLOR_PROMPT 0
48#define PHPDBG_COLOR_ERROR 1
49#define PHPDBG_COLOR_NOTICE 2
50#define PHPDBG_COLORS 3
51
52typedef struct _phpdbg_color_t {
53 char *name;
57
58typedef struct _phpdbg_element_t {
59 char *name;
61 int id;
63
64PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_length);
65PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color);
66PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length);
68PHPDBG_API int phpdbg_get_element(const char *name, size_t len); /* }}} */
69
70/* {{{ Prompt Management */
71PHPDBG_API void phpdbg_set_prompt(const char*);
72PHPDBG_API const char *phpdbg_get_prompt(void); /* }}} */
73
74/* {{{ Console size */
76PHPDBG_API uint32_t phpdbg_get_terminal_height(void); /* }}} */
77
79
81
82int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry **ce);
83
84char *phpdbg_get_property_key(char *key);
85
86typedef int (*phpdbg_parse_var_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval *zv);
87typedef int (*phpdbg_parse_var_with_arg_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval *zv, void *arg);
88
89PHPDBG_API int phpdbg_parse_variable(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_func callback, bool silent);
90PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_with_arg_func callback, phpdbg_parse_var_with_arg_func step_cb, bool silent, void *arg);
91
92int phpdbg_is_auto_global(char *name, int len);
93
95
97
98static zend_always_inline zend_execute_data *phpdbg_user_execute_data(zend_execute_data *ex) {
99 while (!ex->func || !ZEND_USER_CODE(ex->func->common.type)) {
100 ex = ex->prev_execute_data;
102 }
103 return ex;
104}
105
106#ifdef ZTS
107#define PHPDBG_OUTPUT_BACKUP_DEFINES() \
108 zend_output_globals *output_globals_ptr; \
109 zend_output_globals original_output_globals; \
110 output_globals_ptr = TSRMG_BULK_STATIC(output_globals_id, zend_output_globals *);
111#else
112#define PHPDBG_OUTPUT_BACKUP_DEFINES() \
113 zend_output_globals *output_globals_ptr; \
114 zend_output_globals original_output_globals; \
115 output_globals_ptr = &output_globals;
116#endif
117
118#define PHPDBG_OUTPUT_BACKUP_SWAP() \
119 original_output_globals = *output_globals_ptr; \
120 memset(output_globals_ptr, 0, sizeof(zend_output_globals)); \
121 php_output_activate();
122
123#define PHPDBG_OUTPUT_BACKUP() \
124 PHPDBG_OUTPUT_BACKUP_DEFINES() \
125 PHPDBG_OUTPUT_BACKUP_SWAP()
126
127#define PHPDBG_OUTPUT_BACKUP_RESTORE() \
128 php_output_deactivate(); \
129 *output_globals_ptr = original_output_globals;
130
131#endif /* PHPDBG_UTILS_H */
size_t len
Definition apprentice.c:174
bool exception
Definition assert.c:30
zval callback
Definition assert.c:25
zval * zv
Definition ffi.c:3975
zval * arg
Definition ffi.c:3975
zend_long maxlen
short color
unsigned char key[REFLECTION_KEY_LEN]
#define PHPDBG_API
Definition phpdbg.h:27
int fd
Definition phpdbg.h:282
zend_object * ex
PHPDBG_API const phpdbg_color_t * phpdbg_get_color(const char *name, size_t name_length)
PHPDBG_API int phpdbg_is_numeric(const char *)
int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry **ce)
int phpdbg_is_auto_global(char *name, int len)
PHPDBG_API const phpdbg_color_t * phpdbg_get_colors(void)
PHPDBG_API int phpdbg_get_element(const char *name, size_t len)
PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_with_arg_func callback, phpdbg_parse_var_with_arg_func step_cb, bool silent, void *arg)
int(* phpdbg_parse_var_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval *zv)
PHPDBG_API void phpdbg_set_async_io(int fd)
PHPDBG_API const zend_function * phpdbg_get_function(const char *, const char *)
PHPDBG_API char * phpdbg_trim(const char *, size_t, size_t *)
PHPDBG_API bool phpdbg_check_caught_ex(zend_execute_data *ex, zend_object *exception)
#define PHPDBG_COLOR_LEN
PHPDBG_API int phpdbg_is_class_method(const char *, size_t, char **, char **)
PHPDBG_API char * phpdbg_resolve_path(const char *)
char * phpdbg_get_property_key(char *key)
PHPDBG_API int phpdbg_is_empty(const char *)
struct _phpdbg_color_t phpdbg_color_t
PHPDBG_API void phpdbg_set_prompt(const char *)
PHPDBG_API int phpdbg_parse_variable(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_func callback, bool silent)
int phpdbg_rebuild_symtable(void)
int(* phpdbg_parse_var_with_arg_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval *zv, void *arg)
PHPDBG_API const char * phpdbg_current_file(void)
PHPDBG_API uint32_t phpdbg_get_terminal_width(void)
PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length)
PHPDBG_API const char * phpdbg_get_prompt(void)
PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color)
PHPDBG_API int phpdbg_is_addr(const char *)
PHPDBG_API uint32_t phpdbg_get_terminal_height(void)
struct _phpdbg_element_t phpdbg_element_t
char * phpdbg_short_zval_print(zval *zv, int maxlen)
const char code[PHPDBG_COLOR_LEN]
struct _zval_struct zval
#define ZEND_USER_CODE(type)
union _zend_function zend_function
#define zend_always_inline
#define ZEND_ASSERT(c)
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
struct _zend_array HashTable
Definition zend_types.h:386
struct _zend_execute_data zend_execute_data
Definition zend_types.h:91
zend_string * name