Skip to content

Commit cdd72cf

Browse files
committed
housekeeping, moving stuff to appropriate units
1 parent 8743afb commit cdd72cf

File tree

5 files changed

+69
-61
lines changed

5 files changed

+69
-61
lines changed

phpdbg.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */
434434
}
435435
} /* }}} */
436436

437+
static inline void phpdbg_sigint_handler(int signo) /* {{{ */
438+
{
439+
TSRMLS_FETCH();
440+
PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED;
441+
} /* }}} */
442+
437443
int main(int argc, char **argv) /* {{{ */
438444
{
439445
sapi_module_struct *phpdbg = &phpdbg_sapi_module;

phpdbg_opcode.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717
+----------------------------------------------------------------------+
1818
*/
1919

20+
#include "phpdbg.h"
2021
#include "zend_vm_opcodes.h"
2122
#include "zend_compile.h"
2223
#include "phpdbg_opcode.h"
24+
#include "phpdbg_utils.h"
25+
26+
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
2327

2428
static inline zend_uint phpdbg_decode_literal(zend_op_array *ops, zend_literal *literal TSRMLS_DC) /* {{{ */
2529
{
@@ -133,6 +137,49 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRM
133137
return decode[0];
134138
} /* }}} */
135139

140+
void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags TSRMLS_DC) /* {{{ */
141+
{
142+
/* force out a line while stepping so the user knows what is happening */
143+
if (ignore_flags ||
144+
(!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) ||
145+
(PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ||
146+
(PHPDBG_G(oplog)))) {
147+
148+
zend_op *opline = execute_data->opline;
149+
char *decode = phpdbg_decode_opline(execute_data->op_array, opline, vars TSRMLS_CC);
150+
151+
if (ignore_flags ||
152+
(!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) ||
153+
(PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) {
154+
/* output line info */
155+
phpdbg_notice("#%- 5lu %16p %-30s %s %s",
156+
opline->lineno,
157+
opline,
158+
phpdbg_decode_opcode(opline->opcode),
159+
decode,
160+
execute_data->op_array->filename ? execute_data->op_array->filename : "unknown");
161+
}
162+
163+
if (!ignore_flags && PHPDBG_G(oplog)) {
164+
phpdbg_log_ex(PHPDBG_G(oplog), "#%- 5lu %16p %-30s %s %s",
165+
opline->lineno,
166+
opline,
167+
phpdbg_decode_opcode(opline->opcode),
168+
decode,
169+
execute_data->op_array->filename ? execute_data->op_array->filename : "unknown");
170+
}
171+
172+
if (decode) {
173+
free(decode);
174+
}
175+
}
176+
} /* }}} */
177+
178+
void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC) /* {{{ */
179+
{
180+
phpdbg_print_opline_ex(execute_data, NULL, ignore_flags TSRMLS_CC);
181+
} /* }}} */
182+
136183
const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */
137184
{
138185
#define CASE(s) case s: return #s

phpdbg_opcode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@
2424

2525
const char *phpdbg_decode_opcode(zend_uchar);
2626
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRMLS_DC);
27+
void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC);
28+
void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags TSRMLS_DC);
2729

2830
#endif /* PHPDBG_OPCODE_H */

phpdbg_prompt.c

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "phpdbg_cmd.h"
3535

3636
/* {{{ command declarations */
37-
static const phpdbg_command_t phpdbg_prompt_commands[] = {
37+
const phpdbg_command_t phpdbg_prompt_commands[] = {
3838
PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, 1),
3939
PHPDBG_COMMAND_D(compile, "attempt compilation", 'c', NULL, 0),
4040
PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, 1),
@@ -1025,49 +1025,6 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
10251025
return ret;
10261026
} /* }}} */
10271027

1028-
void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags TSRMLS_DC) /* {{{ */
1029-
{
1030-
/* force out a line while stepping so the user knows what is happening */
1031-
if (ignore_flags ||
1032-
(!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) ||
1033-
(PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ||
1034-
(PHPDBG_G(oplog)))) {
1035-
1036-
zend_op *opline = execute_data->opline;
1037-
char *decode = phpdbg_decode_opline(execute_data->op_array, opline, vars TSRMLS_CC);
1038-
1039-
if (ignore_flags ||
1040-
(!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) ||
1041-
(PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) {
1042-
/* output line info */
1043-
phpdbg_notice("#%- 5lu %16p %-30s %s %s",
1044-
opline->lineno,
1045-
opline,
1046-
phpdbg_decode_opcode(opline->opcode),
1047-
decode,
1048-
execute_data->op_array->filename ? execute_data->op_array->filename : "unknown");
1049-
}
1050-
1051-
if (!ignore_flags && PHPDBG_G(oplog)) {
1052-
phpdbg_log_ex(PHPDBG_G(oplog), "#%- 5lu %16p %-30s %s %s",
1053-
opline->lineno,
1054-
opline,
1055-
phpdbg_decode_opcode(opline->opcode),
1056-
decode,
1057-
execute_data->op_array->filename ? execute_data->op_array->filename : "unknown");
1058-
}
1059-
1060-
if (decode) {
1061-
free(decode);
1062-
}
1063-
}
1064-
} /* }}} */
1065-
1066-
void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC) /* {{{ */
1067-
{
1068-
phpdbg_print_opline_ex(execute_data, NULL, ignore_flags TSRMLS_CC);
1069-
} /* }}} */
1070-
10711028
void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */
10721029
{
10731030
/* this is implicitly required */
@@ -1084,12 +1041,6 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */
10841041
}
10851042
} /* }}} */
10861043

1087-
void phpdbg_sigint_handler(int signo)
1088-
{
1089-
TSRMLS_FETCH();
1090-
PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED;
1091-
}
1092-
10931044
static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */
10941045
{
10951046
#if PHP_VERSION_ID >= 50500

phpdbg_prompt.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,13 @@
2020
#ifndef PHPDBG_PROMPT_H
2121
#define PHPDBG_PROMPT_H
2222

23+
/* {{{ */
2324
void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC);
2425
int phpdbg_interactive(TSRMLS_D);
25-
void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC);
26-
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRMLS_DC);
2726
int phpdbg_compile(TSRMLS_D);
28-
void phpdbg_clean(zend_bool full TSRMLS_DC);
29-
void phpdbg_sigint_handler(int signo);
27+
void phpdbg_clean(zend_bool full TSRMLS_DC); /* }}} */
3028

31-
#if PHP_VERSION_ID >= 50500
32-
void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC);
33-
#else
34-
void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC);
35-
#endif
36-
37-
/* {{{ */
29+
/* {{{ phpdbg command handlers */
3830
PHPDBG_COMMAND(exec);
3931
PHPDBG_COMMAND(compile);
4032
PHPDBG_COMMAND(step);
@@ -59,4 +51,14 @@ PHPDBG_COMMAND(oplog);
5951
PHPDBG_COMMAND(register);
6052
PHPDBG_COMMAND(quit); /* }}} */
6153

54+
/* {{{ prompt commands */
55+
extern const phpdbg_command_t phpdbg_prompt_commands[]; /* }}} */
56+
57+
/* {{{ */
58+
#if PHP_VERSION_ID >= 50500
59+
void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC);
60+
#else
61+
void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC);
62+
#endif /* }}} */
63+
6264
#endif /* PHPDBG_PROMPT_H */

0 commit comments

Comments
 (0)