Date: Tue Feb 21 21:43:17 CET 2006
User: Derick Rethans
Directory: xdebug
Log Message:
- Implemented virtual files for eval'ed statements. This fixes bug #136 too.
Modified files:
xdebug/usefulstuff.c (version: 1.25)
xdebug/usefulstuff.h (version: 1.15)
xdebug/xdebug.c (version: 1.299)
xdebug/xdebug_handler_dbgp.c (version: 1.82)
xdebug/xdebug_handler_dbgp.h (version: 1.17)
xdebug/xdebug_handler_gdb.h (version: 1.29)
xdebug/xdebug_handler_php3.h (version: 1.15)
xdebug/xdebug_handlers.c (version: 1.16)
xdebug/xdebug_handlers.h (version: 1.32)
[FILE: /xdebug/usefulstuff.c]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- xdebug/usefulstuff.c:1.24 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/usefulstuff.c Tue Feb 21 19:43:17 2006 GMT
@@ -90,6 +90,26 @@
return tmp;
}
+char *xdebug_join(char *delim, xdebug_arg *args, int begin, int end)
+{
+ int i;
+ xdebug_str *ret;
+
+ xdebug_str_ptr_init(ret);
+ if (begin < 0) {
+ begin = 0;
+ }
+ if (end > args->c - 1) {
+ end = args->c - 1;
+ }
+ for (i = begin; i < end; i++) {
+ xdebug_str_add(ret, args->args[i], 0);
+ xdebug_str_add(ret, delim, 0);
+ }
+ xdebug_str_add(ret, args->args[end], 0);
+ return ret->d;
+}
+
void xdebug_explode(char *delim, char *str, xdebug_arg *args, int limit)
{
char *p1, *p2, *endp;
[FILE: /xdebug/usefulstuff.h]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- xdebug/usefulstuff.h:1.14 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/usefulstuff.h Tue Feb 21 19:43:17 2006 GMT
@@ -52,6 +52,7 @@
#define fd_read_line(s,c,t) fd_read_line_delim(s, c, t, '\n', NULL)
char* fd_read_line_delim(int socket, fd_buf *context, int type, unsigned char delim, int *length);
+char *xdebug_join(char *delim, xdebug_arg *args, int begin, int end);
void xdebug_explode(char *delim, char *str, xdebug_arg *args, int limit);
char* xdebug_memnstr(char *haystack, char *needle, int needle_len, char *end);
double xdebug_get_utime(void);
[FILE: /xdebug/xdebug.c]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.298
retrieving revision 1.299
diff -u -r1.298 -r1.299
--- xdebug/xdebug.c:1.298 Fri Feb 10 13:44:55 2006 GMT
+++ xdebug/xdebug.c Tue Feb 21 19:43:17 2006 GMT
@@ -1164,6 +1164,7 @@
int do_return = (XG(do_trace) && XG(trace_file));
int function_nr = 0;
xdebug_llist_element *le;
+ int eval_id = 0;
if (XG(level) == 0) {
/* Set session cookie if requested */
@@ -1292,6 +1293,13 @@
xdebug_prefil_code_coverage(fse, op_array TSRMLS_CC);
}
+ /* If we're in an eval, we need to create an ID for it. This ID however
+ * depends on the debugger mechanism in use so we need to call a function
+ * in the handler for it */
+ if (XG(remote_enabled) && XG(context).handler->register_eval_id && fse->function.type == XFUNC_EVAL) {
+ eval_id = XG(context).handler->register_eval_id(&(XG(context)), fse);
+ }
+
/* Check for entry breakpoints */
if (XG(remote_enabled) && XG(breakpoints_allowed)) {
if (!handle_breakpoints(fse, XDEBUG_BRK_FUNC_CALL)) {
@@ -1326,6 +1334,11 @@
}
}
+ /* If we're in an eval, we need to destroy the created ID again. */
+ if (XG(remote_enabled) && XG(context).handler->unregister_eval_id && fse->function.type == XFUNC_EVAL) {
+ XG(context).handler->unregister_eval_id(&(XG(context)), fse, eval_id);
+ }
+
fse->symbol_table = NULL;
xdebug_llist_remove(XG(stack), XDEBUG_LLIST_TAIL(XG(stack)), stack_element_dtor);
XG(level)--;
[FILE: /xdebug/xdebug_handler_dbgp.c]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- xdebug/xdebug_handler_dbgp.c:1.81 Tue Jan 24 21:05:54 2006 GMT
+++ xdebug/xdebug_handler_dbgp.c Tue Feb 21 19:43:17 2006 GMT
@@ -50,6 +50,7 @@
#include <fcntl.h>
ZEND_EXTERN_MODULE_GLOBALS(xdebug)
+static char *create_eval_key_id(int id);
/*****************************************************************************
** Constants and strings for statii and reasons
@@ -533,7 +534,7 @@
return 0;
}
-static char* return_source(char *filename, int begin, int end TSRMLS_DC)
+static char* return_file_source(char *filename, int begin, int end TSRMLS_DC)
{
php_stream *stream;
int i = begin;
@@ -586,10 +587,57 @@
return source.d;
}
+static char* return_eval_source(char *id, int begin, int end TSRMLS_DC)
+{
+ char *key, *joined;
+ xdebug_eval_info *ei;
+ xdebug_arg *parts = (xdebug_arg*) xdmalloc(sizeof(xdebug_arg));
+
+ if (begin < 0) {
+ begin = 0;
+ }
+ key = create_eval_key_id(atoi(id));
+ if (xdebug_hash_find(XG(context).eval_id_lookup, key, strlen(key), (void *) &ei)) {
+ xdebug_arg_init(parts);
+ xdebug_explode("\n", ei->contents, parts, end + 2);
+ joined = xdebug_join("\n", parts, begin, end);
+ xdebug_arg_dtor(parts);
+ return joined;
+ }
+ return NULL;
+}
+
+static char* return_source(char *filename, int begin, int end TSRMLS_DC)
+{
+ if (strncmp(filename, "dbgp://", 7) == 0) {
+ return return_eval_source(filename + 7, begin, end TSRMLS_CC);
+ } else {
+ return return_file_source(filename, begin, end TSRMLS_CC);
+ }
+}
+
+
+static int check_evaled_code(function_stack_entry *fse, char **filename, int *lineno TSRMLS_DC)
+{
+ char *end_marker;
+ xdebug_eval_info *ei;
+
+ end_marker = fse->filename + strlen(fse->filename) - strlen("eval()'d code");
+ if (strcmp("eval()'d code", end_marker) == 0) {
+ if (xdebug_hash_find(XG(context).eval_id_lookup, fse->filename, strlen(fse->filename), (void *) &ei)) {
+ *filename = xdebug_sprintf("dbgp://%lu", ei->id);
+ }
+ return 1;
+ }
+ return 0;
+}
+
static xdebug_xml_node* return_stackframe(int nr TSRMLS_DC)
{
function_stack_entry *fse, *fse_prev;
char *tmp_fname;
+ char *tmp_filename;
+ int tmp_lineno;
xdebug_xml_node *tmp;
fse = xdebug_get_stack_frame(nr TSRMLS_CC);
@@ -600,11 +648,17 @@
tmp = xdebug_xml_node_init("stack");
xdebug_xml_add_attribute_ex(tmp, "where", xdstrdup(tmp_fname), 0, 1);
xdebug_xml_add_attribute_ex(tmp, "level", xdebug_sprintf("%ld", nr), 0, 1);
- xdebug_xml_add_attribute_ex(tmp, "type", xdstrdup("file"), 0, 1);
if (fse_prev) {
- xdebug_xml_add_attribute_ex(tmp, "filename", xdebug_path_to_url(fse_prev->filename TSRMLS_CC), 0, 1);
+ if (check_evaled_code(fse_prev, &tmp_filename, &tmp_lineno TSRMLS_CC)) {
+ xdebug_xml_add_attribute_ex(tmp, "type", xdstrdup("eval"), 0, 1);
+ xdebug_xml_add_attribute_ex(tmp, "filename", tmp_filename, 0, 0);
+ } else {
+ xdebug_xml_add_attribute_ex(tmp, "type", xdstrdup("file"), 0, 1);
+ xdebug_xml_add_attribute_ex(tmp, "filename", xdebug_path_to_url(fse_prev->filename TSRMLS_CC), 0, 1);
+ }
xdebug_xml_add_attribute_ex(tmp, "lineno", xdebug_sprintf("%lu", fse_prev->lineno TSRMLS_CC), 0, 1);
} else {
+ xdebug_xml_add_attribute_ex(tmp, "type", xdstrdup("file"), 0, 1);
xdebug_xml_add_attribute_ex(tmp, "filename", xdebug_path_to_url(zend_get_executed_filename(TSRMLS_C) TSRMLS_CC), 0, 1);
xdebug_xml_add_attribute_ex(tmp, "lineno", xdebug_sprintf("%lu", zend_get_executed_lineno(TSRMLS_C)), 0, 1);
}
@@ -1226,7 +1280,7 @@
begin = strtol(CMD_OPTION('b'), NULL, 10);
}
if (CMD_OPTION('e')) {
- begin = strtol(CMD_OPTION('e'), NULL, 10);
+ end = strtol(CMD_OPTION('e'), NULL, 10);
}
/* return_source allocates memory for source */
source = return_source(filename, begin, end TSRMLS_CC);
@@ -1962,7 +2016,7 @@
char *xdebug_dbgp_get_revision(void)
{
- return "$Revision: 1.81 $";
+ return "$Revision: 1.82 $";
}
int xdebug_dbgp_cmdloop(xdebug_con *context TSRMLS_DC)
@@ -2080,6 +2134,8 @@
context->function_breakpoints = xdebug_hash_alloc(64, (xdebug_hash_dtor) xdebug_hash_brk_dtor);
context->class_breakpoints = xdebug_hash_alloc(64, (xdebug_hash_dtor) xdebug_hash_brk_dtor);
context->line_breakpoints = xdebug_llist_alloc((xdebug_llist_dtor) xdebug_llist_brk_dtor);
+ context->eval_id_lookup = xdebug_hash_alloc(64, (xdebug_hash_dtor) xdebug_hash_eval_info_dtor);
+ context->eval_id_sequence = 0;
xdebug_dbgp_cmdloop(context TSRMLS_CC);
@@ -2120,6 +2176,7 @@
xdfree(context->options);
xdebug_hash_destroy(context->function_breakpoints);
xdebug_hash_destroy(context->class_breakpoints);
+ xdebug_hash_destroy(context->eval_id_lookup);
xdebug_llist_destroy(context->line_breakpoints, NULL);
xdebug_hash_destroy(context->breakpoint_list);
xdfree(context->buffer);
@@ -2217,3 +2274,46 @@
return 1;
}
+
+static char *create_eval_key_file(char *filename, int lineno)
+{
+ return xdebug_sprintf("%s(%d) : eval()'d code", filename, lineno);
+}
+
+static char *create_eval_key_id(int id)
+{
+ return xdebug_sprintf("%04x", id);
+}
+
+int xdebug_dbgp_register_eval_id(xdebug_con *context, function_stack_entry *fse)
+{
+ char *key;
+ xdebug_eval_info *ei;
+
+ context->eval_id_sequence++;
+
+ ei = xdcalloc(sizeof(xdebug_eval_info), 1);
+ ei->id = context->eval_id_sequence;
+ ei->contents = xdstrndup(fse->include_filename + 1, strlen(fse->include_filename) - 2);
+ ei->refcount = 2;
+
+ key = create_eval_key_file(fse->filename, fse->lineno);
+ xdebug_hash_add(context->eval_id_lookup, key, strlen(key), (void*) ei);
+
+ key = create_eval_key_id(ei->id);
+ xdebug_hash_add(context->eval_id_lookup, key, strlen(key), (void*) ei);
+
+ return ei->id;
+}
+
+int xdebug_dbgp_unregister_eval_id(xdebug_con *context, function_stack_entry *fse, int eval_id)
+{
+ char *key;
+
+ key = create_eval_key_file(fse->filename, fse->lineno);
+ xdebug_hash_delete(context->eval_id_lookup, key, strlen(key));
+
+ key = create_eval_key_id(eval_id);
+ xdebug_hash_delete(context->eval_id_lookup, key, strlen(key));
+ return 1;
+}
[FILE: /xdebug/xdebug_handler_dbgp.h]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- xdebug/xdebug_handler_dbgp.h:1.16 Sun Jan 22 22:30:59 2006 GMT
+++ xdebug/xdebug_handler_dbgp.h Tue Feb 21 19:43:17 2006 GMT
@@ -74,14 +74,18 @@
int xdebug_dbgp_deinit(xdebug_con *context);
int xdebug_dbgp_error(xdebug_con *context, int type, char *exception_type, char *message, const char *location, const uint line, xdebug_llist *stack);
int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_llist *stack, char *file, long lineno, int type);
+int xdebug_dbgp_register_eval_id(xdebug_con *context, function_stack_entry *fse);
+int xdebug_dbgp_unregister_eval_id(xdebug_con *context, function_stack_entry *fse, int eval_id);
char *xdebug_dbgp_get_revision(void);
-#define xdebug_handler_dbgp { \
- xdebug_dbgp_init, \
- xdebug_dbgp_deinit, \
- xdebug_dbgp_error, \
- xdebug_dbgp_breakpoint, \
- xdebug_dbgp_get_revision \
+#define xdebug_handler_dbgp { \
+ xdebug_dbgp_init, \
+ xdebug_dbgp_deinit, \
+ xdebug_dbgp_error, \
+ xdebug_dbgp_breakpoint, \
+ xdebug_dbgp_register_eval_id, \
+ xdebug_dbgp_unregister_eval_id, \
+ xdebug_dbgp_get_revision \
}
#endif
[FILE: /xdebug/xdebug_handler_gdb.h]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- xdebug/xdebug_handler_gdb.h:1.28 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/xdebug_handler_gdb.h Tue Feb 21 19:43:17 2006 GMT
@@ -81,6 +81,8 @@
xdebug_gdb_deinit, \
xdebug_gdb_error, \
xdebug_gdb_breakpoint, \
+ NULL, \
+ NULL, \
xdebug_gdb_get_revision \
}
[FILE: /xdebug/xdebug_handler_php3.h]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- xdebug/xdebug_handler_php3.h:1.14 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/xdebug_handler_php3.h Tue Feb 21 19:43:17 2006 GMT
@@ -32,6 +32,8 @@
xdebug_php3_deinit, \
xdebug_php3_error, \
NULL, \
+ NULL, \
+ NULL, \
xdebug_php3_get_revision \
}
[FILE: /xdebug/xdebug_handlers.c]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- xdebug/xdebug_handlers.c:1.15 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/xdebug_handlers.c Tue Feb 21 19:43:17 2006 GMT
@@ -79,3 +79,14 @@
xdebug_brk_info_dtor(brk);
}
+void xdebug_hash_eval_info_dtor(xdebug_eval_info *ei)
+{
+ ei->refcount--;
+
+ if (ei->refcount == 0) {
+ xdfree(ei->contents);
+ xdfree(ei);
+ } else {
+ /* refcount wasn't 0 yet, so we won't free it yet */
+ }
+}
[FILE: /xdebug/xdebug_handlers.h]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- xdebug/xdebug_handlers.h:1.31 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/xdebug_handlers.h Tue Feb 21 19:43:17 2006 GMT
@@ -23,10 +23,12 @@
#include "xdebug_com.h"
#include "xdebug_llist.h"
#include "xdebug_hash.h"
+#include "xdebug_private.h"
#include "usefulstuff.h"
typedef struct _xdebug_brk_admin xdebug_brk_admin;
typedef struct _xdebug_brk_info xdebug_brk_info;
+typedef struct _xdebug_eval_info xdebug_eval_info;
typedef struct _xdebug_con xdebug_con;
typedef struct _xdebug_debug_list xdebug_debug_list;
typedef struct _xdebug_remote_handler xdebug_remote_handler;
@@ -56,6 +58,8 @@
xdebug_hash *breakpoint_list;
xdebug_hash *function_breakpoints;
xdebug_hash *class_breakpoints;
+ xdebug_hash *eval_id_lookup;
+ int eval_id_sequence;
xdebug_llist *line_breakpoints;
xdebug_debug_list list;
int do_break;
@@ -90,6 +94,12 @@
int hit_condition;
};
+struct _xdebug_eval_info {
+ int id;
+ int refcount;
+ char *contents;
+};
+
struct _xdebug_remote_handler {
/* Init / deinit */
int (*remote_init)(xdebug_con *h, int mode);
@@ -101,6 +111,10 @@
/* Breakpoints */
int (*remote_breakpoint)(xdebug_con *h, xdebug_llist *stack, char *file, long lineno, int type);
+ /* Eval ID registration and removal */
+ int (*register_eval_id)(xdebug_con *h, function_stack_entry *fse);
+ int (*unregister_eval_id)(xdebug_con *h, function_stack_entry *fse, int eval_id);
+
/* Information */
char *(*get_revision)(void);
};
@@ -117,5 +131,6 @@
void xdebug_brk_info_dtor(xdebug_brk_info *brk);
void xdebug_llist_brk_dtor(void *dummy, xdebug_brk_info *brk);
void xdebug_hash_brk_dtor(xdebug_brk_info *brk);
+void xdebug_hash_eval_info_dtor(xdebug_eval_info *ei);
#endif
Received on Tue Feb 21 2006 - 21:43:20 GMT
This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST