root/sapi/phpdbg/phpdbg.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ZEND_BEGIN_MODULE_GLOBALS

   1 /*
   2    +----------------------------------------------------------------------+
   3    | PHP Version 7                                                        |
   4    +----------------------------------------------------------------------+
   5    | Copyright (c) 1997-2016 The PHP Group                                |
   6    +----------------------------------------------------------------------+
   7    | This source file is subject to version 3.01 of the PHP license,      |
   8    | that is bundled with this package in the file LICENSE, and is        |
   9    | available through the world-wide-web at the following url:           |
  10    | http://www.php.net/license/3_01.txt                                  |
  11    | If you did not receive a copy of the PHP license and are unable to   |
  12    | obtain it through the world-wide-web, please send a note to          |
  13    | license@php.net so we can mail you a copy immediately.               |
  14    +----------------------------------------------------------------------+
  15    | Authors: Felipe Pena <felipe@php.net>                                |
  16    | Authors: Joe Watkins <joe.watkins@live.co.uk>                        |
  17    | Authors: Bob Weinand <bwoebi@php.net>                                |
  18    +----------------------------------------------------------------------+
  19 */
  20 
  21 #ifndef PHPDBG_H
  22 #define PHPDBG_H
  23 
  24 #ifdef PHP_WIN32
  25 # define PHPDBG_API __declspec(dllexport)
  26 #elif defined(__GNUC__) && __GNUC__ >= 4
  27 # define PHPDBG_API __attribute__ ((visibility("default")))
  28 #else
  29 # define PHPDBG_API
  30 #endif
  31 
  32 #ifndef PHP_WIN32
  33 #       include <stdint.h>
  34 #       include <stddef.h>
  35 #else
  36 #       include "main/php_stdint.h"
  37 #endif
  38 #include "php.h"
  39 #include "php_globals.h"
  40 #include "php_variables.h"
  41 #include "php_getopt.h"
  42 #include "zend_builtin_functions.h"
  43 #include "zend_extensions.h"
  44 #include "zend_modules.h"
  45 #include "zend_globals.h"
  46 #include "zend_ini_scanner.h"
  47 #include "zend_stream.h"
  48 #ifndef _WIN32
  49 #       include "zend_signal.h"
  50 #endif
  51 #include "SAPI.h"
  52 #include <fcntl.h>
  53 #include <sys/types.h>
  54 #if defined(_WIN32) && !defined(__MINGW32__)
  55 #       include <windows.h>
  56 #       include "config.w32.h"
  57 #       undef  strcasecmp
  58 #       undef  strncasecmp
  59 #       define strcasecmp _stricmp
  60 #       define strncasecmp _strnicmp
  61 #else
  62 #       include "php_config.h"
  63 #endif
  64 #ifndef O_BINARY
  65 #       define O_BINARY 0
  66 #endif
  67 #include "php_main.h"
  68 
  69 #ifdef ZTS
  70 # include "TSRM.h"
  71 #endif
  72 
  73 #undef zend_hash_str_add
  74 #ifdef PHP_WIN32
  75 #define zend_hash_str_add(...) \
  76         _zend_hash_str_add(__VA_ARGS__ ZEND_FILE_LINE_CC)
  77 #else
  78 #define zend_hash_str_add_tmp(ht, key, len, pData) \
  79         _zend_hash_str_add(ht, key, len, pData ZEND_FILE_LINE_CC)
  80 #define zend_hash_str_add(...) zend_hash_str_add_tmp(__VA_ARGS__)
  81 #endif
  82 
  83 #ifdef HAVE_LIBREADLINE
  84 #       include <readline/readline.h>
  85 #       include <readline/history.h>
  86 #endif
  87 #ifdef HAVE_LIBEDIT
  88 #       include <editline/readline.h>
  89 #endif
  90 
  91 /* {{{ remote console headers */
  92 #ifndef _WIN32
  93 #       include <sys/socket.h>
  94 #       include <sys/un.h>
  95 #       include <sys/select.h>
  96 #       include <sys/types.h>
  97 #       include <netdb.h>
  98 #endif /* }}} */
  99 
 100 /* {{{ strings */
 101 #define PHPDBG_NAME "phpdbg"
 102 #define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */
 103 #define PHPDBG_ISSUES "http://bugs.php.net/report.php"
 104 #define PHPDBG_VERSION "0.5.0"
 105 #define PHPDBG_INIT_FILENAME ".phpdbginit"
 106 #define PHPDBG_DEFAULT_PROMPT "prompt>"
 107 /* }}} */
 108 
 109 /* Hey, apple. One shouldn't define *functions* from the standard C library as marcos. */
 110 #ifdef memcpy
 111 #define memcpy_tmp(...) memcpy(__VA_ARGS__)
 112 #undef memcpy
 113 #define memcpy(...) memcpy_tmp(__VA_ARGS__)
 114 #endif
 115 
 116 #define quiet_write(...) ZEND_IGNORE_VALUE(write(__VA_ARGS__))
 117 
 118 #if !defined(PHPDBG_WEBDATA_TRANSFER_H) && !defined(PHPDBG_WEBHELPER_H)
 119 
 120 #ifdef ZTS
 121 # define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v)
 122 #else
 123 # define PHPDBG_G(v) (phpdbg_globals.v)
 124 #endif
 125 
 126 #include "phpdbg_sigsafe.h"
 127 #include "phpdbg_out.h"
 128 #include "phpdbg_lexer.h"
 129 #include "phpdbg_cmd.h"
 130 #include "phpdbg_utils.h"
 131 #include "phpdbg_btree.h"
 132 #include "phpdbg_watch.h"
 133 #include "phpdbg_bp.h"
 134 #include "phpdbg_opcode.h"
 135 #ifdef PHP_WIN32
 136 # include "phpdbg_sigio_win32.h"
 137 #endif
 138 
 139 int phpdbg_do_parse(phpdbg_param_t *stack, char *input);
 140 
 141 #define PHPDBG_NEXT   2
 142 #define PHPDBG_UNTIL  3
 143 #define PHPDBG_FINISH 4
 144 #define PHPDBG_LEAVE  5
 145 
 146 /*
 147  BEGIN: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE
 148 */
 149 
 150 /* {{{ flags */
 151 #define PHPDBG_HAS_FILE_BP            (1ULL<<1)
 152 #define PHPDBG_HAS_PENDING_FILE_BP    (1ULL<<2)
 153 #define PHPDBG_HAS_SYM_BP             (1ULL<<3)
 154 #define PHPDBG_HAS_OPLINE_BP          (1ULL<<4)
 155 #define PHPDBG_HAS_METHOD_BP          (1ULL<<5)
 156 #define PHPDBG_HAS_COND_BP            (1ULL<<6)
 157 #define PHPDBG_HAS_OPCODE_BP          (1ULL<<7)
 158 #define PHPDBG_HAS_FUNCTION_OPLINE_BP (1ULL<<8)
 159 #define PHPDBG_HAS_METHOD_OPLINE_BP   (1ULL<<9)
 160 #define PHPDBG_HAS_FILE_OPLINE_BP     (1ULL<<10) /* }}} */
 161 
 162 /*
 163  END: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE
 164 */
 165 
 166 #define PHPDBG_IN_COND_BP             (1ULL<<11)
 167 #define PHPDBG_IN_EVAL                (1ULL<<12)
 168 
 169 #define PHPDBG_IS_STEPPING            (1ULL<<13)
 170 #define PHPDBG_STEP_OPCODE            (1ULL<<14)
 171 #define PHPDBG_IS_QUIET               (1ULL<<15)
 172 #define PHPDBG_IS_QUITTING            (1ULL<<16)
 173 #define PHPDBG_IS_COLOURED            (1ULL<<17)
 174 #define PHPDBG_IS_CLEANING            (1ULL<<18)
 175 #define PHPDBG_IS_RUNNING             (1ULL<<19)
 176 
 177 #define PHPDBG_IN_UNTIL               (1ULL<<20)
 178 #define PHPDBG_IN_FINISH              (1ULL<<21)
 179 #define PHPDBG_IN_LEAVE               (1ULL<<22)
 180 
 181 #define PHPDBG_IS_REGISTERED          (1ULL<<23)
 182 #define PHPDBG_IS_STEPONEVAL          (1ULL<<24)
 183 #define PHPDBG_IS_INITIALIZING        (1ULL<<25)
 184 #define PHPDBG_IS_SIGNALED            (1ULL<<26)
 185 #define PHPDBG_IS_INTERACTIVE         (1ULL<<27)
 186 #define PHPDBG_PREVENT_INTERACTIVE    (1ULL<<28)
 187 #define PHPDBG_IS_BP_ENABLED          (1ULL<<29)
 188 #define PHPDBG_IS_REMOTE              (1ULL<<30)
 189 #define PHPDBG_IS_DISCONNECTED        (1ULL<<31)
 190 #define PHPDBG_WRITE_XML              (1ULL<<32)
 191 
 192 #define PHPDBG_SHOW_REFCOUNTS         (1ULL<<33)
 193 
 194 #define PHPDBG_IN_SIGNAL_HANDLER      (1ULL<<34)
 195 
 196 #define PHPDBG_DISCARD_OUTPUT         (1ULL<<35)
 197 
 198 #define PHPDBG_HAS_PAGINATION         (1ULL<<36)
 199 
 200 #define PHPDBG_SEEK_MASK              (PHPDBG_IN_UNTIL | PHPDBG_IN_FINISH | PHPDBG_IN_LEAVE)
 201 #define PHPDBG_BP_RESOLVE_MASK        (PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
 202 #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)
 203 #define PHPDBG_IS_STOPPING            (PHPDBG_IS_QUITTING | PHPDBG_IS_CLEANING)
 204 
 205 #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 | PHPDBG_HAS_PAGINATION)
 206 
 207 #ifndef _WIN32
 208 #       define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED | PHPDBG_HAS_PAGINATION)
 209 #else
 210 #       define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_BP_ENABLED | PHPDBG_HAS_PAGINATION)
 211 #endif /* }}} */
 212 
 213 /* {{{ output descriptors */
 214 #define PHPDBG_STDIN                    0
 215 #define PHPDBG_STDOUT                   1
 216 #define PHPDBG_STDERR                   2
 217 #define PHPDBG_IO_FDS                   3 /* }}} */
 218 
 219 #define phpdbg_try_access \
 220         {                                                            \
 221                 JMP_BUF *__orig_bailout = PHPDBG_G(sigsegv_bailout); \
 222                 JMP_BUF __bailout;                                   \
 223                                                                      \
 224                 PHPDBG_G(sigsegv_bailout) = &__bailout;              \
 225                 if (SETJMP(__bailout) == 0) {
 226 #define phpdbg_catch_access \
 227                 } else {                                             \
 228                         PHPDBG_G(sigsegv_bailout) = __orig_bailout;
 229 #define phpdbg_end_try_access() \
 230                 }                                                    \
 231                         PHPDBG_G(sigsegv_bailout) = __orig_bailout;  \
 232         }
 233 
 234 
 235 /* {{{ structs */
 236 ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
 237         HashTable bp[PHPDBG_BREAK_TABLES];           /* break points */
 238         HashTable registered;                        /* registered */
 239         HashTable seek;                              /* seek oplines */
 240         zend_execute_data *seek_ex;                  /* call frame of oplines to seek to */
 241         zend_object *handled_exception;              /* last handled exception (prevent multiple handling of same exception) */
 242         phpdbg_frame_t frame;                        /* frame */
 243         uint32_t last_line;                          /* last executed line */
 244 
 245         phpdbg_lexer_data lexer;                     /* lexer data */
 246         phpdbg_param_t *parser_stack;                /* param stack during lexer / parser phase */
 247 
 248 #ifndef _WIN32
 249         struct sigaction old_sigsegv_signal;         /* segv signal handler */
 250 #endif
 251         phpdbg_btree watchpoint_tree;                /* tree with watchpoints */
 252         phpdbg_btree watch_HashTables;               /* tree with original dtors of watchpoints */
 253         HashTable watchpoints;                       /* watchpoints */
 254         HashTable watch_collisions;                  /* collision table to check if multiple watches share the same recursive watchpoint */
 255         zend_llist watchlist_mem;                    /* triggered watchpoints */
 256         zend_bool watchpoint_hit;                    /* a watchpoint was hit */
 257         void (*original_free_function)(void *);      /* the original AG(mm_heap)->_free function */
 258         phpdbg_watchpoint_t *watch_tmp;              /* temporary pointer for a watchpoint */
 259 
 260         char *exec;                                  /* file to execute */
 261         size_t exec_len;                             /* size of exec */
 262         zend_op_array *ops;                          /* op_array */
 263         zval retval;                                 /* return value */
 264         int bp_count;                                /* breakpoint count */
 265         int vmret;                                   /* return from last opcode handler execution */
 266         zend_bool in_execution;                      /* in execution? */
 267         zend_bool unclean_eval;                      /* do not check for memory leaks when we needed to bail out during eval */
 268 
 269         zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type);
 270         zend_op_array *(*init_compile_file)(zend_file_handle *file_handle, int type);
 271         zend_op_array *(*compile_string)(zval *source_string, char *filename);
 272         HashTable file_sources;
 273 
 274         FILE *oplog;                                 /* opline log */
 275         zend_arena *oplog_arena;                     /* arena for storing oplog */
 276         phpdbg_oplog_list *oplog_list;               /* list of oplog starts */
 277         phpdbg_oplog_entry *oplog_cur;               /* current oplog entry */
 278 
 279         struct {
 280                 FILE *ptr;
 281                 int fd;
 282         } io[PHPDBG_IO_FDS];                         /* io */
 283         int eol;                                     /* type of line ending to use */
 284         size_t (*php_stdiop_write)(php_stream *, const char *, size_t);
 285         int in_script_xml;                           /* in <stream> output mode */
 286         struct {
 287                 zend_bool active;
 288                 int type;
 289                 int fd;
 290                 char *tag;
 291                 char *msg;
 292                 int msglen;
 293                 char *xml;
 294                 int xmllen;
 295         } err_buf;                                   /* error buffer */
 296         zend_ulong req_id;                           /* "request id" to keep track of commands */
 297 
 298         char *prompt[2];                             /* prompt */
 299         const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */
 300         char *buffer;                                /* buffer */
 301         zend_bool last_was_newline;                  /* check if we don't need to output a newline upon next phpdbg_error or phpdbg_notice */
 302 
 303         char input_buffer[PHPDBG_MAX_CMD];           /* stdin input buffer */
 304         int input_buflen;                            /* length of stdin input buffer */
 305         phpdbg_signal_safe_mem sigsafe_mem;          /* memory to use in async safe environment (only once!) */
 306 
 307         JMP_BUF *sigsegv_bailout;                    /* bailout address for accesibility probing */
 308 
 309         uint64_t flags;                              /* phpdbg flags */
 310 
 311         char *socket_path;                           /* phpdbg.path ini setting */
 312         char *sapi_name_ptr;                         /* store sapi name to free it if necessary to not leak memory */
 313         int socket_fd;                               /* file descriptor to socket (wait command) (-1 if unused) */
 314         int socket_server_fd;                        /* file descriptor to master socket (wait command) (-1 if unused) */
 315 #ifdef PHP_WIN32
 316         HANDLE sigio_watcher_thread;                 /* sigio watcher thread handle */
 317         struct win32_sigio_watcher_data swd;
 318 #endif
 319         long lines;                                  /* max number of lines to display */
 320 ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */
 321 
 322 #endif
 323 
 324 #endif /* PHPDBG_H */

/* [<][>][^][v][top][bottom][index][help] */