29
29
#include "zend_closures.h"
30
30
#include "zend_generators.h"
31
31
32
- #undef ZEND_TEST_EXCEPTIONS
33
-
34
- #if ZEND_DEBUG
35
- static zend_class_entry * zend_test_interface ;
36
- static zend_class_entry * zend_test_class ;
37
- static zend_class_entry * zend_test_trait ;
38
- static zend_object_handlers zend_test_class_handlers ;
39
- #endif
40
-
41
32
static ZEND_FUNCTION (zend_version );
42
33
static ZEND_FUNCTION (func_num_args );
43
34
static ZEND_FUNCTION (func_get_arg );
@@ -61,13 +52,6 @@ static ZEND_FUNCTION(interface_exists);
61
52
static ZEND_FUNCTION (trait_exists );
62
53
static ZEND_FUNCTION (function_exists );
63
54
static ZEND_FUNCTION (class_alias );
64
- #if ZEND_DEBUG
65
- static ZEND_FUNCTION (leak );
66
- static ZEND_FUNCTION (leak_variable );
67
- #ifdef ZEND_TEST_EXCEPTIONS
68
- static ZEND_FUNCTION (crash );
69
- #endif
70
- #endif
71
55
static ZEND_FUNCTION (get_included_files );
72
56
static ZEND_FUNCTION (is_subclass_of );
73
57
static ZEND_FUNCTION (is_a );
@@ -93,13 +77,9 @@ static ZEND_FUNCTION(get_extension_funcs);
93
77
static ZEND_FUNCTION (get_defined_constants );
94
78
static ZEND_FUNCTION (debug_backtrace );
95
79
static ZEND_FUNCTION (debug_print_backtrace );
96
- #if ZEND_DEBUG
97
- static ZEND_FUNCTION (zend_test_func );
98
- static ZEND_FUNCTION (zend_test_func2 );
99
- #ifdef ZTS
80
+ #if ZEND_DEBUG && defined(ZTS )
100
81
static ZEND_FUNCTION (zend_thread_id );
101
82
#endif
102
- #endif
103
83
static ZEND_FUNCTION (gc_mem_caches );
104
84
static ZEND_FUNCTION (gc_collect_cycles );
105
85
static ZEND_FUNCTION (gc_enabled );
@@ -199,13 +179,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_alias, 0, 0, 2)
199
179
ZEND_ARG_INFO (0 , autoload )
200
180
ZEND_END_ARG_INFO ()
201
181
202
- #if ZEND_DEBUG
203
- ZEND_BEGIN_ARG_INFO_EX (arginfo_leak_variable , 0 , 0 , 1 )
204
- ZEND_ARG_INFO (0 , variable )
205
- ZEND_ARG_INFO (0 , leak_data )
206
- ZEND_END_ARG_INFO ()
207
- #endif
208
-
209
182
ZEND_BEGIN_ARG_INFO_EX (arginfo_trigger_error , 0 , 0 , 1 )
210
183
ZEND_ARG_INFO (0 , message )
211
184
ZEND_ARG_INFO (0 , error_type )
@@ -255,70 +228,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1)
255
228
ZEND_ARG_INFO (0 , extension_name )
256
229
ZEND_END_ARG_INFO ()
257
230
258
- #if ZEND_DEBUG
259
- ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO (arginfo_zend_test_func , IS_ARRAY , 0 )
260
- ZEND_END_ARG_INFO ()
261
- ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO (arginfo_zend_test_func2 , IS_ARRAY , 1 )
262
- ZEND_END_ARG_INFO ()
263
- #endif
264
-
265
- /* }}} */
266
-
267
- #if ZEND_DEBUG
268
- static zend_object * zend_test_class_new (zend_class_entry * class_type ) /* {{{ */ {
269
- zend_object * obj = zend_objects_new (class_type );
270
- obj -> handlers = & zend_test_class_handlers ;
271
- return obj ;
272
- }
273
- /* }}} */
274
-
275
- static zend_function * zend_test_class_method_get (zend_object * * object , zend_string * name , const zval * key ) /* {{{ */ {
276
- zend_internal_function * fptr = emalloc (sizeof (zend_internal_function ));
277
- fptr -> type = ZEND_OVERLOADED_FUNCTION_TEMPORARY ;
278
- fptr -> num_args = 1 ;
279
- fptr -> arg_info = NULL ;
280
- fptr -> scope = (* object )-> ce ;
281
- fptr -> fn_flags = ZEND_ACC_CALL_VIA_HANDLER ;
282
- fptr -> function_name = zend_string_copy (name );
283
- fptr -> handler = ZEND_FN (zend_test_func );
284
- zend_set_function_arg_flags ((zend_function * )fptr );
285
-
286
- return (zend_function * )fptr ;
287
- }
288
- /* }}} */
289
-
290
- static zend_function * zend_test_class_static_method_get (zend_class_entry * ce , zend_string * name ) /* {{{ */ {
291
- zend_internal_function * fptr = emalloc (sizeof (zend_internal_function ));
292
- fptr -> type = ZEND_OVERLOADED_FUNCTION ;
293
- fptr -> num_args = 1 ;
294
- fptr -> arg_info = NULL ;
295
- fptr -> scope = ce ;
296
- fptr -> fn_flags = ZEND_ACC_CALL_VIA_HANDLER |ZEND_ACC_STATIC ;
297
- fptr -> function_name = name ;
298
- fptr -> handler = ZEND_FN (zend_test_func );
299
- zend_set_function_arg_flags ((zend_function * )fptr );
300
-
301
- return (zend_function * )fptr ;
302
- }
303
- /* }}} */
304
-
305
- static int zend_test_class_call_method (zend_string * method , zend_object * object , INTERNAL_FUNCTION_PARAMETERS ) /* {{{ */ {
306
- RETVAL_STR (zend_string_copy (method ));
307
- return 0 ;
308
- }
309
- /* }}} */
310
-
311
- static ZEND_METHOD (_ZendTestTrait , testMethod ) /* {{{ */ {
312
- RETURN_TRUE ;
313
- }
314
231
/* }}} */
315
232
316
- static zend_function_entry zend_test_trait_methods [] = {
317
- ZEND_ME (_ZendTestTrait , testMethod , arginfo_zend__void , ZEND_ACC_PUBLIC )
318
- ZEND_FE_END
319
- };
320
- #endif
321
-
322
233
static const zend_function_entry builtin_functions [] = { /* {{{ */
323
234
ZEND_FE (zend_version , arginfo_zend__void )
324
235
ZEND_FE (func_num_args , arginfo_zend__void )
@@ -343,13 +254,6 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
343
254
ZEND_FE (trait_exists , arginfo_trait_exists )
344
255
ZEND_FE (function_exists , arginfo_function_exists )
345
256
ZEND_FE (class_alias , arginfo_class_alias )
346
- #if ZEND_DEBUG
347
- ZEND_FE (leak , NULL )
348
- ZEND_FE (leak_variable , arginfo_leak_variable )
349
- #ifdef ZEND_TEST_EXCEPTIONS
350
- ZEND_FE (crash , NULL )
351
- #endif
352
- #endif
353
257
ZEND_FE (get_included_files , arginfo_zend__void )
354
258
ZEND_FALIAS (get_required_files , get_included_files , arginfo_zend__void )
355
259
ZEND_FE (is_subclass_of , arginfo_is_subclass_of )
@@ -377,12 +281,8 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
377
281
ZEND_FE (get_defined_constants , arginfo_get_defined_constants )
378
282
ZEND_FE (debug_backtrace , arginfo_debug_backtrace )
379
283
ZEND_FE (debug_print_backtrace , arginfo_debug_print_backtrace )
380
- #if ZEND_DEBUG
381
- ZEND_FE (zend_test_func , arginfo_zend_test_func )
382
- ZEND_FE (zend_test_func2 , arginfo_zend_test_func2 )
383
- #ifdef ZTS
284
+ #if ZEND_DEBUG && defined (ZTS )
384
285
ZEND_FE (zend_thread_id , NULL )
385
- #endif
386
286
#endif
387
287
ZEND_FE (gc_mem_caches , arginfo_zend__void )
388
288
ZEND_FE (gc_collect_cycles , arginfo_zend__void )
@@ -401,26 +301,6 @@ ZEND_MINIT_FUNCTION(core) { /* {{{ */
401
301
402
302
zend_register_default_classes ();
403
303
404
- #if ZEND_DEBUG
405
- INIT_CLASS_ENTRY (class_entry , "_ZendTestInterface" , NULL );
406
- zend_test_interface = zend_register_internal_interface (& class_entry );
407
- zend_declare_class_constant_long (zend_test_interface , ZEND_STRL ("DUMMY" ), 0 );
408
- INIT_CLASS_ENTRY (class_entry , "_ZendTestClass" , NULL );
409
- zend_test_class = zend_register_internal_class_ex (& class_entry , NULL );
410
- zend_class_implements (zend_test_class , 1 , zend_test_interface );
411
- zend_test_class -> create_object = zend_test_class_new ;
412
- zend_test_class -> get_static_method = zend_test_class_static_method_get ;
413
-
414
- memcpy (& zend_test_class_handlers , zend_get_std_object_handlers (), sizeof (zend_object_handlers ));
415
- zend_test_class_handlers .get_method = zend_test_class_method_get ;
416
- zend_test_class_handlers .call_method = zend_test_class_call_method ;
417
-
418
- INIT_CLASS_ENTRY (class_entry , "_ZendTestTrait" , zend_test_trait_methods );
419
- zend_test_trait = zend_register_internal_class (& class_entry );
420
- zend_test_trait -> ce_flags |= ZEND_ACC_TRAIT ;
421
- zend_declare_property_null (zend_test_trait , "testProp" , sizeof ("testProp" )- 1 , ZEND_ACC_PUBLIC );
422
- #endif
423
-
424
304
return SUCCESS ;
425
305
}
426
306
/* }}} */
@@ -1653,63 +1533,6 @@ ZEND_FUNCTION(class_alias)
1653
1533
}
1654
1534
/* }}} */
1655
1535
1656
- #if ZEND_DEBUG
1657
- /* {{{ proto void leak([int num_bytes])
1658
- Cause an intentional memory leak, for testing/debugging purposes */
1659
- ZEND_FUNCTION (leak )
1660
- {
1661
- zend_long leakbytes = 3 ;
1662
-
1663
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "|l" , & leakbytes ) == FAILURE ) {
1664
- return ;
1665
- }
1666
-
1667
- emalloc (leakbytes );
1668
- }
1669
- /* }}} */
1670
-
1671
- /* {{{ proto void leak_variable(mixed variable [, bool leak_data])
1672
- Leak a variable that is a resource or an object */
1673
- ZEND_FUNCTION (leak_variable )
1674
- {
1675
- zval * zv ;
1676
- zend_bool leak_data = 0 ;
1677
-
1678
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "z|b" , & zv , & leak_data ) == FAILURE ) {
1679
- return ;
1680
- }
1681
-
1682
- if (!leak_data ) {
1683
- Z_ADDREF_P (zv );
1684
- } else if (Z_TYPE_P (zv ) == IS_RESOURCE ) {
1685
- Z_ADDREF_P (zv );
1686
- } else if (Z_TYPE_P (zv ) == IS_OBJECT ) {
1687
- Z_ADDREF_P (zv );
1688
- } else {
1689
- zend_error (E_WARNING , "Leaking non-zval data is only applicable to resources and objects" );
1690
- }
1691
- }
1692
- /* }}} */
1693
-
1694
-
1695
- #ifdef ZEND_TEST_EXCEPTIONS
1696
- /* {{{ proto void crash(void)
1697
- Crash the script */
1698
- ZEND_FUNCTION (crash )
1699
- {
1700
- char * nowhere = NULL ;
1701
-
1702
- if (zend_parse_parameters_none () == FAILURE ) {
1703
- return ;
1704
- }
1705
-
1706
- memcpy (nowhere , "something" , sizeof ("something" ));
1707
- }
1708
- /* }}} */
1709
- #endif
1710
-
1711
- #endif /* ZEND_DEBUG */
1712
-
1713
1536
/* {{{ proto array get_included_files(void)
1714
1537
Returns an array with the file names that were include_once()'d */
1715
1538
ZEND_FUNCTION (get_included_files )
@@ -2095,28 +1918,12 @@ ZEND_FUNCTION(create_function)
2095
1918
}
2096
1919
/* }}} */
2097
1920
2098
- #if ZEND_DEBUG
2099
- ZEND_FUNCTION (zend_test_func )
2100
- {
2101
- zval * arg1 , * arg2 ;
2102
-
2103
- zend_parse_parameters (ZEND_NUM_ARGS (), "|zz" , & arg1 , & arg2 );
2104
- }
2105
-
2106
- ZEND_FUNCTION (zend_test_func2 )
2107
- {
2108
- zval * arg1 , * arg2 ;
2109
-
2110
- zend_parse_parameters (ZEND_NUM_ARGS (), "|zz" , & arg1 , & arg2 );
2111
- }
2112
-
2113
- #ifdef ZTS
1921
+ #if ZEND_DEBUG && defined(ZTS )
2114
1922
ZEND_FUNCTION (zend_thread_id )
2115
1923
{
2116
1924
RETURN_LONG ((zend_long )tsrm_thread_id ());
2117
1925
}
2118
1926
#endif
2119
- #endif
2120
1927
2121
1928
/* {{{ proto string get_resource_type(resource res)
2122
1929
Get the resource type name for a given resource */
0 commit comments