summaryrefslogtreecommitdiffstats
path: root/xdebug-pr167.patch
diff options
context:
space:
mode:
Diffstat (limited to 'xdebug-pr167.patch')
-rw-r--r--xdebug-pr167.patch128
1 files changed, 128 insertions, 0 deletions
diff --git a/xdebug-pr167.patch b/xdebug-pr167.patch
new file mode 100644
index 0000000..293f261
--- /dev/null
+++ b/xdebug-pr167.patch
@@ -0,0 +1,128 @@
+From b6da4dad4e2410de764964b61b17bdff7fa72cd9 Mon Sep 17 00:00:00 2001
+From: Derick Rethans <github@derickrethans.nl>
+Date: Tue, 31 Mar 2015 10:25:56 +0100
+Subject: [PATCH] Fixed issue #1133: PDO exception code value type is changed
+
+---
+ tests/bug01133.phpt | 19 +++++++++++++++++++
+ xdebug.c | 17 +++++++++++++++--
+ xdebug_handler_dbgp.c | 4 ++--
+ xdebug_handler_dbgp.h | 2 +-
+ xdebug_handlers.h | 2 +-
+ xdebug_stack.c | 6 +++++-
+ 6 files changed, 43 insertions(+), 7 deletions(-)
+ create mode 100644 tests/bug01133.phpt
+
+diff --git a/xdebug.c b/xdebug.c
+index e10449b..af6601e 100644
+--- a/xdebug.c
++++ b/xdebug.c
+@@ -1186,6 +1186,7 @@ static void xdebug_throw_exception_hook(zval *exception TSRMLS_DC)
+ zval *xdebug_message_trace, *previous_exception;
+ zend_class_entry *default_ce, *exception_ce;
+ xdebug_brk_info *extra_brk_info;
++ char *code_str = NULL;
+ char *exception_trace;
+ xdebug_str tmp_str = { 0, 0, NULL };
+
+@@ -1201,7 +1202,14 @@ static void xdebug_throw_exception_hook(zval *exception TSRMLS_DC)
+ file = zend_read_property(default_ce, exception, "file", sizeof("file")-1, 0 TSRMLS_CC);
+ line = zend_read_property(default_ce, exception, "line", sizeof("line")-1, 0 TSRMLS_CC);
+
+- convert_to_long_ex(&code);
++ if (Z_TYPE_P(code) == IS_LONG) {
++ if (Z_LVAL_P(code) != 0) {
++ code_str = xdebug_sprintf("%lu", Z_LVAL_P(code));
++ }
++ } else if (Z_TYPE_P(code) != IS_STRING) {
++ code_str = xdstrdup("");
++ }
++
+ convert_to_string_ex(&message);
+ convert_to_string_ex(&file);
+ convert_to_long_ex(&line);
+@@ -1265,11 +1273,16 @@ static void xdebug_throw_exception_hook(zval *exception TSRMLS_DC)
+ }
+
+ if (exception_breakpoint_found && xdebug_handle_hit_value(extra_brk_info)) {
+- if (!XG(context).handler->remote_breakpoint(&(XG(context)), XG(stack), Z_STRVAL_P(file), Z_LVAL_P(line), XDEBUG_BREAK, (char *) exception_ce->name, Z_LVAL_P(code), Z_STRVAL_P(message))) {
++ if (!XG(context).handler->remote_breakpoint(&(XG(context)), XG(stack), Z_STRVAL_P(file), Z_LVAL_P(line), XDEBUG_BREAK, (char *) exception_ce->name, code_str ? code_str : Z_STRVAL_P(code), Z_STRVAL_P(message))) {
+ XG(remote_enabled) = 0;
+ }
+ }
+ }
++
++ /* Free code_str if necessary */
++ if (code_str) {
++ xdfree(code_str);
++ }
+ }
+
+ static int handle_breakpoints(function_stack_entry *fse, int breakpoint_type)
+diff --git a/xdebug_handler_dbgp.c b/xdebug_handler_dbgp.c
+index ebbadc2..3265c4b 100644
+--- a/xdebug_handler_dbgp.c
++++ b/xdebug_handler_dbgp.c
+@@ -2342,7 +2342,7 @@ int xdebug_dbgp_error(xdebug_con *context, int type, char *exception_type, char
+ return 1;
+ }
+
+-int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_llist *stack, char *file, long lineno, int type, char *exception, int code, char *message)
++int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_llist *stack, char *file, long lineno, int type, char *exception, char *code, char *message)
+ {
+ xdebug_xml_node *response, *error_container;
+ TSRMLS_FETCH();
+@@ -2379,7 +2379,7 @@ int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_llist *stack, char *file,
+ xdebug_xml_add_attribute_ex(error_container, "exception", xdstrdup(exception), 0, 1);
+ }
+ if (code) {
+- xdebug_xml_add_attribute_ex(error_container, "code", xdebug_sprintf("%lu", code), 0, 1);
++ xdebug_xml_add_attribute_ex(error_container, "code", xdstrdup(code), 0, 1);
+ }
+ if (message) {
+ xdebug_xml_add_text(error_container, xdstrdup(message));
+diff --git a/xdebug_handler_dbgp.h b/xdebug_handler_dbgp.h
+index f875cde..0892d06 100644
+--- a/xdebug_handler_dbgp.h
++++ b/xdebug_handler_dbgp.h
+@@ -91,7 +91,7 @@ typedef struct xdebug_dbgp_cmd {
+ int xdebug_dbgp_init(xdebug_con *context, int mode);
+ 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, char *exception, int code, char *message);
++int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_llist *stack, char *file, long lineno, int type, char *exception, char *code, char *message);
+ int xdebug_dbgp_stream_output(const char *string, unsigned int length TSRMLS_DC);
+ int xdebug_dbgp_register_eval_id(xdebug_con *context, function_stack_entry *fse);
+ char *xdebug_dbgp_get_revision(void);
+diff --git a/xdebug_handlers.h b/xdebug_handlers.h
+index 73b0d77..dbd92f2 100644
+--- a/xdebug_handlers.h
++++ b/xdebug_handlers.h
+@@ -110,7 +110,7 @@ struct _xdebug_remote_handler {
+ int (*remote_error)(xdebug_con *h, int type, char *exception_type, char *message, const char *location, const uint line, xdebug_llist *stack);
+
+ /* Breakpoints */
+- int (*remote_breakpoint)(xdebug_con *h, xdebug_llist *stack, char *file, long lineno, int type, char *exception, int code, char *message);
++ int (*remote_breakpoint)(xdebug_con *h, xdebug_llist *stack, char *file, long lineno, int type, char *exception, char *code, char *message);
+
+ /* Output redirection */
+ int (*remote_stream_output)(const char *string, unsigned int length TSRMLS_DC);
+diff --git a/xdebug_stack.c b/xdebug_stack.c
+index 40a71cc..a8d04d8 100644
+--- a/xdebug_stack.c
++++ b/xdebug_stack.c
+@@ -654,9 +654,13 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line
+ xdebug_hash_find(XG(context).exception_breakpoints, "*", 1, (void *) &extra_brk_info)
+ ) {
+ if (xdebug_handle_hit_value(extra_brk_info)) {
+- if (!XG(context).handler->remote_breakpoint(&(XG(context)), XG(stack), (char *) error_filename, error_lineno, XDEBUG_BREAK, error_type_str, type, buffer)) {
++ char *type_str = xdebug_sprintf("%ld", type);
++
++ if (!XG(context).handler->remote_breakpoint(&(XG(context)), XG(stack), (char *) error_filename, error_lineno, XDEBUG_BREAK, error_type_str, type_str, buffer)) {
+ XG(remote_enabled) = 0;
+ }
++
++ xdfree(type_str);
+ }
+ }
+ }