@@ -363,6 +363,15 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file) /* {{{ */
363
363
364
364
PHPDBG_API void phpdbg_set_breakpoint_symbol (const char * name , size_t name_len ) /* {{{ */
365
365
{
366
+ char * lcname ;
367
+
368
+ if (* name == '\\' ) {
369
+ name ++ ;
370
+ name_len -- ;
371
+ }
372
+
373
+ lcname = zend_str_tolower_dup (name , name_len );
374
+
366
375
if (!zend_hash_str_exists (& PHPDBG_G (bp )[PHPDBG_BREAK_SYM ], name , name_len )) {
367
376
phpdbg_breaksymbol_t new_break ;
368
377
@@ -371,29 +380,39 @@ PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len)
371
380
PHPDBG_BREAK_INIT (new_break , PHPDBG_BREAK_SYM );
372
381
new_break .symbol = estrndup (name , name_len );
373
382
374
- zend_hash_str_update_mem (& PHPDBG_G (bp )[PHPDBG_BREAK_SYM ], new_break . symbol , name_len , & new_break , sizeof (phpdbg_breaksymbol_t ));
383
+ zend_hash_str_update_mem (& PHPDBG_G (bp )[PHPDBG_BREAK_SYM ], lcname , name_len , & new_break , sizeof (phpdbg_breaksymbol_t ));
375
384
376
385
phpdbg_notice ("breakpoint" , "add=\"success\" id=\"%d\" function=\"%s\"" , "Breakpoint #%d added at %s" , new_break .id , new_break .symbol );
377
386
378
387
PHPDBG_BREAK_MAPPING (new_break .id , & PHPDBG_G (bp )[PHPDBG_BREAK_SYM ]);
379
388
} else {
380
389
phpdbg_error ("breakpoint" , "type=\"exists\" add=\"fail\" function=\"%s\"" , "Breakpoint exists at %s" , name );
381
390
}
391
+
392
+ efree (lcname );
382
393
} /* }}} */
383
394
384
395
PHPDBG_API void phpdbg_set_breakpoint_method (const char * class_name , const char * func_name ) /* {{{ */
385
396
{
386
397
HashTable class_breaks , * class_table ;
387
398
size_t class_len = strlen (class_name );
388
399
size_t func_len = strlen (func_name );
389
- char * lcname = zend_str_tolower_dup (func_name , func_len );
400
+ char * func_lcname , * class_lcname ;
401
+
402
+ if (* class_name == '\\' ) {
403
+ class_name ++ ;
404
+ class_len -- ;
405
+ }
390
406
391
- if (!(class_table = zend_hash_str_find_ptr (& PHPDBG_G (bp )[PHPDBG_BREAK_METHOD ], class_name , class_len ))) {
407
+ func_lcname = zend_str_tolower_dup (func_name , func_len );
408
+ class_lcname = zend_str_tolower_dup (class_name , class_len );
409
+
410
+ if (!(class_table = zend_hash_str_find_ptr (& PHPDBG_G (bp )[PHPDBG_BREAK_METHOD ], class_lcname , class_len ))) {
392
411
zend_hash_init (& class_breaks , 8 , NULL , phpdbg_class_breaks_dtor , 0 );
393
- class_table = zend_hash_str_update_mem (& PHPDBG_G (bp )[PHPDBG_BREAK_METHOD ], class_name , class_len , & class_breaks , sizeof (HashTable ));
412
+ class_table = zend_hash_str_update_mem (& PHPDBG_G (bp )[PHPDBG_BREAK_METHOD ], class_lcname , class_len , & class_breaks , sizeof (HashTable ));
394
413
}
395
414
396
- if (!zend_hash_str_exists (class_table , lcname , func_len )) {
415
+ if (!zend_hash_str_exists (class_table , func_lcname , func_len )) {
397
416
phpdbg_breakmethod_t new_break ;
398
417
399
418
PHPDBG_G (flags ) |= PHPDBG_HAS_METHOD_BP ;
@@ -404,7 +423,7 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char
404
423
new_break .func_name = estrndup (func_name , func_len );
405
424
new_break .func_len = func_len ;
406
425
407
- zend_hash_str_update_mem (class_table , lcname , func_len , & new_break , sizeof (phpdbg_breakmethod_t ));
426
+ zend_hash_str_update_mem (class_table , func_lcname , func_len , & new_break , sizeof (phpdbg_breakmethod_t ));
408
427
409
428
phpdbg_notice ("breakpoint" , "add=\"success\" id=\"%d\" method=\"%s::%s\"" , "Breakpoint #%d added at %s::%s" , new_break .id , class_name , func_name );
410
429
@@ -413,7 +432,8 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char
413
432
phpdbg_error ("breakpoint" , "type=\"exists\" add=\"fail\" method=\"%s::%s\"" , "Breakpoint exists at %s::%s" , class_name , func_name );
414
433
}
415
434
416
- efree (lcname );
435
+ efree (func_lcname );
436
+ efree (class_lcname );
417
437
} /* }}} */
418
438
419
439
PHPDBG_API void phpdbg_set_breakpoint_opline (zend_ulong opline ) /* {{{ */
@@ -572,6 +592,8 @@ PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break) /* {
572
592
return SUCCESS ;
573
593
} /* }}} */
574
594
595
+ /* TODO ... method/function oplines need to be normalized (leading backslash, lowercase) and file oplines need to be resolved properly */
596
+
575
597
PHPDBG_API void phpdbg_set_breakpoint_method_opline (const char * class , const char * method , zend_ulong opline ) /* {{{ */
576
598
{
577
599
phpdbg_breakopline_t new_break ;
@@ -872,8 +894,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_
872
894
873
895
static inline phpdbg_breakbase_t * phpdbg_find_breakpoint_symbol (zend_function * fbc ) /* {{{ */
874
896
{
875
- const char * fname ;
876
- size_t flen ;
877
897
zend_op_array * ops ;
878
898
879
899
if (fbc -> type != ZEND_USER_FUNCTION ) {
@@ -888,30 +908,33 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_symbol(zend_function *f
888
908
}
889
909
890
910
if (ops -> function_name ) {
891
- fname = ZSTR_VAL (ops -> function_name );
892
- flen = ZSTR_LEN (ops -> function_name );
911
+ phpdbg_breakbase_t * brake ;
912
+ zend_string * fname = zend_string_tolower (ops -> function_name );
913
+
914
+ brake = zend_hash_find_ptr (& PHPDBG_G (bp )[PHPDBG_BREAK_SYM ], fname );
915
+
916
+ zend_string_release (fname );
917
+ return brake ;
893
918
} else {
894
- fname = "main" ;
895
- flen = 4 ;
919
+ return zend_hash_str_find_ptr (& PHPDBG_G (bp )[PHPDBG_BREAK_SYM ], ZEND_STRL ("main" ));
896
920
}
897
-
898
- return zend_hash_str_find_ptr (& PHPDBG_G (bp )[PHPDBG_BREAK_SYM ], fname , flen );
899
921
} /* }}} */
900
922
901
923
static inline phpdbg_breakbase_t * phpdbg_find_breakpoint_method (zend_op_array * ops ) /* {{{ */
902
924
{
903
925
HashTable * class_table ;
904
926
phpdbg_breakbase_t * brake = NULL ;
927
+ zend_string * class_lcname = zend_string_tolower (ops -> scope -> name );
905
928
906
- if ((class_table = zend_hash_find_ptr (& PHPDBG_G (bp )[PHPDBG_BREAK_METHOD ], ops -> scope -> name ))) {
907
- size_t lcname_len = ZSTR_LEN (ops -> function_name );
908
- char * lcname = zend_str_tolower_dup (ZSTR_VAL (ops -> function_name ), lcname_len );
929
+ if ((class_table = zend_hash_find_ptr (& PHPDBG_G (bp )[PHPDBG_BREAK_METHOD ], class_lcname ))) {
930
+ zend_string * lcname = zend_string_tolower (ops -> function_name );
909
931
910
- brake = zend_hash_str_find_ptr (class_table , lcname , lcname_len );
932
+ brake = zend_hash_find_ptr (class_table , lcname );
911
933
912
- efree (lcname );
934
+ zend_string_release (lcname );
913
935
}
914
936
937
+ zend_string_release (class_lcname );
915
938
return brake ;
916
939
} /* }}} */
917
940
0 commit comments