source: EcnlProtoTool/trunk/prototool/src/mrdb.h@ 279

Last change on this file since 279 was 279, checked in by coas-nagasima, 7 years ago

ファイルを追加、更新。

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 3.7 KB
Line 
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
15typedef 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_WATCH,
23 DBGCMD_INFO_WATCH,
24 DBGCMD_ENABLE,
25 DBGCMD_DISABLE,
26 DBGCMD_DELETE,
27 DBGCMD_PRINT,
28 DBGCMD_DISPLAY,
29 DBGCMD_INFO_DISPLAY,
30 DBGCMD_DELETE_DISPLAY,
31 DBGCMD_EVAL,
32 DBGCMD_BACKTRACE,
33 DBGCMD_LIST,
34 DBGCMD_HELP,
35 DBGCMD_QUIT,
36 DBGCMD_UNKNOWN
37} debug_command_id;
38
39typedef enum dbgcmd_state {
40 DBGST_CONTINUE,
41 DBGST_PROMPT,
42 DBGST_COMMAND_ERROR,
43 DBGST_MAX,
44 DBGST_RESTART
45} dbgcmd_state;
46
47typedef enum mrdb_exemode {
48 DBG_INIT,
49 DBG_RUN,
50 DBG_STEP,
51 DBG_NEXT,
52 DBG_QUIT,
53} mrdb_exemode;
54
55#ifdef _MSC_VER
56# define __func__ __FUNCTION__
57extern long __stdcall InterlockedExchange(long *dst, long src);
58extern long __stdcall InterlockedCompareExchange(long *dst, long src, long cmp);
59#else
60#define InterlockedExchange(dst, src) do { *(dst) = src; } while(0)
61__inline__ static enum mrdb_exemode InterlockedCompareExchange(enum mrdb_exemode *dst, enum mrdb_exemode src, enum mrdb_exemode cmp) { long prev = *(dst); if (*(dst) == cmp) *(dst) = src; return prev; }
62#endif
63
64typedef enum mrdb_exephase {
65 DBG_PHASE_BEFORE_RUN,
66 DBG_PHASE_RUNNING,
67 DBG_PHASE_AFTER_RUN,
68 DBG_PHASE_RESTART,
69} mrdb_exephase;
70
71typedef enum mrdb_brkmode {
72 BRK_INIT,
73 BRK_BREAK,
74 BRK_STEP,
75 BRK_NEXT,
76 BRK_QUIT,
77} mrdb_brkmode;
78
79typedef enum {
80 MRB_DEBUG_BPTYPE_NONE,
81 MRB_DEBUG_BPTYPE_LINE,
82 MRB_DEBUG_BPTYPE_METHOD,
83} mrb_debug_bptype;
84
85struct mrb_irep;
86struct mrbc_context;
87struct mrb_debug_context;
88
89typedef struct mrb_debug_linepoint {
90 const char *file;
91 uint16_t lineno;
92} mrb_debug_linepoint;
93
94typedef struct mrb_debug_methodpoint {
95 const char *class_name;
96 const char *method_name;
97} mrb_debug_methodpoint;
98
99typedef struct mrb_debug_breakpoint {
100 uint32_t bpno;
101 uint8_t enable;
102 mrb_debug_bptype type;
103 union point {
104 mrb_debug_linepoint linepoint;
105 mrb_debug_methodpoint methodpoint;
106 } point;
107} mrb_debug_breakpoint;
108
109typedef struct mrb_debug_context {
110 struct mrb_irep *root_irep;
111 struct mrb_irep *irep;
112 mrb_code *pc;
113 mrb_value *regs;
114
115 const char *prvfile;
116 int32_t prvline;
117 mrb_callinfo *prvci;
118
119#ifdef _MSC_VER
120 long xm;
121#else
122 mrdb_exemode xm;
123#endif
124 mrdb_exephase xphase;
125 mrdb_brkmode bm;
126 int16_t bmi;
127
128 uint16_t ccnt;
129 uint16_t scnt;
130
131 mrb_debug_breakpoint bp[MAX_BREAKPOINT];
132 uint32_t bpnum;
133 int32_t next_bpno;
134 int32_t method_bpno;
135 int32_t stopped_bpno;
136 mrb_bool isCfunc;
137
138 mrdb_exemode (*break_hook)(mrb_state *mrb, struct mrb_debug_context *dbg);
139
140} mrb_debug_context;
141
142typedef struct mrdb_state {
143 char *command;
144 uint8_t wcnt;
145 uint8_t pi;
146 char *words[MAX_COMMAND_WORD];
147 const char *srcpath;
148 uint32_t print_no;
149
150 mrb_debug_context *dbg;
151} mrdb_state;
152
153typedef dbgcmd_state (*debug_command_func)(mrb_state*, mrdb_state*);
154
155/* cmdrun.c */
156dbgcmd_state dbgcmd_run(mrb_state*, mrdb_state*);
157dbgcmd_state dbgcmd_continue(mrb_state*, mrdb_state*);
158dbgcmd_state dbgcmd_step(mrb_state*, mrdb_state*);
159dbgcmd_state dbgcmd_next(mrb_state*, mrdb_state*);
160/* cmdbreak.c */
161dbgcmd_state dbgcmd_break(mrb_state*, mrdb_state*);
162dbgcmd_state dbgcmd_info_break(mrb_state*, mrdb_state*);
163dbgcmd_state dbgcmd_delete(mrb_state*, mrdb_state*);
164dbgcmd_state dbgcmd_enable(mrb_state*, mrdb_state*);
165dbgcmd_state dbgcmd_disable(mrb_state*, mrdb_state*);
166/* cmdprint.c */
167dbgcmd_state dbgcmd_print(mrb_state*, mrdb_state*);
168dbgcmd_state dbgcmd_eval(mrb_state*, mrdb_state*);
169/* cmdmisc.c */
170dbgcmd_state dbgcmd_help(mrb_state*, mrdb_state*);
171dbgcmd_state dbgcmd_quit(mrb_state*, mrdb_state*);
172
173#endif
Note: See TracBrowser for help on using the repository browser.