1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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);
}
}
}
|