@@ -189,6 +189,7 @@ static void (*old_zend_execute_internal)(zend_execute_data *execute_data_ptr, zv
189
189
static PHP_INI_MH ((* origOnChangeMemoryLimit )) = NULL ;
190
190
191
191
static int memprof_enabled = 0 ;
192
+ static int memprof_dumped = 0 ;
192
193
static int track_mallocs = 0 ;
193
194
194
195
static frame default_frame ;
@@ -719,6 +720,7 @@ static void memprof_enable()
719
720
MALLOC_HOOK_SET_OWN ();
720
721
721
722
memprof_enabled = 1 ;
723
+ memprof_dumped = 0 ;
722
724
723
725
if (is_zend_mm ()) {
724
726
/* There is no way to completely free a zend_mm_heap with custom
@@ -763,6 +765,10 @@ static void memprof_disable()
763
765
764
766
JudyLFreeArray (& allocs_set , PJE0 );
765
767
allocs_set = (Pvoid_t ) NULL ;
768
+
769
+ if (!memprof_dumped ) {
770
+ zend_error (E_WARNING , "Memprof profiling was enabled, but no profile was dumped. Did you forget to call one of memprof_dump_callgrind(), memprof_dump_pprof(), or memprof_dump_array() ?" );
771
+ }
766
772
}
767
773
768
774
static void disable_opcache ()
@@ -1244,7 +1250,7 @@ PHP_FUNCTION(memprof_dump_array)
1244
1250
}
1245
1251
1246
1252
if (!memprof_enabled ) {
1247
- zend_throw_exception (EG (exception_class ), "memprof is not enabled" , 0 );
1253
+ zend_throw_exception (EG (exception_class ), "memprof_dump_array(): memprof is not enabled" , 0 );
1248
1254
return ;
1249
1255
}
1250
1256
@@ -1253,6 +1259,8 @@ PHP_FUNCTION(memprof_dump_array)
1253
1259
dump_frame_array (return_value , & default_frame );
1254
1260
1255
1261
} END_WITHOUT_MALLOC_TRACKING ;
1262
+
1263
+ memprof_dumped = 1 ;
1256
1264
}
1257
1265
/* }}} */
1258
1266
@@ -1270,7 +1278,7 @@ PHP_FUNCTION(memprof_dump_callgrind)
1270
1278
}
1271
1279
1272
1280
if (!memprof_enabled ) {
1273
- zend_throw_exception (EG (exception_class ), "memprof is not enabled" , 0 );
1281
+ zend_throw_exception (EG (exception_class ), "memprof_dump_callgrind(): memprof is not enabled" , 0 );
1274
1282
return ;
1275
1283
}
1276
1284
@@ -1289,6 +1297,8 @@ PHP_FUNCTION(memprof_dump_callgrind)
1289
1297
stream_printf (stream , "total: %zu %zu\n" , total_size , total_count );
1290
1298
1291
1299
} END_WITHOUT_MALLOC_TRACKING ;
1300
+
1301
+ memprof_dumped = 1 ;
1292
1302
}
1293
1303
/* }}} */
1294
1304
@@ -1305,7 +1315,7 @@ PHP_FUNCTION(memprof_dump_pprof)
1305
1315
}
1306
1316
1307
1317
if (!memprof_enabled ) {
1308
- zend_throw_exception (EG (exception_class ), "memprof is not enabled" , 0 );
1318
+ zend_throw_exception (EG (exception_class ), "memprof_dump_pprof(): memprof is not enabled" , 0 );
1309
1319
return ;
1310
1320
}
1311
1321
@@ -1341,6 +1351,8 @@ PHP_FUNCTION(memprof_dump_pprof)
1341
1351
zend_hash_destroy (& symbols );
1342
1352
1343
1353
} END_WITHOUT_MALLOC_TRACKING ;
1354
+
1355
+ memprof_dumped = 1 ;
1344
1356
}
1345
1357
/* }}} */
1346
1358
@@ -1393,7 +1405,7 @@ PHP_FUNCTION(memprof_enable)
1393
1405
}
1394
1406
1395
1407
if (memprof_enabled ) {
1396
- zend_throw_exception (EG (exception_class ), "memprof is already enabled" , 0 );
1408
+ zend_throw_exception (EG (exception_class ), "memprof_enable(): memprof is already enabled" , 0 );
1397
1409
return ;
1398
1410
}
1399
1411
@@ -1414,7 +1426,7 @@ PHP_FUNCTION(memprof_disable)
1414
1426
}
1415
1427
1416
1428
if (!memprof_enabled ) {
1417
- zend_throw_exception (EG (exception_class ), "memprof is not enabled" , 0 );
1429
+ zend_throw_exception (EG (exception_class ), "memprof_disable(): memprof is not enabled" , 0 );
1418
1430
return ;
1419
1431
}
1420
1432
0 commit comments