Debian Codegraph @

vendor/mruby-source/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h

raw
1 /*
2 ** mrdb.h - mruby debugger
3 **
4 */
5
6 #ifndef MRDB_H
7 #define MRDB_H
8
9 #include <mruby.h>
10
11 #include "mrdbconf.h"
12
13 #define MAX_COMMAND_WORD (16)
14
15 typedef enum debug_command_id {
16 DBGCMD_RUN,
17 DBGCMD_CONTINUE,
18 DBGCMD_NEXT,
19 DBGCMD_STEP,
20 DBGCMD_BREAK,
21 DBGCMD_INFO_BREAK,
22 DBGCMD_INFO_LOCAL,
23 DBGCMD_WATCH,
24 DBGCMD_INFO_WATCH,
25 DBGCMD_ENABLE,
26 DBGCMD_DISABLE,
27 DBGCMD_DELETE,
28 DBGCMD_PRINT,
29 DBGCMD_DISPLAY,
30 DBGCMD_INFO_DISPLAY,
31 DBGCMD_DELETE_DISPLAY,
32 DBGCMD_EVAL,
33 DBGCMD_BACKTRACE,
34 DBGCMD_LIST,
35 DBGCMD_HELP,
36 DBGCMD_QUIT,
37 DBGCMD_UNKNOWN
38 } debug_command_id;
39
40 typedef enum dbgcmd_state {
41 DBGST_CONTINUE,
42 DBGST_PROMPT,
43 DBGST_COMMAND_ERROR,
44 DBGST_MAX,
45 DBGST_RESTART
46 } dbgcmd_state;
47
48 typedef enum mrdb_exemode {
49 DBG_INIT,
50 DBG_RUN,
51 DBG_STEP,
52 DBG_NEXT,
53 DBG_QUIT,
54 } mrdb_exemode;
55
56 typedef enum mrdb_exephase {
57 DBG_PHASE_BEFORE_RUN,
58 DBG_PHASE_RUNNING,
59 DBG_PHASE_AFTER_RUN,
60 DBG_PHASE_RESTART,
61 } mrdb_exephase;
62
63 typedef enum mrdb_brkmode {
64 BRK_INIT,
65 BRK_BREAK,
66 BRK_STEP,
67 BRK_NEXT,
68 BRK_QUIT,
69 } mrdb_brkmode;
70
71 typedef enum {
72 MRB_DEBUG_BPTYPE_NONE,
73 MRB_DEBUG_BPTYPE_LINE,
74 MRB_DEBUG_BPTYPE_METHOD,
75 } mrb_debug_bptype;
76
77 struct mrb_irep;
78 struct mrbc_context;
79 struct mrb_debug_context;
80
81 typedef struct mrb_debug_linepoint {
82 const char *file;
83 uint16_t lineno;
84 } mrb_debug_linepoint;
85
86 typedef struct mrb_debug_methodpoint {
87 const char *class_name;
88 const char *method_name;
89 } mrb_debug_methodpoint;
90
91 typedef struct mrb_debug_breakpoint {
92 uint32_t bpno;
93 uint8_t enable;
94 mrb_debug_bptype type;
95 union point {
96 mrb_debug_linepoint linepoint;
97 mrb_debug_methodpoint methodpoint;
98 } point;
99 } mrb_debug_breakpoint;
100
101 typedef struct mrb_debug_context {
102 const struct mrb_irep *root_irep;
103 const struct mrb_irep *irep;
104 const mrb_code *pc;
105 mrb_value *regs;
106
107 const char *prvfile;
108 int32_t prvline;
109 mrb_callinfo *prvci;
110
111 mrdb_exemode xm;
112 mrdb_exephase xphase;
113 mrdb_brkmode bm;
114 int16_t bmi;
115
116 uint16_t ccnt;
117 uint16_t scnt;
118
119 mrb_debug_breakpoint bp[MAX_BREAKPOINT];
120 uint32_t bpnum;
121 int32_t next_bpno;
122 int32_t method_bpno;
123 int32_t stopped_bpno;
124 mrb_bool isCfunc;
125
126 mrdb_exemode (*break_hook)(mrb_state *mrb, struct mrb_debug_context *dbg);
127
128 } mrb_debug_context;
129
130 typedef struct mrdb_state {
131 char *command;
132 uint8_t wcnt;
133 uint8_t pi;
134 char *words[MAX_COMMAND_WORD];
135 const char *srcpath;
136 uint32_t print_no;
137
138 mrb_debug_context *dbg;
139 } mrdb_state;
140
141 typedef dbgcmd_state (*debug_command_func)(mrb_state*, mrdb_state*);
142
143 /* cmdrun.c */
144 dbgcmd_state dbgcmd_run(mrb_state*, mrdb_state*);
145 dbgcmd_state dbgcmd_continue(mrb_state*, mrdb_state*);
146 dbgcmd_state dbgcmd_step(mrb_state*, mrdb_state*);
147 dbgcmd_state dbgcmd_next(mrb_state*, mrdb_state*);
148 /* cmdbreak.c */
149 dbgcmd_state dbgcmd_break(mrb_state*, mrdb_state*);
150 dbgcmd_state dbgcmd_info_break(mrb_state*, mrdb_state*);
151 dbgcmd_state dbgcmd_info_local(mrb_state*, mrdb_state*);
152 dbgcmd_state dbgcmd_delete(mrb_state*, mrdb_state*);
153 dbgcmd_state dbgcmd_enable(mrb_state*, mrdb_state*);
154 dbgcmd_state dbgcmd_disable(mrb_state*, mrdb_state*);
155 /* cmdprint.c */
156 dbgcmd_state dbgcmd_print(mrb_state*, mrdb_state*);
157 dbgcmd_state dbgcmd_eval(mrb_state*, mrdb_state*);
158 /* cmdmisc.c */
159 dbgcmd_state dbgcmd_list(mrb_state*, mrdb_state*);
160 dbgcmd_state dbgcmd_help(mrb_state*, mrdb_state*);
161 dbgcmd_state dbgcmd_quit(mrb_state*, mrdb_state*);
162
163 #endif