summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg.h
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/phpdbg/phpdbg.h')
-rw-r--r--sapi/phpdbg/phpdbg.h250
1 files changed, 90 insertions, 160 deletions
diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h
index a0ba75e4d4..eb4faf1f94 100644
--- a/sapi/phpdbg/phpdbg.h
+++ b/sapi/phpdbg/phpdbg.h
@@ -21,8 +21,6 @@
#ifndef PHPDBG_H
#define PHPDBG_H
-#define PHPDBG_IN_DEV 0
-
#ifdef PHP_WIN32
# define PHPDBG_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
@@ -31,12 +29,6 @@
# define PHPDBG_API
#endif
-#ifndef PHP_WIN32
-# include <stdint.h>
-# include <stddef.h>
-#else
-# include "win32/php_stdint.h"
-#endif
#include "php.h"
#include "php_globals.h"
#include "php_variables.h"
@@ -48,20 +40,20 @@
#include "zend_ini_scanner.h"
#include "zend_stream.h"
#ifndef _WIN32
-# include "zend_signal.h"
+# include "zend_signal.h"
#endif
#include "SAPI.h"
#include <fcntl.h>
#include <sys/types.h>
#if defined(_WIN32) && !defined(__MINGW32__)
-# include <windows.h>
-# include "config.w32.h"
-# undef strcasecmp
-# undef strncasecmp
-# define strcasecmp _stricmp
-# define strncasecmp _strnicmp
+# include <windows.h>
+# include "config.w32.h"
+# undef strcasecmp
+# undef strncasecmp
+# define strcasecmp _stricmp
+# define strncasecmp _strnicmp
#else
-# include "php_config.h"
+# include "php_config.h"
#endif
#ifndef O_BINARY
# define O_BINARY 0
@@ -72,62 +64,28 @@
# include "TSRM.h"
#endif
-#ifdef HAVE_LIBREADLINE
-# include <readline/readline.h>
-# include <readline/history.h>
+#ifdef LIBREADLINE
+# include <readline/readline.h>
+# include <readline/history.h>
#endif
#ifdef HAVE_LIBEDIT
-# include <editline/readline.h>
+# include <editline/readline.h>
#endif
-/* {{{ remote console headers */
-#ifndef _WIN32
-# include <sys/socket.h>
-# include <sys/un.h>
-# include <sys/select.h>
-# include <sys/types.h>
-# include <netdb.h>
-#endif /* }}} */
-
-/* {{{ strings */
-#define PHPDBG_NAME "phpdbg"
-#define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */
-#define PHPDBG_URL "http://phpdbg.com"
-#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues"
-#define PHPDBG_VERSION "0.4.0"
-#define PHPDBG_INIT_FILENAME ".phpdbginit"
-#define PHPDBG_DEFAULT_PROMPT "prompt>"
-/* }}} */
-
-/* Hey, apple. One shouldn't define *functions* from the standard C library as marcos. */
-#ifdef memcpy
-#define memcpy_tmp(...) memcpy(__VA_ARGS__)
-#undef memcpy
-#define memcpy(...) memcpy_tmp(__VA_ARGS__)
-#endif
-
-#if !defined(PHPDBG_WEBDATA_TRANSFER_H) && !defined(PHPDBG_WEBHELPER_H)
-
-#ifdef ZTS
-# define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v)
-#else
-# define PHPDBG_G(v) (phpdbg_globals.v)
-#endif
-
-#include "phpdbg_sigsafe.h"
-#include "phpdbg_out.h"
#include "phpdbg_lexer.h"
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
#include "phpdbg_btree.h"
#include "phpdbg_watch.h"
-#include "phpdbg_bp.h"
-#ifdef PHP_WIN32
-# include "phpdbg_sigio_win32.h"
-#endif
int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
+#ifdef ZTS
+# define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v)
+#else
+# define PHPDBG_G(v) (phpdbg_globals.v)
+#endif
+
#define PHPDBG_NEXT 2
#define PHPDBG_UNTIL 3
#define PHPDBG_FINISH 4
@@ -137,87 +95,84 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
BEGIN: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE
*/
+/* {{{ tables */
+#define PHPDBG_BREAK_FILE 0
+#define PHPDBG_BREAK_SYM 1
+#define PHPDBG_BREAK_OPLINE 2
+#define PHPDBG_BREAK_METHOD 3
+#define PHPDBG_BREAK_COND 4
+#define PHPDBG_BREAK_OPCODE 5
+#define PHPDBG_BREAK_FUNCTION_OPLINE 6
+#define PHPDBG_BREAK_METHOD_OPLINE 7
+#define PHPDBG_BREAK_FILE_OPLINE 8
+#define PHPDBG_BREAK_MAP 9
+#define PHPDBG_BREAK_TABLES 10 /* }}} */
+
/* {{{ flags */
-#define PHPDBG_HAS_FILE_BP (1ULL<<1)
-#define PHPDBG_HAS_PENDING_FILE_BP (1ULL<<2)
-#define PHPDBG_HAS_SYM_BP (1ULL<<3)
-#define PHPDBG_HAS_OPLINE_BP (1ULL<<4)
-#define PHPDBG_HAS_METHOD_BP (1ULL<<5)
-#define PHPDBG_HAS_COND_BP (1ULL<<6)
-#define PHPDBG_HAS_OPCODE_BP (1ULL<<7)
-#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1ULL<<8)
-#define PHPDBG_HAS_METHOD_OPLINE_BP (1ULL<<9)
-#define PHPDBG_HAS_FILE_OPLINE_BP (1ULL<<10) /* }}} */
+#define PHPDBG_HAS_FILE_BP (1<<1)
+#define PHPDBG_HAS_SYM_BP (1<<2)
+#define PHPDBG_HAS_OPLINE_BP (1<<3)
+#define PHPDBG_HAS_METHOD_BP (1<<4)
+#define PHPDBG_HAS_COND_BP (1<<5)
+#define PHPDBG_HAS_OPCODE_BP (1<<6)
+#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1<<7)
+#define PHPDBG_HAS_METHOD_OPLINE_BP (1<<8)
+#define PHPDBG_HAS_FILE_OPLINE_BP (1<<9) /* }}} */
/*
END: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE
*/
-#define PHPDBG_IN_COND_BP (1ULL<<11)
-#define PHPDBG_IN_EVAL (1ULL<<12)
-
-#define PHPDBG_IS_STEPPING (1ULL<<13)
-#define PHPDBG_STEP_OPCODE (1ULL<<14)
-#define PHPDBG_IS_QUIET (1ULL<<15)
-#define PHPDBG_IS_QUITTING (1ULL<<16)
-#define PHPDBG_IS_COLOURED (1ULL<<17)
-#define PHPDBG_IS_CLEANING (1ULL<<18)
-#define PHPDBG_IS_RUNNING (1ULL<<19)
+#define PHPDBG_IN_COND_BP (1<<10)
+#define PHPDBG_IN_EVAL (1<<11)
-#define PHPDBG_IN_UNTIL (1ULL<<20)
-#define PHPDBG_IN_FINISH (1ULL<<21)
-#define PHPDBG_IN_LEAVE (1ULL<<22)
+#define PHPDBG_IS_STEPPING (1<<12)
+#define PHPDBG_STEP_OPCODE (1<<13)
+#define PHPDBG_IS_QUIET (1<<14)
+#define PHPDBG_IS_QUITTING (1<<15)
+#define PHPDBG_IS_COLOURED (1<<16)
+#define PHPDBG_IS_CLEANING (1<<17)
-#define PHPDBG_IS_REGISTERED (1ULL<<23)
-#define PHPDBG_IS_STEPONEVAL (1ULL<<24)
-#define PHPDBG_IS_INITIALIZING (1ULL<<25)
-#define PHPDBG_IS_SIGNALED (1ULL<<26)
-#define PHPDBG_IS_INTERACTIVE (1ULL<<27)
-#define PHPDBG_IS_BP_ENABLED (1ULL<<28)
-#define PHPDBG_IS_REMOTE (1ULL<<29)
-#define PHPDBG_IS_DISCONNECTED (1ULL<<30)
-#define PHPDBG_WRITE_XML (1ULL<<31)
+#define PHPDBG_IN_UNTIL (1<<18)
+#define PHPDBG_IN_FINISH (1<<19)
+#define PHPDBG_IN_LEAVE (1<<20)
-#define PHPDBG_SHOW_REFCOUNTS (1ULL<<32)
+#define PHPDBG_IS_REGISTERED (1<<21)
+#define PHPDBG_IS_STEPONEVAL (1<<22)
+#define PHPDBG_IS_INITIALIZING (1<<23)
+#define PHPDBG_IS_SIGNALED (1<<24)
+#define PHPDBG_IS_INTERACTIVE (1<<25)
+#define PHPDBG_IS_BP_ENABLED (1<<26)
+#define PHPDBG_IS_REMOTE (1<<27)
+#define PHPDBG_IS_DISCONNECTED (1<<28)
-#define PHPDBG_IN_SIGNAL_HANDLER (1ULL<<33)
+#define PHPDBG_SHOW_REFCOUNTS (1<<29)
-#define PHPDBG_DISCARD_OUTPUT (1ULL<<34)
-
-#define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL | PHPDBG_IN_FINISH | PHPDBG_IN_LEAVE)
-#define PHPDBG_BP_RESOLVE_MASK (PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
-#define PHPDBG_BP_MASK (PHPDBG_HAS_FILE_BP | PHPDBG_HAS_SYM_BP | PHPDBG_HAS_METHOD_BP | PHPDBG_HAS_OPLINE_BP | PHPDBG_HAS_COND_BP | PHPDBG_HAS_OPCODE_BP | PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
-#define PHPDBG_IS_STOPPING (PHPDBG_IS_QUITTING | PHPDBG_IS_CLEANING)
-
-#define PHPDBG_PRESERVE_FLAGS_MASK (PHPDBG_SHOW_REFCOUNTS | PHPDBG_IS_STEPONEVAL | PHPDBG_IS_BP_ENABLED | PHPDBG_STEP_OPCODE | PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_REMOTE | PHPDBG_WRITE_XML | PHPDBG_IS_DISCONNECTED)
+#define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL|PHPDBG_IN_FINISH|PHPDBG_IN_LEAVE)
+#define PHPDBG_BP_RESOLVE_MASK (PHPDBG_HAS_FUNCTION_OPLINE_BP|PHPDBG_HAS_METHOD_OPLINE_BP|PHPDBG_HAS_FILE_OPLINE_BP)
+#define PHPDBG_BP_MASK (PHPDBG_HAS_FILE_BP|PHPDBG_HAS_SYM_BP|PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_OPLINE_BP|PHPDBG_HAS_COND_BP|PHPDBG_HAS_OPCODE_BP|PHPDBG_HAS_FUNCTION_OPLINE_BP|PHPDBG_HAS_METHOD_OPLINE_BP|PHPDBG_HAS_FILE_OPLINE_BP)
#ifndef _WIN32
-# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED)
+# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED)
#else
-# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_BP_ENABLED)
+# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED)
#endif /* }}} */
+/* {{{ strings */
+#define PHPDBG_NAME "phpdbg"
+#define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */
+#define PHPDBG_URL "http://phpdbg.com"
+#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues"
+#define PHPDBG_VERSION "0.4.0"
+#define PHPDBG_INIT_FILENAME ".phpdbginit"
+/* }}} */
+
/* {{{ output descriptors */
#define PHPDBG_STDIN 0
#define PHPDBG_STDOUT 1
#define PHPDBG_STDERR 2
#define PHPDBG_IO_FDS 3 /* }}} */
-#define phpdbg_try_access \
- { \
- JMP_BUF *__orig_bailout = PHPDBG_G(sigsegv_bailout); \
- JMP_BUF __bailout; \
- \
- PHPDBG_G(sigsegv_bailout) = &__bailout; \
- if (SETJMP(__bailout) == 0) {
-#define phpdbg_catch_access \
- } else { \
- PHPDBG_G(sigsegv_bailout) = __orig_bailout;
-#define phpdbg_end_try_access() \
- } \
- PHPDBG_G(sigsegv_bailout) = __orig_bailout; \
- }
-
/* {{{ structs */
ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
@@ -247,54 +202,29 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
int bp_count; /* breakpoint count */
int vmret; /* return from last opcode handler execution */
- zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
- HashTable file_sources;
-
FILE *oplog; /* opline log */
- struct {
- FILE *ptr;
- int fd;
- } io[PHPDBG_IO_FDS]; /* io */
- int eol; /* type of line ending to use */
- size_t (*php_stdiop_write)(php_stream *, const char *, size_t TSRMLS_DC);
- int in_script_xml; /* in <stream> output mode */
- struct {
- zend_bool active;
- int type;
- int fd;
- char *tag;
- char *msg;
- int msglen;
- char *xml;
- int xmllen;
- } err_buf; /* error buffer */
- zend_ulong req_id; /* "request id" to keep track of commands */
+ FILE *io[PHPDBG_IO_FDS]; /* io */
char *prompt[2]; /* prompt */
const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */
char *buffer; /* buffer */
- zend_bool last_was_newline; /* check if we don't need to output a newline upon next phpdbg_error or phpdbg_notice */
-
- char input_buffer[PHPDBG_MAX_CMD]; /* stdin input buffer */
- int input_buflen; /* length of stdin input buffer */
- phpdbg_signal_safe_mem sigsafe_mem; /* memory to use in async safe environment (only once!) */
- JMP_BUF *sigsegv_bailout; /* bailout address for accesibility probing */
-
- uint64_t flags; /* phpdbg flags */
-
- char *socket_path; /* phpdbg.path ini setting */
- char *sapi_name_ptr; /* store sapi name to free it if necessary to not leak memory */
- int socket_fd; /* file descriptor to socket (wait command) (-1 if unused) */
- int socket_server_fd; /* file descriptor to master socket (wait command) (-1 if unused) */
-#ifdef PHP_WIN32
- HANDLE sigio_watcher_thread; /* sigio watcher thread handle */
- struct win32_sigio_watcher_data swd;
-#endif
-
- struct _zend_phpdbg_globals *backup; /* backup of data to store */
+ zend_ulong flags; /* phpdbg flags */
ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */
-#endif
+/* the beginning (= the important part) of the _zend_mm_heap struct defined in Zend/zend_alloc.c
+ Needed for realizing watchpoints */
+struct _zend_mm_heap {
+ int use_zend_alloc;
+ void *(*_malloc)(size_t);
+ void (*_free)(void *);
+ void *(*_realloc)(void *, size_t);
+ size_t free_bitmap;
+ size_t large_free_bitmap;
+ size_t block_size;
+ size_t compact_size;
+ zend_mm_segment *segments_list;
+ zend_mm_storage *storage;
+};
#endif /* PHPDBG_H */