1
0
mirror of https://github.com/php/php-src.git synced 2026-03-31 12:42:29 +02:00

Committed the damned new files

This commit is contained in:
Bob Weinand
2013-12-11 21:31:22 +01:00
parent 488dd317fe
commit 2e5d78192e
2 changed files with 112 additions and 0 deletions

69
phpdbg_watch.c Normal file
View File

@@ -0,0 +1,69 @@
#include "zend.h"
#include "phpdbg.h"
#include "phpdbg_watch.h"
#include <unistd.h>
#include <sys/mman.h>
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
long phpdbg_pagesize;
void phpdbg_setup_watchpoints() {
#ifdef _SC_PAGE_SIZE
phpdbg_pagesize = sysconf(_SC_PAGE_SIZE);
#endif
#ifdef _SC_PAGESIZE
phpdbg_pagesize = sysconf(_SC_PAGESIZE);
#endif
#ifdef _SC_NUTC_OS_PAGESIZE
phpdbg_pagesize = sysconf(_SC_NUTC_OS_PAGESIZE);
#endif
}
int phpdbg_check_for_watchpoint(void *addr) {
return FAILURE;
}
int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context TSRMLS_DC) {
printf("Text");
return FAILURE;
}
void phpdbg_create_addr_watchpoint(void *addr, size_t size) {
int m;
/* pagesize is assumed to be in the range of 2^x */
m= mprotect((void *)((unsigned long)addr & ~(phpdbg_pagesize - 1)), ((size - 1) & ~(phpdbg_pagesize - 1)) | phpdbg_pagesize, PROT_NONE | PROT_READ);
printf("\n!!!!!\n%d\n!!!!!\n", m);
}
void phpdbg_create_zval_watchpoint(zval *zv) {
phpdbg_create_addr_watchpoint(zv, sizeof(zval));
}
int phpdbg_create_var_watchpoint(char *name, size_t len TSRMLS_DC) {
zval *zv;
if (!EG(active_op_array)) {
phpdbg_error("No active op array!");
return SUCCESS;
}
if (!EG(active_symbol_table)) {
zend_rebuild_symbol_table(TSRMLS_C);
if (!EG(active_symbol_table)) {
phpdbg_error("No active symbol table!");
return SUCCESS;
}
}
/* Lookup current symbol table */
if (zend_hash_find(EG(current_execute_data)->symbol_table, name, len + 1, (void **)&zv) == SUCCESS) {
phpdbg_create_zval_watchpoint(zv);
return SUCCESS;
}
return FAILURE;
}

43
phpdbg_watch.h Normal file
View File

@@ -0,0 +1,43 @@
#ifndef PHPDBG_WATCH_H
#define PHPDBG_WATCH_H
#include "TSRM.h"
#include "phpdbg_cmd.h"
#define PHPDBG_WATCH(name) PHPDBG_COMMAND(watch_##name)
/**
* Printer Forward Declarations
*/
/*PHPDBG_WATCH();*/
/* Watchpoint functions/typedefs */
typedef enum {
WATCH_ON_ZVAL,
WATCH_ON_HASHTABLE,
WATCH_ON_PTR
} phpdbg_watchtype;
typedef struct _phpdbg_watchpoint_t phpdbg_watchpoint_t;
struct _phpdbg_watchpoint_t {
phpdbg_watchpoint_t *parent;
char *str;
union {
zval *zv;
HashTable *ht;
void *ptr;
} addr;
int size;
phpdbg_watchtype type;
};
void phpdbg_setup_watchpoints();
int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context TSRMLS_DC);
int phpdbg_create_var_watchpoint(char *name, size_t len TSRMLS_DC);
#endif