Skip to content

Commit fa3056c

Browse files
committed
Merge branch 'master' of https://github.com/krakjoe/phpdbg
2 parents c2365d8 + 77cb82d commit fa3056c

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

phpdbg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#define PHPDBG_HAS_SYM_BP 0x00000010
5858
#define PHPDBG_HAS_OPLINE_BP 0x00000100
5959
#define PHPDBG_HAS_METHOD_BP 0x00001000
60+
#define PHPDBG_BP_MASK (PHPDBG_HAS_FILE_BP|PHPDBG_HAS_SYM_BP|PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_OPLINE_BP)
6061

6162
#define PHPDBG_IS_STEPPING 0x00010000
6263
#define PHPDBG_IS_QUIET 0x00100000

phpdbg_bp.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void phpdbg_llist_breakfile_dtor(void *data) /* {{{ */
3636
static void phpdbg_class_breaks_dtor(void *data) /* {{{ */
3737
{
3838
phpdbg_breakmethod_t *bp = (phpdbg_breakmethod_t*) data;
39-
39+
4040
efree((char*)bp->class_name);
4141
efree((char*)bp->func_name);
4242
} /* }}} */
@@ -92,13 +92,13 @@ void phpdbg_set_breakpoint_symbol(const char *name TSRMLS_DC) /* {{{ */
9292
}
9393
} /* }}} */
9494

95-
void phpdbg_set_breakpoint_method(const char* class_name,
95+
void phpdbg_set_breakpoint_method(const char* class_name,
9696
size_t class_len,
97-
const char* func_name,
97+
const char* func_name,
9898
size_t func_len TSRMLS_DC) /* {{{ */
9999
{
100100
HashTable class_breaks, *class_table;
101-
101+
102102
if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_name, class_len, (void**)&class_table) != SUCCESS) {
103103
zend_hash_init(
104104
&class_breaks, 8, NULL, phpdbg_class_breaks_dtor, 0);
@@ -110,15 +110,15 @@ void phpdbg_set_breakpoint_method(const char* class_name,
110110

111111
if (!zend_hash_exists(class_table, func_name, func_len)) {
112112
phpdbg_breakmethod_t new_break;
113-
113+
114114
PHPDBG_G(flags) |= PHPDBG_HAS_METHOD_BP;
115-
115+
116116
new_break.class_name = class_name;
117117
new_break.class_len = class_len;
118118
new_break.func_name = func_name;
119119
new_break.func_len = func_len;
120120
new_break.id = PHPDBG_G(bp_count)++;
121-
121+
122122
zend_hash_update(class_table, func_name, func_len, &new_break, sizeof(phpdbg_breakmethod_t), NULL);
123123
printf(
124124
"[Breakpoint #%d added at %s::%s]\n", new_break.id, class_name, func_name);
@@ -200,9 +200,9 @@ int phpdbg_find_breakpoint_symbol(zend_function *fbc TSRMLS_DC) /* {{{ */
200200
if (fbc->type != ZEND_USER_FUNCTION) {
201201
return FAILURE;
202202
}
203-
203+
204204
ops = (zend_op_array*)fbc;
205-
205+
206206
if (ops->scope) {
207207
/* find method breaks here */
208208
return phpdbg_find_breakpoint_method(
@@ -235,9 +235,9 @@ int phpdbg_find_breakpoint_method(zend_op_array *ops TSRMLS_DC) /* {{{ */
235235
(void**)&class_table) == SUCCESS) {
236236
if (zend_hash_find(
237237
class_table,
238-
ops->function_name,
238+
ops->function_name,
239239
strlen(ops->function_name), (void**)&bp) == SUCCESS) {
240-
240+
241241
printf(
242242
"[Breakpoint #%d in %s::%s() at %s:%u]\n", bp->id, bp->class_name, bp->func_name,
243243
zend_get_executed_filename(TSRMLS_C),
@@ -272,7 +272,8 @@ void phpdbg_clear_breakpoints(TSRMLS_D) /* {{{ */
272272
zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]);
273273
zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]);
274274

275-
PHPDBG_G(flags) &= ~(PHPDBG_HAS_FILE_BP|PHPDBG_HAS_SYM_BP|PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_OPLINE_BP);
275+
PHPDBG_G(flags) &= ~PHPDBG_BP_MASK;
276+
276277
PHPDBG_G(bp_count) = 0;
277278
} /* }}} */
278279

phpdbg_list.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ void phpdbg_list_file(const char *filename, long count, long offset) /* {{{ */
3333
unsigned int line = 0, displayed = 0;
3434

3535
if ((fd = open(filename, O_RDONLY)) == -1) {
36-
printf("[Failed to open file to list]\n");
36+
printf("[Failed to open file %s to list]\n", filename);
3737
return;
3838
}
3939

40-
fstat(fd, &st);
40+
if (fstat(fd, &st) == -1) {
41+
printf("[Failed to stat file %s]\n", filename);
42+
goto out;
43+
}
4144

4245
last_pos = mem = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
4346
end_pos = mem + st.st_size;
@@ -67,6 +70,6 @@ void phpdbg_list_file(const char *filename, long count, long offset) /* {{{ */
6770
}
6871

6972
munmap(mem, st.st_size);
73+
out:
7074
close(fd);
71-
7275
} /* }}} */

0 commit comments

Comments
 (0)