@@ -363,6 +363,15 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file) /* {{{ */
363363
364364PHPDBG_API void phpdbg_set_breakpoint_symbol (const char * name , size_t name_len ) /* {{{ */
365365{
366+ char * lcname ;
367+
368+ if (* name == '\\' ) {
369+ name ++ ;
370+ name_len -- ;
371+ }
372+
373+ lcname = zend_str_tolower_dup (name , name_len );
374+
366375 if (!zend_hash_str_exists (& PHPDBG_G (bp )[PHPDBG_BREAK_SYM ], name , name_len )) {
367376 phpdbg_breaksymbol_t new_break ;
368377
@@ -371,29 +380,39 @@ PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len)
371380 PHPDBG_BREAK_INIT (new_break , PHPDBG_BREAK_SYM );
372381 new_break .symbol = estrndup (name , name_len );
373382
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 ));
375384
376385 phpdbg_notice ("breakpoint" , "add=\"success\" id=\"%d\" function=\"%s\"" , "Breakpoint #%d added at %s" , new_break .id , new_break .symbol );
377386
378387 PHPDBG_BREAK_MAPPING (new_break .id , & PHPDBG_G (bp )[PHPDBG_BREAK_SYM ]);
379388 } else {
380389 phpdbg_error ("breakpoint" , "type=\"exists\" add=\"fail\" function=\"%s\"" , "Breakpoint exists at %s" , name );
381390 }
391+
392+ efree (lcname );
382393} /* }}} */
383394
384395PHPDBG_API void phpdbg_set_breakpoint_method (const char * class_name , const char * func_name ) /* {{{ */
385396{
386397 HashTable class_breaks , * class_table ;
387398 size_t class_len = strlen (class_name );
388399 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+ }
390406
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 ))) {
392411 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 ));
394413 }
395414
396- if (!zend_hash_str_exists (class_table , lcname , func_len )) {
415+ if (!zend_hash_str_exists (class_table , func_lcname , func_len )) {
397416 phpdbg_breakmethod_t new_break ;
398417
399418 PHPDBG_G (flags ) |= PHPDBG_HAS_METHOD_BP ;
@@ -404,7 +423,7 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char
404423 new_break .func_name = estrndup (func_name , func_len );
405424 new_break .func_len = func_len ;
406425
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 ));
408427
409428 phpdbg_notice ("breakpoint" , "add=\"success\" id=\"%d\" method=\"%s::%s\"" , "Breakpoint #%d added at %s::%s" , new_break .id , class_name , func_name );
410429
@@ -413,7 +432,8 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char
413432 phpdbg_error ("breakpoint" , "type=\"exists\" add=\"fail\" method=\"%s::%s\"" , "Breakpoint exists at %s::%s" , class_name , func_name );
414433 }
415434
416- efree (lcname );
435+ efree (func_lcname );
436+ efree (class_lcname );
417437} /* }}} */
418438
419439PHPDBG_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) /* {
572592 return SUCCESS ;
573593} /* }}} */
574594
595+ /* TODO ... method/function oplines need to be normalized (leading backslash, lowercase) and file oplines need to be resolved properly */
596+
575597PHPDBG_API void phpdbg_set_breakpoint_method_opline (const char * class , const char * method , zend_ulong opline ) /* {{{ */
576598{
577599 phpdbg_breakopline_t new_break ;
@@ -872,8 +894,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_
872894
873895static inline phpdbg_breakbase_t * phpdbg_find_breakpoint_symbol (zend_function * fbc ) /* {{{ */
874896{
875- const char * fname ;
876- size_t flen ;
877897 zend_op_array * ops ;
878898
879899 if (fbc -> type != ZEND_USER_FUNCTION ) {
@@ -888,30 +908,33 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_symbol(zend_function *f
888908 }
889909
890910 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 ;
893918 } else {
894- fname = "main" ;
895- flen = 4 ;
919+ return zend_hash_str_find_ptr (& PHPDBG_G (bp )[PHPDBG_BREAK_SYM ], ZEND_STRL ("main" ));
896920 }
897-
898- return zend_hash_str_find_ptr (& PHPDBG_G (bp )[PHPDBG_BREAK_SYM ], fname , flen );
899921} /* }}} */
900922
901923static inline phpdbg_breakbase_t * phpdbg_find_breakpoint_method (zend_op_array * ops ) /* {{{ */
902924{
903925 HashTable * class_table ;
904926 phpdbg_breakbase_t * brake = NULL ;
927+ zend_string * class_lcname = zend_string_tolower (ops -> scope -> name );
905928
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 );
909931
910- brake = zend_hash_str_find_ptr (class_table , lcname , lcname_len );
932+ brake = zend_hash_find_ptr (class_table , lcname );
911933
912- efree (lcname );
934+ zend_string_release (lcname );
913935 }
914936
937+ zend_string_release (class_lcname );
915938 return brake ;
916939} /* }}} */
917940
0 commit comments