2020-09-01 23:57:49 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Levi Morrison <levim@php.net> |
|
|
|
|
| Sammy Kaye Powers <sammyk@php.net> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEND_OBSERVER_H
|
|
|
|
#define ZEND_OBSERVER_H
|
|
|
|
|
|
|
|
#include "zend.h"
|
|
|
|
#include "zend_compile.h"
|
2021-04-27 00:07:06 +08:00
|
|
|
#include "zend_fibers.h"
|
2020-09-01 23:57:49 +08:00
|
|
|
|
|
|
|
BEGIN_EXTERN_C()
|
|
|
|
|
|
|
|
extern ZEND_API int zend_observer_fcall_op_array_extension;
|
|
|
|
|
|
|
|
#define ZEND_OBSERVER_ENABLED (zend_observer_fcall_op_array_extension != -1)
|
|
|
|
|
2020-09-18 17:55:58 +08:00
|
|
|
#define ZEND_OBSERVER_FCALL_BEGIN(execute_data) do { \
|
|
|
|
if (ZEND_OBSERVER_ENABLED) { \
|
|
|
|
zend_observer_fcall_begin(execute_data); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZEND_OBSERVER_FCALL_END(execute_data, return_value) do { \
|
|
|
|
if (ZEND_OBSERVER_ENABLED) { \
|
|
|
|
zend_observer_fcall_end(execute_data, return_value); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
typedef void (*zend_observer_fcall_begin_handler)(zend_execute_data *execute_data);
|
|
|
|
typedef void (*zend_observer_fcall_end_handler)(zend_execute_data *execute_data, zval *retval);
|
|
|
|
|
|
|
|
typedef struct _zend_observer_fcall_handlers {
|
|
|
|
zend_observer_fcall_begin_handler begin;
|
|
|
|
zend_observer_fcall_end_handler end;
|
|
|
|
} zend_observer_fcall_handlers;
|
2020-09-01 23:57:49 +08:00
|
|
|
|
|
|
|
/* If the fn should not be observed then return {NULL, NULL} */
|
2020-09-25 03:57:43 +08:00
|
|
|
typedef zend_observer_fcall_handlers (*zend_observer_fcall_init)(zend_execute_data *execute_data);
|
2020-09-01 23:57:49 +08:00
|
|
|
|
|
|
|
// Call during minit/startup ONLY
|
2020-09-18 17:55:58 +08:00
|
|
|
ZEND_API void zend_observer_fcall_register(zend_observer_fcall_init);
|
2020-09-01 23:57:49 +08:00
|
|
|
|
|
|
|
ZEND_API void zend_observer_startup(void); // Called by engine before MINITs
|
|
|
|
ZEND_API void zend_observer_activate(void);
|
|
|
|
ZEND_API void zend_observer_deactivate(void);
|
|
|
|
ZEND_API void zend_observer_shutdown(void);
|
|
|
|
|
2020-09-18 17:55:58 +08:00
|
|
|
ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin(
|
2020-09-01 23:57:49 +08:00
|
|
|
zend_execute_data *execute_data);
|
|
|
|
|
2020-09-18 17:55:58 +08:00
|
|
|
ZEND_API void ZEND_FASTCALL zend_observer_generator_resume(
|
|
|
|
zend_execute_data *execute_data);
|
2020-09-01 23:57:49 +08:00
|
|
|
|
2020-09-18 17:55:58 +08:00
|
|
|
ZEND_API void ZEND_FASTCALL zend_observer_fcall_end(
|
2020-09-01 23:57:49 +08:00
|
|
|
zend_execute_data *execute_data,
|
|
|
|
zval *return_value);
|
|
|
|
|
2020-10-24 02:43:31 +08:00
|
|
|
ZEND_API void zend_observer_fcall_end_all(void);
|
|
|
|
|
2021-04-23 16:47:08 +08:00
|
|
|
typedef void (*zend_observer_error_cb)(int type, zend_string *error_filename, uint32_t error_lineno, zend_string *message);
|
2020-09-14 20:05:54 +08:00
|
|
|
|
|
|
|
ZEND_API void zend_observer_error_register(zend_observer_error_cb callback);
|
2021-04-23 16:47:08 +08:00
|
|
|
void zend_observer_error_notify(int type, zend_string *error_filename, uint32_t error_lineno, zend_string *message);
|
2020-09-14 20:05:54 +08:00
|
|
|
|
2021-07-21 23:18:15 +08:00
|
|
|
typedef void (*zend_observer_fiber_init_handler)(zend_fiber_context *initializing);
|
2021-06-05 12:25:35 +08:00
|
|
|
typedef void (*zend_observer_fiber_switch_handler)(zend_fiber_context *from, zend_fiber_context *to);
|
2021-07-21 23:18:15 +08:00
|
|
|
typedef void (*zend_observer_fiber_destroy_handler)(zend_fiber_context *destroying);
|
2021-04-27 00:07:06 +08:00
|
|
|
|
2021-07-21 23:18:15 +08:00
|
|
|
ZEND_API void zend_observer_fiber_init_register(zend_observer_fiber_init_handler handler);
|
2021-04-27 00:07:06 +08:00
|
|
|
ZEND_API void zend_observer_fiber_switch_register(zend_observer_fiber_switch_handler handler);
|
2021-07-21 23:18:15 +08:00
|
|
|
ZEND_API void zend_observer_fiber_destroy_register(zend_observer_fiber_destroy_handler handler);
|
|
|
|
|
|
|
|
ZEND_API void ZEND_FASTCALL zend_observer_fiber_init_notify(zend_fiber_context *initializing);
|
2021-06-05 12:25:35 +08:00
|
|
|
ZEND_API void ZEND_FASTCALL zend_observer_fiber_switch_notify(zend_fiber_context *from, zend_fiber_context *to);
|
2021-07-21 23:18:15 +08:00
|
|
|
ZEND_API void ZEND_FASTCALL zend_observer_fiber_destroy_notify(zend_fiber_context *destroying);
|
2021-04-27 00:07:06 +08:00
|
|
|
|
2020-09-01 23:57:49 +08:00
|
|
|
END_EXTERN_C()
|
|
|
|
|
|
|
|
#endif /* ZEND_OBSERVER_H */
|