@@ -218,7 +218,7 @@ void phpdbg_print_watch_diff(phpdbg_watchtype type, zend_string *name, void *old
218
218
/* ### LOW LEVEL WATCHPOINT HANDLING ### */
219
219
static phpdbg_watchpoint_t * phpdbg_check_for_watchpoint (phpdbg_btree * tree , void * addr ) {
220
220
phpdbg_watchpoint_t * watch ;
221
- phpdbg_btree_result * result = phpdbg_btree_find_closest (tree , (zend_ulong ) phpdbg_get_page_boundary (addr ) + phpdbg_pagesize - 1 );
221
+ phpdbg_btree_result * result = phpdbg_btree_find_closest (tree , (zend_ulong )( uintptr_t ) phpdbg_get_page_boundary (addr ) + phpdbg_pagesize - 1 );
222
222
223
223
if (result == NULL ) {
224
224
return NULL ;
@@ -301,7 +301,7 @@ int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context) {
301
301
/* re-enable writing */
302
302
mprotect (page , phpdbg_pagesize , PROT_READ | PROT_WRITE );
303
303
304
- zend_hash_index_add_empty_element (PHPDBG_G (watchlist_mem ), (zend_ulong ) page );
304
+ zend_hash_index_add_empty_element (PHPDBG_G (watchlist_mem ), (zend_ulong )( uintptr_t ) page );
305
305
306
306
return SUCCESS ;
307
307
}
@@ -317,7 +317,7 @@ void *phpdbg_watchpoint_userfaultfd_thread(void *phpdbg_globals_ptr) {
317
317
struct uffd_msg fault_msg = {0 };
318
318
while (read (globals -> watch_userfaultfd , & fault_msg , sizeof (fault_msg )) == sizeof (fault_msg )) {
319
319
void * page = phpdbg_get_page_boundary ((char * )(uintptr_t ) fault_msg .arg .pagefault .address );
320
- zend_hash_index_add_empty_element (globals -> watchlist_mem , (zend_ulong ) page );
320
+ zend_hash_index_add_empty_element (globals -> watchlist_mem , (zend_ulong )( uintptr_t ) page );
321
321
struct uffdio_writeprotect unprotect = {
322
322
.mode = 0 ,
323
323
.range = {
@@ -335,14 +335,14 @@ void *phpdbg_watchpoint_userfaultfd_thread(void *phpdbg_globals_ptr) {
335
335
/* ### REGISTER WATCHPOINT ### To be used only by watch element and collision managers ### */
336
336
static inline void phpdbg_store_watchpoint_btree (phpdbg_watchpoint_t * watch ) {
337
337
#if ZEND_DEBUG
338
- phpdbg_btree_result * res = phpdbg_btree_find (& PHPDBG_G (watchpoint_tree ), (zend_ulong ) watch -> addr .ptr );
338
+ phpdbg_btree_result * res = phpdbg_btree_find (& PHPDBG_G (watchpoint_tree ), (zend_ulong )( uintptr_t ) watch -> addr .ptr );
339
339
ZEND_ASSERT (res == NULL || res -> ptr == watch );
340
340
#endif
341
- phpdbg_btree_insert (& PHPDBG_G (watchpoint_tree ), (zend_ulong ) watch -> addr .ptr , watch );
341
+ phpdbg_btree_insert (& PHPDBG_G (watchpoint_tree ), (zend_ulong )( uintptr_t ) watch -> addr .ptr , watch );
342
342
}
343
343
344
344
static inline void phpdbg_remove_watchpoint_btree (phpdbg_watchpoint_t * watch ) {
345
- phpdbg_btree_delete (& PHPDBG_G (watchpoint_tree ), (zend_ulong ) watch -> addr .ptr );
345
+ phpdbg_btree_delete (& PHPDBG_G (watchpoint_tree ), (zend_ulong )( uintptr_t ) watch -> addr .ptr );
346
346
}
347
347
348
348
/* ### SET WATCHPOINT ADDR ### To be used only by watch element and collision managers ### */
@@ -394,8 +394,8 @@ void phpdbg_watch_backup_data(phpdbg_watchpoint_t *watch) {
394
394
/* watch collisions are responsible for having only one watcher on a given refcounted/refval and having a mapping back to the parent zvals */
395
395
void phpdbg_delete_watch_collision (phpdbg_watchpoint_t * watch ) {
396
396
phpdbg_watch_collision * coll ;
397
- if ((coll = zend_hash_index_find_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong ) watch -> ref ))) {
398
- zend_hash_index_del (& coll -> parents , (zend_ulong ) watch );
397
+ if ((coll = zend_hash_index_find_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong )( uintptr_t ) watch -> ref ))) {
398
+ zend_hash_index_del (& coll -> parents , (zend_ulong )( uintptr_t ) watch );
399
399
if (zend_hash_num_elements (& coll -> parents ) == 0 ) {
400
400
phpdbg_remove_watchpoint_btree (& coll -> ref );
401
401
phpdbg_deactivate_watchpoint (& coll -> ref );
@@ -411,7 +411,7 @@ void phpdbg_delete_watch_collision(phpdbg_watchpoint_t *watch) {
411
411
}
412
412
}
413
413
414
- zend_hash_index_del (& PHPDBG_G (watch_collisions ), (zend_ulong ) watch -> ref );
414
+ zend_hash_index_del (& PHPDBG_G (watch_collisions ), (zend_ulong )( uintptr_t ) watch -> ref );
415
415
zend_hash_destroy (& coll -> parents );
416
416
efree (coll );
417
417
}
@@ -433,7 +433,7 @@ void phpdbg_update_watch_ref(phpdbg_watchpoint_t *watch) {
433
433
434
434
watch -> ref = Z_COUNTED_P (watch -> addr .zv );
435
435
436
- if (!(coll = zend_hash_index_find_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong ) watch -> ref ))) {
436
+ if (!(coll = zend_hash_index_find_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong )( uintptr_t ) watch -> ref ))) {
437
437
coll = emalloc (sizeof (* coll ));
438
438
coll -> ref .type = WATCH_ON_REFCOUNTED ;
439
439
phpdbg_set_addr_watchpoint (Z_COUNTED_P (watch -> addr .zv ), sizeof (uint32_t ), & coll -> ref );
@@ -462,9 +462,9 @@ void phpdbg_update_watch_ref(phpdbg_watchpoint_t *watch) {
462
462
}
463
463
464
464
zend_hash_init (& coll -> parents , 8 , NULL , NULL , 0 );
465
- zend_hash_index_add_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong ) watch -> ref , coll );
465
+ zend_hash_index_add_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong )( uintptr_t ) watch -> ref , coll );
466
466
}
467
- zend_hash_index_add_ptr (& coll -> parents , (zend_long ) watch , watch );
467
+ zend_hash_index_add_ptr (& coll -> parents , (zend_long )( uintptr_t ) watch , watch );
468
468
} else if (Z_TYPE_P (watch -> addr .zv ) == IS_INDIRECT ) {
469
469
if ((zend_refcounted * ) Z_INDIRECT_P (watch -> addr .zv ) == watch -> ref ) {
470
470
return ;
@@ -476,7 +476,7 @@ void phpdbg_update_watch_ref(phpdbg_watchpoint_t *watch) {
476
476
477
477
watch -> ref = (zend_refcounted * ) Z_INDIRECT_P (watch -> addr .zv );
478
478
479
- if (!(coll = zend_hash_index_find_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong ) watch -> ref ))) {
479
+ if (!(coll = zend_hash_index_find_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong )( uintptr_t ) watch -> ref ))) {
480
480
coll = emalloc (sizeof (* coll ));
481
481
phpdbg_set_zval_watchpoint (Z_INDIRECT_P (watch -> addr .zv ), & coll -> ref );
482
482
coll -> ref .coll = coll ;
@@ -486,9 +486,9 @@ void phpdbg_update_watch_ref(phpdbg_watchpoint_t *watch) {
486
486
phpdbg_watch_backup_data (& coll -> ref );
487
487
488
488
zend_hash_init (& coll -> parents , 8 , NULL , NULL , 0 );
489
- zend_hash_index_add_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong ) watch -> ref , coll );
489
+ zend_hash_index_add_ptr (& PHPDBG_G (watch_collisions ), (zend_ulong )( uintptr_t ) watch -> ref , coll );
490
490
}
491
- zend_hash_index_add_ptr (& coll -> parents , (zend_long ) watch , watch );
491
+ zend_hash_index_add_ptr (& coll -> parents , (zend_long )( uintptr_t ) watch , watch );
492
492
} else if (watch -> ref ) {
493
493
phpdbg_delete_watch_collision (watch );
494
494
watch -> ref = NULL ;
@@ -505,7 +505,7 @@ void phpdbg_watch_parent_ht(phpdbg_watch_element *element);
505
505
506
506
phpdbg_watch_element * phpdbg_add_watch_element (phpdbg_watchpoint_t * watch , phpdbg_watch_element * element ) {
507
507
phpdbg_btree_result * res ;
508
- if ((res = phpdbg_btree_find (& PHPDBG_G (watchpoint_tree ), (zend_ulong ) watch -> addr .ptr )) == NULL ) {
508
+ if ((res = phpdbg_btree_find (& PHPDBG_G (watchpoint_tree ), (zend_ulong )( uintptr_t ) watch -> addr .ptr )) == NULL ) {
509
509
phpdbg_watchpoint_t * mem = emalloc (sizeof (* mem ));
510
510
* mem = * watch ;
511
511
watch = mem ;
@@ -647,12 +647,12 @@ void phpdbg_watch_parent_ht(phpdbg_watch_element *element) {
647
647
phpdbg_btree_result * res ;
648
648
phpdbg_watch_ht_info * hti ;
649
649
ZEND_ASSERT (element -> parent_container );
650
- if (!(res = phpdbg_btree_find (& PHPDBG_G (watch_HashTables ), (zend_ulong ) element -> parent_container ))) {
650
+ if (!(res = phpdbg_btree_find (& PHPDBG_G (watch_HashTables ), (zend_ulong )( uintptr_t ) element -> parent_container ))) {
651
651
hti = emalloc (sizeof (* hti ));
652
652
hti -> ht = element -> parent_container ;
653
653
654
654
zend_hash_init (& hti -> watches , 0 , NULL , ZVAL_PTR_DTOR , 0 );
655
- phpdbg_btree_insert (& PHPDBG_G (watch_HashTables ), (zend_ulong ) hti -> ht , hti );
655
+ phpdbg_btree_insert (& PHPDBG_G (watch_HashTables ), (zend_ulong )( uintptr_t ) hti -> ht , hti );
656
656
657
657
phpdbg_set_addr_watchpoint (HT_GET_DATA_ADDR (hti -> ht ), HT_HASH_SIZE (hti -> ht -> nTableMask ), & hti -> hash_watch );
658
658
hti -> hash_watch .type = WATCH_ON_HASHDATA ;
@@ -668,14 +668,14 @@ void phpdbg_watch_parent_ht(phpdbg_watch_element *element) {
668
668
669
669
void phpdbg_unwatch_parent_ht (phpdbg_watch_element * element ) {
670
670
if (element -> watch && element -> watch -> type == WATCH_ON_BUCKET ) {
671
- phpdbg_btree_result * res = phpdbg_btree_find (& PHPDBG_G (watch_HashTables ), (zend_ulong ) element -> parent_container );
671
+ phpdbg_btree_result * res = phpdbg_btree_find (& PHPDBG_G (watch_HashTables ), (zend_ulong )( uintptr_t ) element -> parent_container );
672
672
ZEND_ASSERT (element -> parent_container );
673
673
if (res ) {
674
674
phpdbg_watch_ht_info * hti = res -> ptr ;
675
675
676
676
if (zend_hash_num_elements (& hti -> watches ) == 1 ) {
677
677
zend_hash_destroy (& hti -> watches );
678
- phpdbg_btree_delete (& PHPDBG_G (watch_HashTables ), (zend_ulong ) hti -> ht );
678
+ phpdbg_btree_delete (& PHPDBG_G (watch_HashTables ), (zend_ulong )( uintptr_t ) hti -> ht );
679
679
phpdbg_remove_watchpoint_btree (& hti -> hash_watch );
680
680
phpdbg_deactivate_watchpoint (& hti -> hash_watch );
681
681
efree (hti );
@@ -712,7 +712,7 @@ void phpdbg_queue_element_for_recreation(phpdbg_watch_element *element) {
712
712
713
713
if (!element -> parent ) {
714
714
/* HERE BE DRAGONS; i.e. we assume HashTable is directly allocated via emalloc() ... (which *should be* the case for every user-accessible array and symbol tables) */
715
- zend_hash_index_add_empty_element (& PHPDBG_G (watch_free ), (zend_ulong ) element -> parent_container );
715
+ zend_hash_index_add_empty_element (& PHPDBG_G (watch_free ), (zend_ulong )( uintptr_t ) element -> parent_container );
716
716
}
717
717
}
718
718
@@ -775,7 +775,7 @@ void phpdbg_dequeue_elements_for_recreation(void) {
775
775
776
776
ZEND_HASH_MAP_FOREACH_PTR (& PHPDBG_G (watch_recreation ), element ) {
777
777
ZEND_ASSERT (element -> flags & (PHPDBG_WATCH_IMPLICIT | PHPDBG_WATCH_RECURSIVE_ROOT | PHPDBG_WATCH_SIMPLE ));
778
- if (element -> parent || zend_hash_index_find (& PHPDBG_G (watch_free ), (zend_ulong ) element -> parent_container )) {
778
+ if (element -> parent || zend_hash_index_find (& PHPDBG_G (watch_free ), (zend_ulong )( uintptr_t ) element -> parent_container )) {
779
779
zval _zv , * zv = & _zv ;
780
780
if (element -> parent ) {
781
781
ZEND_ASSERT (element -> parent -> watch -> type == WATCH_ON_ZVAL || element -> parent -> watch -> type == WATCH_ON_BUCKET );
@@ -1019,7 +1019,7 @@ void phpdbg_check_watchpoint(phpdbg_watchpoint_t *watch) {
1019
1019
zval * zv ;
1020
1020
ZEND_HASH_MAP_FOREACH_PTR (& watch -> elements , element ) {
1021
1021
if (element -> flags & PHPDBG_WATCH_RECURSIVE ) {
1022
- phpdbg_btree_result * res = phpdbg_btree_find (& PHPDBG_G (watch_HashTables ), (zend_ulong ) HT_WATCH_HT (watch ));
1022
+ phpdbg_btree_result * res = phpdbg_btree_find (& PHPDBG_G (watch_HashTables ), (zend_ulong )( uintptr_t ) HT_WATCH_HT (watch ));
1023
1023
phpdbg_watch_ht_info * hti = res ? res -> ptr : NULL ;
1024
1024
1025
1025
ZEND_HASH_REVERSE_FOREACH_KEY_VAL (HT_WATCH_HT (watch ), idx , str , zv ) {
@@ -1132,7 +1132,7 @@ void phpdbg_reenable_memory_watches(void) {
1132
1132
res = phpdbg_btree_find_closest (& PHPDBG_G (watchpoint_tree ), page + phpdbg_pagesize - 1 );
1133
1133
if (res ) {
1134
1134
watch = res -> ptr ;
1135
- if ((char * ) page < (char * ) watch -> addr .ptr + watch -> size ) {
1135
+ if ((char * )( uintptr_t ) page < (char * ) watch -> addr .ptr + watch -> size ) {
1136
1136
#ifdef HAVE_USERFAULTFD_WRITEFAULT
1137
1137
if (PHPDBG_G (watch_userfaultfd )) {
1138
1138
struct uffdio_writeprotect protect = {
@@ -1146,7 +1146,7 @@ void phpdbg_reenable_memory_watches(void) {
1146
1146
} else
1147
1147
#endif
1148
1148
{
1149
- mprotect ((void * ) page , phpdbg_pagesize , PROT_READ );
1149
+ mprotect ((void * )( uintptr_t ) page , phpdbg_pagesize , PROT_READ );
1150
1150
}
1151
1151
}
1152
1152
}
@@ -1179,7 +1179,7 @@ int phpdbg_print_changed_zvals(void) {
1179
1179
}
1180
1180
if ((res = phpdbg_btree_find_closest (& PHPDBG_G (watchpoint_tree ), page - 1 ))) {
1181
1181
watch = res -> ptr ;
1182
- if ((char * ) page < (char * ) watch -> addr .ptr + watch -> size ) {
1182
+ if ((char * )( uintptr_t ) page < (char * ) watch -> addr .ptr + watch -> size ) {
1183
1183
phpdbg_check_watchpoint (watch );
1184
1184
}
1185
1185
}
@@ -1206,7 +1206,7 @@ void phpdbg_watch_efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) {
1206
1206
1207
1207
/* only do expensive checks if there are any watches at all */
1208
1208
if (zend_hash_num_elements (& PHPDBG_G (watch_elements ))) {
1209
- if ((result = phpdbg_btree_find (& PHPDBG_G (watchpoint_tree ), (zend_ulong ) ptr ))) {
1209
+ if ((result = phpdbg_btree_find (& PHPDBG_G (watchpoint_tree ), (zend_ulong )( uintptr_t ) ptr ))) {
1210
1210
phpdbg_watchpoint_t * watch = result -> ptr ;
1211
1211
if (watch -> type != WATCH_ON_HASHDATA ) {
1212
1212
phpdbg_remove_watchpoint (watch );
@@ -1226,14 +1226,14 @@ void phpdbg_watch_efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) {
1226
1226
}
1227
1227
1228
1228
/* special case watchpoints as they aren't on ptr but on ptr + HT_WATCH_OFFSET */
1229
- if ((result = phpdbg_btree_find (& PHPDBG_G (watchpoint_tree ), HT_WATCH_OFFSET + (zend_ulong ) ptr ))) {
1229
+ if ((result = phpdbg_btree_find (& PHPDBG_G (watchpoint_tree ), HT_WATCH_OFFSET + (zend_ulong )( uintptr_t ) ptr ))) {
1230
1230
phpdbg_watchpoint_t * watch = result -> ptr ;
1231
1231
if (watch -> type == WATCH_ON_HASHTABLE ) {
1232
1232
phpdbg_remove_watchpoint (watch );
1233
1233
}
1234
1234
}
1235
1235
1236
- zend_hash_index_del (& PHPDBG_G (watch_free ), (zend_ulong ) ptr );
1236
+ zend_hash_index_del (& PHPDBG_G (watch_free ), (zend_ulong )( uintptr_t ) ptr );
1237
1237
}
1238
1238
1239
1239
if (PHPDBG_G (original_free_function )) {
0 commit comments