php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
phpdbg_set.c
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#include "phpdbg.h"
20#include "phpdbg_cmd.h"
21#include "phpdbg_set.h"
22#include "phpdbg_utils.h"
23#include "phpdbg_bp.h"
24#include "phpdbg_prompt.h"
25
27
28#define PHPDBG_SET_COMMAND_D(f, h, a, m, l, s, flags) \
29 PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[17], flags)
30
32 PHPDBG_SET_COMMAND_D(prompt, "usage: set prompt [<string>]", 'p', set_prompt, NULL, "|s", 0),
33 PHPDBG_SET_COMMAND_D(pagination, "usage: set pagination [<on|off>]", 'P', set_pagination, NULL, "|b", PHPDBG_ASYNC_SAFE),
34#ifndef _WIN32
35 PHPDBG_SET_COMMAND_D(color, "usage: set color <element> <color>", 'c', set_color, NULL, "ss", PHPDBG_ASYNC_SAFE),
36 PHPDBG_SET_COMMAND_D(colors, "usage: set colors [<on|off>]", 'C', set_colors, NULL, "|b", PHPDBG_ASYNC_SAFE),
37#endif
38 PHPDBG_SET_COMMAND_D(break, "usage: set break id [<on|off>]", 'b', set_break, NULL, "l|b", PHPDBG_ASYNC_SAFE),
39 PHPDBG_SET_COMMAND_D(breaks, "usage: set breaks [<on|off>]", 'B', set_breaks, NULL, "|b", PHPDBG_ASYNC_SAFE),
40 PHPDBG_SET_COMMAND_D(quiet, "usage: set quiet [<on|off>]", 'q', set_quiet, NULL, "|b", PHPDBG_ASYNC_SAFE),
41 PHPDBG_SET_COMMAND_D(stepping, "usage: set stepping [<line|op>]", 's', set_stepping, NULL, "|s", PHPDBG_ASYNC_SAFE),
42 PHPDBG_SET_COMMAND_D(refcount, "usage: set refcount [<on|off>]", 'r', set_refcount, NULL, "|b", PHPDBG_ASYNC_SAFE),
43 PHPDBG_SET_COMMAND_D(lines, "usage: set lines [<number>]", 'l', set_lines, NULL, "|l", PHPDBG_ASYNC_SAFE),
45};
46
47PHPDBG_SET(prompt) /* {{{ */
48{
49 if (!param || param->type == EMPTY_PARAM) {
50 phpdbg_writeln("Current prompt: %s", phpdbg_get_prompt());
51 } else {
52 phpdbg_set_prompt(param->str);
53 }
54
55 return SUCCESS;
56} /* }}} */
57
58PHPDBG_SET(pagination) /* {{{ */
59{
60 if (!param || param->type == EMPTY_PARAM) {
61 phpdbg_writeln("Pagination %s", PHPDBG_G(flags) & PHPDBG_HAS_PAGINATION ? "on" : "off");
62 } else switch (param->type) {
63 case NUMERIC_PARAM: {
64 if (param->num) {
66 } else {
68 }
69 } break;
70
71 default:
72 phpdbg_error("set pagination used incorrectly: set pagination <on|off>");
73 }
74
75 return SUCCESS;
76} /* }}} */
77
78PHPDBG_SET(lines) /* {{{ */
79{
80 if (!param || param->type == EMPTY_PARAM) {
82 } else switch (param->type) {
83 case NUMERIC_PARAM: {
84 PHPDBG_G(lines) = param->num;
85 } break;
86
87 default:
88 phpdbg_error("set lines used incorrectly: set lines <number>");
89 }
90
91 return SUCCESS;
92} /* }}} */
93
94PHPDBG_SET(break) /* {{{ */
95{
96 switch (param->type) {
97 case NUMERIC_PARAM: {
98 if (param->next) {
99 if (param->next->num) {
100 phpdbg_enable_breakpoint(param->num);
101 } else {
102 phpdbg_disable_breakpoint(param->num);
103 }
104 } else {
105 phpdbg_breakbase_t *brake = phpdbg_find_breakbase(param->num);
106 if (brake) {
107 phpdbg_writeln("Breakpoint #"ZEND_LONG_FMT" %s", param->num, brake->disabled ? "off" : "on");
108 } else {
109 phpdbg_error("Failed to find breakpoint #"ZEND_LONG_FMT, param->num);
110 }
111 }
112 } break;
113
114 default:
115 phpdbg_error("set break used incorrectly: set break [id] <on|off>");
116 }
117
118 return SUCCESS;
119} /* }}} */
120
121PHPDBG_SET(breaks) /* {{{ */
122{
123 if (!param || param->type == EMPTY_PARAM) {
124 phpdbg_writeln("Breakpoints %s",PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED ? "on" : "off");
125 } else switch (param->type) {
126 case NUMERIC_PARAM: {
127 if (param->num) {
129 } else {
131 }
132 } break;
133
134 default:
135 phpdbg_error("set breaks used incorrectly: set breaks <on|off>");
136 }
137
138 return SUCCESS;
139} /* }}} */
140
141#ifndef _WIN32
142PHPDBG_SET(color) /* {{{ */
143{
144 const phpdbg_color_t *color = phpdbg_get_color(param->next->str, param->next->len);
145
146 if (!color) {
147 phpdbg_error("Failed to find the requested color (%s)", param->next->str);
148 return SUCCESS;
149 }
150
151 switch (phpdbg_get_element(param->str, param->len)) {
153 phpdbg_notice("setting prompt color to %s (%s)", color->name, color->code);
154 if (PHPDBG_G(prompt)[1]) {
155 free(PHPDBG_G(prompt)[1]);
156 PHPDBG_G(prompt)[1]=NULL;
157 }
159 break;
160
162 phpdbg_notice("setting error color to %s (%s)", color->name, color->code);
164 break;
165
167 phpdbg_notice("setting notice color to %s (%s)", color->name, color->code);
169 break;
170
171 default:
172 phpdbg_error("Failed to find the requested element (%s)", param->str);
173 }
174
175 return SUCCESS;
176} /* }}} */
177
178PHPDBG_SET(colors) /* {{{ */
179{
180 if (!param || param->type == EMPTY_PARAM) {
181 phpdbg_writeln("Colors %s", PHPDBG_G(flags) & PHPDBG_IS_COLOURED ? "on" : "off");
182 } else switch (param->type) {
183 case NUMERIC_PARAM: {
184 if (param->num) {
186 } else {
188 }
189 } break;
190
191 default:
192 phpdbg_error("set colors used incorrectly: set colors <on|off>");
193 }
194
195 return SUCCESS;
196} /* }}} */
197#endif
198
199PHPDBG_SET(quiet) /* {{{ */
200{
201 if (!param || param->type == EMPTY_PARAM) {
202 phpdbg_writeln("Quietness %s", PHPDBG_G(flags) & PHPDBG_IS_QUIET ? "on" : "off");
203 } else switch (param->type) {
204 case NUMERIC_PARAM: {
205 if (param->num) {
207 } else {
209 }
210 } break;
211
213 }
214
215 return SUCCESS;
216} /* }}} */
217
218PHPDBG_SET(stepping) /* {{{ */
219{
220 if (!param || param->type == EMPTY_PARAM) {
221 phpdbg_writeln("Stepping %s", PHPDBG_G(flags) & PHPDBG_STEP_OPCODE ? "opcode" : "line");
222 } else switch (param->type) {
223 case STR_PARAM: {
224 if (param->len == sizeof("opcode") - 1 && !memcmp(param->str, "opcode", sizeof("opcode"))) {
226 } else if (param->len == sizeof("line") - 1 && !memcmp(param->str, "line", sizeof("line"))) {
228 } else {
229 phpdbg_error("usage set stepping [<opcode|line>]");
230 }
231 } break;
232
234 }
235
236 return SUCCESS;
237} /* }}} */
238
239PHPDBG_SET(refcount) /* {{{ */
240{
241 if (!param || param->type == EMPTY_PARAM) {
242 phpdbg_writeln("Showing refcounts %s", PHPDBG_G(flags) & PHPDBG_IS_QUIET ? "on" : "off");
243 } else switch (param->type) {
244 case NUMERIC_PARAM: {
245 if (param->num) {
247 } else {
249 }
250 } break;
251
253 }
254
255 return SUCCESS;
256} /* }}} */
Definition test.php:8
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
short color
#define PHPDBG_SHOW_REFCOUNTS
Definition phpdbg.h:163
#define PHPDBG_G(v)
Definition phpdbg.h:102
#define PHPDBG_IS_QUIET
Definition phpdbg.h:146
#define PHPDBG_STEP_OPCODE
Definition phpdbg.h:145
#define PHPDBG_HAS_PAGINATION
Definition phpdbg.h:166
#define PHPDBG_IS_COLOURED
Definition phpdbg.h:148
zend_ulong lines
Definition phpdbg.h:311
#define PHPDBG_IS_BP_ENABLED
Definition phpdbg.h:162
const phpdbg_color_t * colors[PHPDBG_COLORS]
Definition phpdbg.h:295
PHPDBG_API void phpdbg_disable_breakpoints(void)
Definition phpdbg_bp.c:1418
PHPDBG_API void phpdbg_disable_breakpoint(zend_ulong id)
Definition phpdbg_bp.c:1404
PHPDBG_API void phpdbg_enable_breakpoint(zend_ulong id)
Definition phpdbg_bp.c:1395
PHPDBG_API phpdbg_breakbase_t * phpdbg_find_breakbase(zend_ulong id)
Definition phpdbg_bp.c:1422
PHPDBG_API void phpdbg_enable_breakpoints(void)
Definition phpdbg_bp.c:1413
struct _phpdbg_breakbase_t phpdbg_breakbase_t
@ EMPTY_PARAM
Definition phpdbg_cmd.h:33
@ STR_PARAM
Definition phpdbg_cmd.h:38
@ NUMERIC_PARAM
Definition phpdbg_cmd.h:39
#define PHPDBG_END_COMMAND
Definition phpdbg_cmd.h:171
#define phpdbg_default_switch_case()
Definition phpdbg_cmd.h:176
struct _phpdbg_command_t phpdbg_command_t
Definition phpdbg_cmd.h:88
#define PHPDBG_ASYNC_SAFE
Definition phpdbg_cmd.h:84
#define phpdbg_error(strfmt,...)
Definition phpdbg_out.h:43
#define phpdbg_notice(strfmt,...)
Definition phpdbg_out.h:44
#define phpdbg_writeln(strfmt,...)
Definition phpdbg_out.h:45
#define PHPDBG_SET_COMMAND_D(f, h, a, m, l, s, flags)
Definition phpdbg_set.c:28
const phpdbg_command_t phpdbg_set_commands[]
Definition phpdbg_set.c:31
#define PHPDBG_SET(name)
Definition phpdbg_set.h:24
PHPDBG_API const phpdbg_color_t * phpdbg_get_color(const char *name, size_t name_length)
PHPDBG_API int phpdbg_get_element(const char *name, size_t len)
PHPDBG_API void phpdbg_set_prompt(const char *prompt)
PHPDBG_API const char * phpdbg_get_prompt(void)
PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color)
#define PHPDBG_COLOR_PROMPT
struct _phpdbg_color_t phpdbg_color_t
#define PHPDBG_COLOR_NOTICE
#define PHPDBG_COLOR_ERROR
char * prompt
#define ZEND_EXTERN_MODULE_GLOBALS(module_name)
Definition zend_API.h:270
#define ZEND_ULONG_FMT
Definition zend_long.h:88
#define ZEND_LONG_FMT
Definition zend_long.h:87