/
handlers.h
159 lines (134 loc) · 5.72 KB
/
handlers.h
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
+----------------------------------------------------------------------+
| Xdebug |
+----------------------------------------------------------------------+
| Copyright (c) 2002-2019 Derick Rethans |
+----------------------------------------------------------------------+
| This source file is subject to version 1.01 of the Xdebug license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| https://xdebug.org/license.php |
| If you did not receive a copy of the Xdebug license and are unable |
| to obtain it through the world-wide-web, please send a note to |
| derick@xdebug.org so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Derick Rethans <derick@xdebug.org> |
+----------------------------------------------------------------------+
*/
#ifndef __HAVE_XDEBUG_HANDLERS_H__
#define __HAVE_XDEBUG_HANDLERS_H__
#include "php_xdebug.h"
#include "lib/compat.h"
#include "lib/llist.h"
#include "lib/hash.h"
#include "lib/private.h"
#include "lib/usefulstuff.h"
#include "debugger_private.h"
typedef struct _xdebug_brk_admin xdebug_brk_admin;
typedef struct _xdebug_brk_info xdebug_brk_info;
typedef struct _xdebug_brk_span xdebug_brk_span;
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;
typedef struct _xdebug_remote_handler_info xdebug_remote_handler_info;
struct _xdebug_debug_list {
char *last_file;
int last_line;
};
#define XDEBUG_BREAKPOINT_TYPE_LINE 0x01
#define XDEBUG_BREAKPOINT_TYPE_CONDITIONAL 0x02
#define XDEBUG_BREAKPOINT_TYPE_CALL 0x04
#define XDEBUG_BREAKPOINT_TYPE_RETURN 0x08
#define XDEBUG_BREAKPOINT_TYPE_EXCEPTION 0x10
#define XDEBUG_BREAKPOINT_TYPE_WATCH 0x20
#define XDEBUG_BREAKPOINT_TYPE_NAME(v) (xdebug_breakpoint_types[(int)(log2(v))]).name
struct _xdebug_brk_admin {
int id;
int type;
char *key;
};
struct _xdebug_con {
int socket;
void *options;
xdebug_remote_handler *handler;
fd_buf *buffer;
char *program_name;
xdebug_hash *breakpoint_list;
xdebug_hash *function_breakpoints;
xdebug_hash *eval_id_lookup;
int eval_id_sequence;
xdebug_llist *line_breakpoints;
xdebug_hash *exception_breakpoints;
xdebug_debug_list list;
int do_break;
int do_step;
int do_next;
int next_level;
int do_finish;
int finish_level;
int finish_func_nr;
int send_notifications;
int inhibit_notifications;
int resolved_breakpoints;
};
#define XDEBUG_BRK_UNRESOLVED 0
#define XDEBUG_BRK_RESOLVED 1
#define XDEBUG_HIT_DISABLED 0
#define XDEBUG_HIT_GREATER_EQUAL 1
#define XDEBUG_HIT_EQUAL 2
#define XDEBUG_HIT_MOD 3
#define XDEBUG_RESOLVED_SPAN_MIN -1
#define XDEBUG_RESOLVED_SPAN_MAX 4294967295
struct _xdebug_brk_span {
int start;
int end;
};
struct _xdebug_brk_info {
int id;
int brk_type;
int resolved;
char *classname;
char *functionname;
char *exceptionname;
int function_break_type; /* XDEBUG_BRK_FUNC_* */
char *file;
int file_len;
int original_lineno; /* line number that was set through breakpoint_set */
int resolved_lineno; /* line number after resolving, initialised with 'original_lineno' */
xdebug_brk_span resolved_span;
char *condition;
int disabled;
int temporary;
int hit_count;
int hit_value;
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);
int (*remote_deinit)(xdebug_con *h);
/* Stack messages */
int (*remote_error)(xdebug_con *h, int type, char *exception_type, char *message, const char *location, const unsigned int line, xdebug_llist *stack);
/* Breakpoints */
int (*break_on_line)(xdebug_con *h, xdebug_brk_info *brk, const char *file, int filename_len, int lineno);
int (*remote_breakpoint)(xdebug_con *h, xdebug_llist *stack, char *file, long lineno, int type, char *exception, char *code, char *message);
int (*resolve_breakpoints)(xdebug_con *h, int type, void *data);
/* Output redirection */
int (*remote_stream_output)(const char *string, unsigned int length);
/* Notifications & Logging */
int (*remote_notification)(xdebug_con *h, const char *file, long lineno, int type, char *type_string, char *message);
void XDEBUG_ATTRIBUTE_FORMAT(printf, 2, 3) (*log)(int log_level, const char *fmt, ...);
/* Eval ID registration and removal */
int (*register_eval_id)(xdebug_con *h, function_stack_entry *fse);
};
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