php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
phpdbg_sigsafe.c
Go to the documentation of this file.
1#include "phpdbg_sigsafe.h"
2#include "phpdbg.h"
3
5
6#define STR(x) #x
7#define EXP_STR(x) STR(x)
8
9static void* zend_mm_mem_alloc(zend_mm_storage *storage, size_t size, size_t alignment) {
10
12 PHPDBG_G(sigsafe_mem).allocated = 1;
13 return (void *) (((size_t) PHPDBG_G(sigsafe_mem).mem & ~(alignment - 1)) + alignment);
14 }
15
16 zend_quiet_write(PHPDBG_G(io)[PHPDBG_STDERR].fd, ZEND_STRL("Tried to allocate more than " EXP_STR(PHPDBG_SIGSAFE_MEM_SIZE) " bytes from stack memory in signal handler ... bailing out of signal handler\n"));
17
18 if (*EG(bailout)) {
20 }
21
22 zend_quiet_write(PHPDBG_G(io)[PHPDBG_STDERR].fd, ZEND_STRL("Bailed out without a bailout address in signal handler!\n"));
23
24 return NULL;
25}
26
27static void zend_mm_mem_free(zend_mm_storage *storage, void *ptr, size_t size) {
28}
29
32 const zend_mm_handlers phpdbg_handlers = {
33 zend_mm_mem_alloc,
34 zend_mm_mem_free,
35 NULL,
36 NULL,
37 };
38
39 mem->mem = buffer;
40 mem->allocated = 0;
41
42 mem->heap = zend_mm_startup_ex(&phpdbg_handlers, NULL, 0);
43
44 mem->old_heap = zend_mm_set_heap(mem->heap);
45}
46
50
55
57 return !!PHPDBG_G(sigsafe_mem).mem;
58}
Definition test.php:8
new_type size
Definition ffi.c:4365
void * ptr
Definition ffi.c:3814
#define NULL
Definition gdcache.h:45
JMP_BUF bailout
Definition php_ffi.h:49
struct @234323133100145062121301312242002332057146367313 io[PHPDBG_IO_FDS]
#define PHPDBG_G(v)
Definition phpdbg.h:102
int fd
Definition phpdbg.h:282
#define PHPDBG_STDERR
Definition phpdbg.h:191
phpdbg_signal_safe_mem sigsafe_mem
Definition phpdbg.h:304
zend_mm_heap * phpdbg_original_heap_sigsafe_mem(void)
void phpdbg_clear_sigsafe_mem(void)
#define EXP_STR(x)
void phpdbg_set_sigsafe_mem(char *buffer)
bool phpdbg_active_sigsafe_mem(void)
#define PHPDBG_SIGSAFE_MEM_SIZE
Definition file.h:177
zend_mm_heap * old_heap
#define ZEND_EXTERN_MODULE_GLOBALS(module_name)
Definition zend_API.h:270
ZEND_API zend_mm_heap * zend_mm_startup_ex(const zend_mm_handlers *handlers, void *data, size_t data_size)
ZEND_API zend_mm_heap * zend_mm_set_heap(zend_mm_heap *new_heap)
struct _zend_mm_storage zend_mm_storage
Definition zend_alloc.h:297
struct _zend_mm_handlers zend_mm_handlers
struct _zend_mm_heap zend_mm_heap
Definition zend_alloc.h:244
#define EG(v)
#define zend_quiet_write(...)
#define EXPECTED(condition)
#define LONGJMP(a, b)
#define ZEND_STRL(str)
@ FAILURE
Definition zend_types.h:61