php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
phpdbg_cmd.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_CMD_H
20#define PHPDBG_CMD_H
21
22#include "TSRM.h"
23#include "zend_generators.h"
24
25/* {{{ Command and Parameter */
26enum {
27 NO_ARG = 0,
30};
31
50
56 struct {
57 char *name;
60 struct {
61 char *class;
62 char *name;
64 char *str;
65 size_t len;
68};
69
70#define phpdbg_init_param(v, t) do{ \
71 (v)->type = (t); \
72 (v)->addr = 0; \
73 (v)->num = 0; \
74 (v)->file.name = NULL; \
75 (v)->file.line = 0; \
76 (v)->method.class = NULL; \
77 (v)->method.name = NULL; \
78 (v)->str = NULL; \
79 (v)->len = 0; \
80 (v)->next = NULL; \
81 (v)->top = NULL; \
82} while(0)
83
84#define PHPDBG_ASYNC_SAFE 1
85
87
90 const char *name; /* Command name */
91 size_t name_len; /* Command name length */
92 const char *tip; /* Menu tip */
93 size_t tip_len; /* Menu tip length */
94 char alias; /* Alias */
95 phpdbg_command_handler_t handler; /* Command handler */
96 const phpdbg_command_t *subs; /* Sub Commands */
97 char *args; /* Argument Spec */
98 const phpdbg_command_t *parent; /* Parent Command */
99 bool flags; /* General flags */
100};
101/* }}} */
102
103/* {{{ misc */
104#define PHPDBG_STRL(s) s, sizeof(s)-1
105#define PHPDBG_MAX_CMD 500
106#define PHPDBG_FRAME(v) (PHPDBG_G(frame).v)
107#define PHPDBG_EX(v) (EG(current_execute_data)->v)
108
114/* }}} */
115
116/*
117* Workflow:
118* 1) the lexer/parser creates a stack of commands and arguments from input
119* 2) the commands at the top of the stack are resolved sensibly using aliases, abbreviations and case insensitive matching
120* 3) the remaining arguments in the stack are verified (optionally) against the handlers declared argument specification
121* 4) the handler is called passing the top of the stack as the only parameter
122* 5) the stack is destroyed upon return from the handler
123*/
124
125/*
126* Input Management
127*/
128PHPDBG_API char *phpdbg_read_input(const char *buffered);
129PHPDBG_API void phpdbg_destroy_input(char **input);
130PHPDBG_API int phpdbg_ask_user_permission(const char *question);
131
139PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, bool allow_async_unsafe);
141
142/*
143* Parameter Management
144*/
150PHPDBG_API char* phpdbg_param_tostring(const phpdbg_param_t *param, char **pointer);
151PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg);
152
156#define PHPDBG_COMMAND_HANDLER(name) phpdbg_do_##name
157
158#define PHPDBG_COMMAND_D_EXP(name, tip, alias, handler, children, args, parent, flags) \
159 {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, parent, flags}
160
161#define PHPDBG_COMMAND_D_EX(name, tip, alias, handler, children, args, flags) \
162 {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, NULL, flags}
163
164#define PHPDBG_COMMAND_D(name, tip, alias, children, args, flags) \
165 {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, args, NULL, flags}
166
167#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param)
168
169#define PHPDBG_COMMAND_ARGS param
170
171#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, NULL, NULL, 0}
172
173/*
174* Default Switch Case
175*/
176#define phpdbg_default_switch_case() \
177 default: \
178 phpdbg_error("Unsupported parameter type (%s) for command", phpdbg_get_param_type(param)); \
179 break
180
181#endif /* PHPDBG_CMD_H */
file(string $filename, int $flags=0, $context=null)
char * msg
Definition phpdbg.h:289
#define PHPDBG_API
Definition phpdbg.h:27
struct _phpdbg_param phpdbg_param_t
Definition phpdbg_cmd.h:51
PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, bool allow_async_unsafe)
Definition phpdbg_cmd.c:720
int(* phpdbg_command_handler_t)(const phpdbg_param_t *)
Definition phpdbg_cmd.h:86
phpdbg_param_type
Definition phpdbg_cmd.h:32
@ NUMERIC_FILE_PARAM
Definition phpdbg_cmd.h:36
@ EVAL_PARAM
Definition phpdbg_cmd.h:43
@ EMPTY_PARAM
Definition phpdbg_cmd.h:33
@ ADDR_PARAM
Definition phpdbg_cmd.h:34
@ OP_PARAM
Definition phpdbg_cmd.h:46
@ NUMERIC_METHOD_PARAM
Definition phpdbg_cmd.h:41
@ SHELL_PARAM
Definition phpdbg_cmd.h:44
@ STACK_PARAM
Definition phpdbg_cmd.h:42
@ ORIG_PARAM
Definition phpdbg_cmd.h:47
@ STR_PARAM
Definition phpdbg_cmd.h:38
@ COND_PARAM
Definition phpdbg_cmd.h:45
@ METHOD_PARAM
Definition phpdbg_cmd.h:37
@ FILE_PARAM
Definition phpdbg_cmd.h:35
@ RUN_PARAM
Definition phpdbg_cmd.h:48
@ NUMERIC_PARAM
Definition phpdbg_cmd.h:39
@ NUMERIC_FUNCTION_PARAM
Definition phpdbg_cmd.h:40
PHPDBG_API const char * phpdbg_get_param_type(const phpdbg_param_t *)
Definition phpdbg_cmd.c:49
@ REQUIRED_ARG
Definition phpdbg_cmd.h:28
@ OPTIONAL_ARG
Definition phpdbg_cmd.h:29
@ NO_ARG
Definition phpdbg_cmd.h:27
PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t *, phpdbg_param_t *)
Definition phpdbg_cmd.c:138
PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg)
Definition phpdbg_cmd.c:326
struct _phpdbg_command_t phpdbg_command_t
Definition phpdbg_cmd.h:88
PHPDBG_API char * phpdbg_read_input(const char *buffered)
Definition phpdbg_cmd.c:745
PHPDBG_API void phpdbg_clear_param(phpdbg_param_t *)
Definition phpdbg_cmd.c:75
PHPDBG_API void phpdbg_destroy_input(char **input)
Definition phpdbg_cmd.c:811
PHPDBG_API void phpdbg_stack_separate(phpdbg_param_t *param)
Definition phpdbg_cmd.c:462
PHPDBG_API char * phpdbg_param_tostring(const phpdbg_param_t *param, char **pointer)
Definition phpdbg_cmd.c:96
PHPDBG_API bool phpdbg_match_param(const phpdbg_param_t *, const phpdbg_param_t *)
Definition phpdbg_cmd.c:251
PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param)
Definition phpdbg_cmd.c:437
PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t *)
Definition phpdbg_cmd.c:196
PHPDBG_API const phpdbg_command_t * phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top)
Definition phpdbg_cmd.c:575
PHPDBG_API int phpdbg_ask_user_permission(const char *question)
Definition phpdbg_cmd.c:816
PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack)
Definition phpdbg_cmd.c:471
PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack)
Definition phpdbg_cmd.c:377
original_stack top
const phpdbg_command_t * subs
Definition phpdbg_cmd.h:96
const char * tip
Definition phpdbg_cmd.h:92
phpdbg_command_handler_t handler
Definition phpdbg_cmd.h:95
const char * name
Definition phpdbg_cmd.h:90
const phpdbg_command_t * parent
Definition phpdbg_cmd.h:98
zend_ulong line
Definition phpdbg_cmd.h:58
phpdbg_param_t * top
Definition phpdbg_cmd.h:67
phpdbg_param_type type
Definition phpdbg_cmd.h:53
zend_ulong addr
Definition phpdbg_cmd.h:55
zend_long num
Definition phpdbg_cmd.h:54
phpdbg_param_t * next
Definition phpdbg_cmd.h:66
struct _phpdbg_param::@004226021353141374347100337026301377067143131166 method
zend_execute_data * execute_data
Definition phpdbg_cmd.h:112
zend_generator * generator
Definition phpdbg_cmd.h:111
struct _zend_generator zend_generator
int32_t zend_long
Definition zend_long.h:42
uint32_t zend_ulong
Definition zend_long.h:43
struct _zend_execute_data zend_execute_data
Definition zend_types.h:91