com php-src: Committed the damned new files: phpdbg_watch.c phpdbg_watch.h
| From: | Bob Weinand | Date: | Wed, 11 Dec 2013 20:31:22 +0000 |
| Subject: | com php-src: Committed the damned new files: phpdbg_watch.c phpdbg_watch.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77114@lists.php.net to get a copy of this message | ||
Commit: 2e5d78192eb4727dff34aba9275cd4dc9230f38c
Author: Bob Weinand <bobwei9@hotmail.com> Wed, 11 Dec 2013 21:31:22 +0100
Parents: 488dd317feacd0ea3a9419e80eb8183ff2879c91
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2e5d78192eb4727dff34aba9275cd4dc9230f38c
Log:
Committed the damned new files
Changed paths:
A phpdbg_watch.c
A phpdbg_watch.h
Diff:
diff --git a/phpdbg_watch.c b/phpdbg_watch.c
new file mode 100644
index 0000000..e54431f
--- /dev/null
+++ b/phpdbg_watch.c
@@ -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;
+}
diff --git a/phpdbg_watch.h b/phpdbg_watch.h
new file mode 100644
index 0000000..3d14207
--- /dev/null
+++ b/phpdbg_watch.h
@@ -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