source: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c@ 331

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

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 17.1 KB
RevLine 
[270]1/*
2** mrdb.c - mruby debugger
3**
4*/
5
6#include <stdlib.h>
7#include <string.h>
8#include <stdio.h>
9#include <ctype.h>
10
[331]11#include <mruby.h>
12#include <mruby/dump.h>
13#include <mruby/debug.h>
14#include <mruby/class.h>
15#include <mruby/opcode.h>
16#include <mruby/variable.h>
[270]17
18#include "mrdb.h"
19#include "apibreak.h"
20#include "apilist.h"
21
22void mrdb_state_free(mrb_state *);
23
24static mrb_debug_context *_debug_context = NULL;
25static mrdb_state *_mrdb_state = NULL;
26
27struct _args {
28 FILE *rfp;
29 char* fname;
30 char* srcpath;
31 int argc;
32 char** argv;
33 mrb_bool mrbfile : 1;
34};
35
36typedef struct debug_command {
37 const char *cmd1;
38 const char *cmd2;
39 uint8_t len1;
40 uint8_t len2;
41 uint8_t div;
42 debug_command_id id;
43 debug_command_func func;
44} debug_command;
45
46static const debug_command debug_command_list[] = {
47 {"break", NULL, 1, 0, 0, DBGCMD_BREAK, dbgcmd_break}, /* b[reak] */
48 {"continue", NULL, 1, 0, 0, DBGCMD_CONTINUE, dbgcmd_continue}, /* c[ontinue] */
49 {"delete", NULL, 1, 0, 1, DBGCMD_DELETE, dbgcmd_delete}, /* d[elete] */
50 {"disable", NULL, 3, 0, 1, DBGCMD_DISABLE, dbgcmd_disable}, /* dis[able] */
51 {"enable", NULL, 2, 0, 1, DBGCMD_ENABLE, dbgcmd_enable}, /* en[able] */
52 {"eval", NULL, 2, 0, 0, DBGCMD_EVAL, dbgcmd_eval}, /* ev[al] */
53 {"help", NULL, 1, 0, 1, DBGCMD_HELP, dbgcmd_help}, /* h[elp] */
54 {"info", "breakpoints", 1, 1, 1, DBGCMD_INFO_BREAK, dbgcmd_info_break}, /* i[nfo] b[reakpoints] */
55 {"list", NULL, 1, 0, 1, DBGCMD_LIST, dbgcmd_list}, /* l[ist] */
56 {"print", NULL, 1, 0, 0, DBGCMD_PRINT, dbgcmd_print}, /* p[rint] */
57 {"quit", NULL, 1, 0, 0, DBGCMD_QUIT, dbgcmd_quit}, /* q[uit] */
58 {"run", NULL, 1, 0, 0, DBGCMD_RUN, dbgcmd_run}, /* r[un] */
59 {"step", NULL, 1, 0, 1, DBGCMD_STEP, dbgcmd_step}, /* s[tep] */
[331]60 {"next", NULL, 1, 0, 1, DBGCMD_NEXT, dbgcmd_next}, /* n[ext] */
[270]61 {NULL}
62};
63
64
65static void
66usage(const char *name)
67{
68 static const char *const usage_msg[] = {
69 "switches:",
70 "-b load and execute RiteBinary (mrb) file",
71 "-d specify source directory",
72 "--version print the version",
73 "--copyright print the copyright",
74 NULL
75 };
76 const char *const *p = usage_msg;
77
78 printf("Usage: %s [switches] programfile\n", name);
79 while (*p) {
80 printf(" %s\n", *p++);
81 }
82}
83
84static int
85parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
86{
87 char **origargv = argv;
88 static const struct _args args_zero = { 0 };
89
90 *args = args_zero;
91
92 for (argc--,argv++; argc > 0; argc--,argv++) {
93 char *item;
94 if (argv[0][0] != '-') break;
95
96 item = argv[0] + 1;
97 switch (*item++) {
98 case 'b':
99 args->mrbfile = TRUE;
100 break;
101 case 'd':
102 if (item[0]) {
103 goto append_srcpath;
104 }
105 else if (argc > 1) {
106 argc--; argv++;
107 item = argv[0];
108append_srcpath:
109 if (!args->srcpath) {
110 size_t buflen;
111 char *buf;
112
113 buflen = strlen(item) + 1;
114 buf = (char *)mrb_malloc(mrb, buflen);
115 memcpy(buf, item, buflen);
116 args->srcpath = buf;
117 }
118 else {
119 size_t srcpathlen;
120 size_t itemlen;
121
122 srcpathlen = strlen(args->srcpath);
123 itemlen = strlen(item);
124 args->srcpath =
125 (char *)mrb_realloc(mrb, args->srcpath, srcpathlen + itemlen + 2);
126 args->srcpath[srcpathlen] = '\n';
127 memcpy(args->srcpath + srcpathlen + 1, item, itemlen + 1);
128 }
129 }
130 else {
131 printf("%s: No path specified for -d\n", *origargv);
132 return EXIT_SUCCESS;
133 }
134 break;
135 case '-':
136 if (strcmp((*argv) + 2, "version") == 0) {
137 mrb_show_version(mrb);
138 exit(EXIT_SUCCESS);
139 }
140 else if (strcmp((*argv) + 2, "copyright") == 0) {
141 mrb_show_copyright(mrb);
142 exit(EXIT_SUCCESS);
143 }
144 default:
145 return EXIT_FAILURE;
146 }
147 }
148
149 if (args->rfp == NULL) {
150 if (*argv == NULL) {
151 printf("%s: Program file not specified.\n", *origargv);
152 return EXIT_FAILURE;
153 }
154 else {
155 args->rfp = fopen(argv[0], args->mrbfile ? "rb" : "r");
156 if (args->rfp == NULL) {
157 printf("%s: Cannot open program file. (%s)\n", *origargv, *argv);
158 return EXIT_FAILURE;
159 }
160 args->fname = argv[0];
161 argc--; argv++;
162 }
163 }
164 args->argv = (char **)mrb_realloc(mrb, args->argv, sizeof(char*) * (argc + 1));
165 memcpy(args->argv, argv, (argc+1) * sizeof(char*));
166 args->argc = argc;
167
168 return EXIT_SUCCESS;
169}
170
171static void
172cleanup(mrb_state *mrb, struct _args *args)
173{
174 if (args->rfp)
175 fclose(args->rfp);
176 if (args->srcpath)
177 mrb_free(mrb, args->srcpath);
178 if (args->argv)
179 mrb_free(mrb, args->argv);
180 mrdb_state_free(mrb);
181 mrb_close(mrb);
182}
183
184static mrb_debug_context*
185mrb_debug_context_new(mrb_state *mrb)
186{
187 mrb_debug_context *dbg = mrb_malloc(mrb, sizeof(mrb_debug_context));
188
189 memset(dbg, 0, sizeof(mrb_debug_context));
190
191 dbg->xm = DBG_INIT;
192 dbg->xphase = DBG_PHASE_BEFORE_RUN;
193 dbg->next_bpno = 1;
194
195 return dbg;
196}
197
198mrb_debug_context*
199mrb_debug_context_get(mrb_state *mrb)
200{
201 if (!_debug_context) {
202 _debug_context = mrb_debug_context_new(mrb);
203 }
204 return _debug_context;
205}
206
207void
208mrb_debug_context_set(mrb_debug_context *dbg)
209{
210 _debug_context = dbg;
211}
212
213void
214mrb_debug_context_free(mrb_state *mrb)
215{
216 if (_debug_context) {
217 mrb_debug_delete_break_all(mrb, _debug_context);
218 mrb_free(mrb, _debug_context);
219 _debug_context = NULL;
220 }
221}
222
223static mrdb_state*
224mrdb_state_new(mrb_state *mrb)
225{
226 mrdb_state *mrdb = mrb_malloc(mrb, sizeof(mrdb_state));
227
228 memset(mrdb, 0, sizeof(mrdb_state));
229
230 mrdb->dbg = mrb_debug_context_get(mrb);
231 mrdb->command = mrb_malloc(mrb, MAX_COMMAND_LINE+1);
232 mrdb->print_no = 1;
233
234 return mrdb;
235}
236
237mrdb_state*
238mrdb_state_get(mrb_state *mrb)
239{
240 if (!_mrdb_state) {
241 _mrdb_state = mrdb_state_new(mrb);
242 }
243 return _mrdb_state;
244}
245
246void
247mrdb_state_set(mrdb_state *mrdb)
248{
249 _mrdb_state = mrdb;
250}
251
252void
253mrdb_state_free(mrb_state *mrb)
254{
255 mrb_debug_context_free(mrb);
256 if (_mrdb_state) {
257 mrb_free(mrb, _mrdb_state->command);
258 mrb_free(mrb, _mrdb_state);
259 _mrdb_state = NULL;
260 }
261}
262
263static char*
264get_command(mrb_state *mrb, mrdb_state *mrdb)
265{
266 int i;
267 int c;
268
269 for (i=0; i<MAX_COMMAND_LINE; i++) {
270 if ((c=getchar()) == EOF || c == '\n') break;
271 mrdb->command[i] = c;
272 }
273
274 if (i == 0 && feof(stdin)) {
275 clearerr(stdin);
276 strcpy(mrdb->command, "quit");
277 i += sizeof("quit") - 1;
278 }
279
280 if (i == MAX_COMMAND_LINE) {
281 for ( ; (c=getchar()) != EOF && c !='\n'; i++) ;
282 }
283
284 if (i > MAX_COMMAND_LINE) {
285 printf("command line too long.\n");
286 i = 0; /* discard command data */
287 }
288 mrdb->command[i] = '\0';
289
290 return mrdb->command;
291}
292
293static char*
294pick_out_word(mrb_state *mrb, char **pp)
295{
296 char *ps;
297
298 for (ps=*pp; ISBLANK(*ps); ps++) ;
299 if (*ps == '\0') {
300 return NULL;
301 }
302
303 if (*ps == '\"' || *ps == '\'') {
304 *pp = strchr(ps+1, *ps);
305 if (*pp) (*pp)++;
306 }
307 else {
308 *pp = strpbrk(ps, " \t");
309 }
310
311 if (!*pp) {
312 *pp = ps + strlen(ps);
313 }
314
315 if (**pp != '\0') {
316 **pp = '\0';
317 (*pp)++;
318 }
319
320 return ps;
321}
322
323static debug_command*
324parse_command(mrb_state *mrb, mrdb_state *mrdb, char *buf)
325{
326 debug_command *cmd = NULL;
327 char *p = buf;
328 size_t wlen;
329
330 /* get word #1 */
331 mrdb->words[0] = pick_out_word(mrb, &p);
332 if (!mrdb->words[0]) {
333 return NULL;
334 }
335 mrdb->wcnt = 1;
336 /* set remain parameter */
337 for ( ; *p && ISBLANK(*p); p++) ;
338 if (*p) {
339 mrdb->words[mrdb->wcnt++] = p;
340 }
341
342 /* check word #1 */
343 for (cmd=(debug_command*)debug_command_list; cmd->cmd1; cmd++) {
344 wlen = strlen(mrdb->words[0]);
345 if (wlen >= cmd->len1 &&
346 strncmp(mrdb->words[0], cmd->cmd1, wlen) == 0) {
347 break;
348 }
349 }
350
351 if (cmd->cmd2) {
352 if (mrdb->wcnt > 1) {
353 /* get word #2 */
354 mrdb->words[1] = pick_out_word(mrb, &p);
355 if (mrdb->words[1]) {
356 /* update remain parameter */
357 for ( ; *p && ISBLANK(*p); p++) ;
358 if (*p) {
359 mrdb->words[mrdb->wcnt++] = p;
360 }
361 }
362 }
363
364 /* check word #1,#2 */
365 for ( ; cmd->cmd1; cmd++) {
366 wlen = strlen(mrdb->words[0]);
367 if (wlen < cmd->len1 ||
368 strncmp(mrdb->words[0], cmd->cmd1, wlen)) {
369 continue;
370 }
371
372 if (!cmd->cmd2) break; /* word #1 only */
373
374 if (mrdb->wcnt == 1) continue; /* word #2 not specified */
375
376 wlen = strlen(mrdb->words[1]);
377 if (wlen >= cmd->len2 &&
378 strncmp(mrdb->words[1], cmd->cmd2, wlen) == 0) {
379 break; /* word #1 and #2 */
380 }
381 }
382 }
383
384 /* divide remain parameters */
385 if (cmd->cmd1 && cmd->div) {
386 p = mrdb->words[--mrdb->wcnt];
387 for ( ; mrdb->wcnt<MAX_COMMAND_WORD; mrdb->wcnt++) {
388 mrdb->words[mrdb->wcnt] = pick_out_word(mrb, &p);
389 if (!mrdb->words[mrdb->wcnt]) {
390 break;
391 }
392 }
393 }
394
395 return cmd->cmd1 ? cmd : NULL;
396}
397
398static void
399print_info_stopped_break(mrb_state *mrb, mrdb_state *mrdb)
400{
401 mrb_debug_breakpoint bp;
402 int32_t ret;
403 uint16_t lineno;
404 const char *file;
405 const char *method_name;
406 const char *class_name;
407
408 ret = mrb_debug_get_break(mrb, mrdb->dbg, mrdb->dbg->stopped_bpno, &bp);
[331]409 if (ret == 0) {
[270]410 switch(bp.type) {
411 case MRB_DEBUG_BPTYPE_LINE:
412 file = bp.point.linepoint.file;
413 lineno = bp.point.linepoint.lineno;
414 printf("Breakpoint %d, at %s:%d\n", bp.bpno, file, lineno);
415 break;
416 case MRB_DEBUG_BPTYPE_METHOD:
417 method_name = bp.point.methodpoint.method_name;
418 class_name = bp.point.methodpoint.class_name;
[331]419 if (class_name == NULL) {
[270]420 printf("Breakpoint %d, %s\n", bp.bpno, method_name);
421 }
422 else {
423 printf("Breakpoint %d, %s:%s\n", bp.bpno, class_name, method_name);
424 }
[331]425 if (mrdb->dbg->isCfunc) {
[270]426 printf("Stopped before calling the C function.\n");
427 }
428 break;
429 default:
430 break;
431 }
432 }
433}
434
435static void
436print_info_stopped_step_next(mrb_state *mrb, mrdb_state *mrdb)
437{
438 const char* file = mrdb->dbg->prvfile;
439 uint16_t lineno = mrdb->dbg->prvline;
440 printf("%s:%d\n", file, lineno);
441}
442
443static void
444print_info_stopped_code(mrb_state *mrb, mrdb_state *mrdb)
445{
446 char* file = mrb_debug_get_source(mrb, mrdb, mrdb->srcpath, mrdb->dbg->prvfile);
447 uint16_t lineno = mrdb->dbg->prvline;
[331]448 if (file != NULL) {
[270]449 mrb_debug_list(mrb, mrdb->dbg, file, lineno, lineno);
450 mrb_free(mrb, file);
451 }
452}
453
454static void
455print_info_stopped(mrb_state *mrb, mrdb_state *mrdb)
456{
457 switch(mrdb->dbg->bm) {
458 case BRK_BREAK:
459 print_info_stopped_break(mrb, mrdb);
460 print_info_stopped_code(mrb, mrdb);
461 break;
462 case BRK_STEP:
463 case BRK_NEXT:
464 print_info_stopped_step_next(mrb, mrdb);
465 print_info_stopped_code(mrb, mrdb);
466 break;
467 default:
468 break;
469 }
470}
471
472static debug_command*
473get_and_parse_command(mrb_state *mrb, mrdb_state *mrdb)
474{
475 debug_command *cmd = NULL;
476 char *p;
477 int i;
478
479 while (!cmd) {
480 for (p=NULL; !p || *p=='\0'; ) {
481 printf("(%s:%d) ", mrdb->dbg->prvfile, mrdb->dbg->prvline);
482 fflush(stdout);
483 p = get_command(mrb, mrdb);
484 }
485
486 cmd = parse_command(mrb, mrdb, p);
487#ifdef _DBG_MRDB_PARSER_
488 for (i=0; i<mrdb->wcnt; i++) {
489 printf("%d: %s\n", i, mrdb->words[i]);
490 }
491#endif
492 if (!cmd) {
493 printf("invalid command (");
494 for (i=0; i<mrdb->wcnt; i++) {
495 if (i>0) {
496 printf(" ");
497 }
498 printf("%s", mrdb->words[i]);
499 }
500 puts(")");
501 }
502 }
503 return cmd;
504}
505
506static int32_t
507check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value *regs)
508{
509 struct RClass* c;
510 mrb_sym sym;
511 int32_t bpno;
512 mrb_bool isCfunc;
513
514 mrb_debug_context *dbg = mrb_debug_context_get(mrb);
515
516 isCfunc = FALSE;
517 bpno = dbg->method_bpno;
518 dbg->method_bpno = 0;
519
520 switch(GET_OPCODE(*pc)) {
521 case OP_SEND:
522 case OP_SENDB:
523 c = mrb_class(mrb, regs[GETARG_A(*pc)]);
524 sym = irep->syms[GETARG_B(*pc)];
525 break;
526 case OP_SUPER:
527 c = mrb->c->ci->target_class->super;
528 sym = mrb->c->ci->mid;
529 break;
530 default:
531 sym = 0;
532 break;
533 }
[331]534 if (sym != 0) {
[270]535 dbg->method_bpno = mrb_debug_check_breakpoint_method(mrb, dbg, c, sym, &isCfunc);
[331]536 if (isCfunc) {
[270]537 bpno = dbg->method_bpno;
538 dbg->method_bpno = 0;
539 }
540 }
541 dbg->isCfunc = isCfunc;
542 return bpno;
543}
544
545static void
546mrb_code_fetch_hook(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value *regs)
547{
548 const char *file;
549 int32_t line;
550 int32_t bpno;
551
552 mrb_debug_context *dbg = mrb_debug_context_get(mrb);
553
554 mrb_assert(dbg);
555
556 dbg->irep = irep;
557 dbg->pc = pc;
558 dbg->regs = regs;
559
[331]560 if (dbg->xphase == DBG_PHASE_RESTART) {
[270]561 dbg->root_irep = irep;
562 dbg->prvfile = NULL;
563 dbg->prvline = 0;
[331]564 dbg->prvci = NULL;
[270]565 dbg->xm = DBG_RUN;
566 dbg->xphase = DBG_PHASE_RUNNING;
567 }
568
569 file = mrb_debug_get_filename(irep, (uint32_t)(pc - irep->iseq));
570 line = mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq));
571
572 switch (dbg->xm) {
573 case DBG_STEP:
574 if (!file || (dbg->prvfile == file && dbg->prvline == line)) {
575 return;
576 }
577 dbg->method_bpno = 0;
578 dbg->bm = BRK_STEP;
579 break;
580
[331]581 case DBG_NEXT:
582 if (!file || (dbg->prvfile == file && dbg->prvline == line)) {
583 return;
584 }
585 if ((intptr_t)(dbg->prvci) < (intptr_t)(mrb->c->ci)) {
586 return;
587 }
588 dbg->prvci = NULL;
589 dbg->method_bpno = 0;
590 dbg->bm = BRK_NEXT;
591 break;
592
[270]593 case DBG_RUN:
594 bpno = check_method_breakpoint(mrb, irep, pc, regs);
595 if (bpno > 0) {
596 dbg->stopped_bpno = bpno;
597 dbg->bm = BRK_BREAK;
598 break;
599 }
600 if (dbg->prvfile != file || dbg->prvline != line) {
601 bpno = mrb_debug_check_breakpoint_line(mrb, dbg, file, line);
602 if (bpno > 0) {
603 dbg->stopped_bpno = bpno;
604 dbg->bm = BRK_BREAK;
605 break;
606 }
607 }
608 dbg->prvfile = file;
609 dbg->prvline = line;
610 return;
611 case DBG_INIT:
612 dbg->root_irep = irep;
613 dbg->bm = BRK_INIT;
614 if (!file || line < 0) {
615 puts("Cannot get debugging information.");
616 }
617 break;
618
619 default:
620 return;
621 }
622
623 dbg->prvfile = file;
624 dbg->prvline = line;
625
[331]626 if (dbg->bm == BRK_BREAK && --dbg->ccnt > 0) {
[270]627 return;
628 }
629 dbg->break_hook(mrb, dbg);
630
631 dbg->xphase = DBG_PHASE_RUNNING;
632}
633
634static mrdb_exemode
635mrb_debug_break_hook(mrb_state *mrb, mrb_debug_context *dbg)
636{
637 debug_command *cmd;
638 dbgcmd_state st = DBGST_CONTINUE;
639 mrdb_state *mrdb = mrdb_state_get(mrb);
640
641 print_info_stopped(mrb, mrdb);
642
643 while (1) {
644 cmd = get_and_parse_command(mrb, mrdb);
645 mrb_assert(cmd);
646
647 st = cmd->func(mrb, mrdb);
648
[331]649 if ((st == DBGST_CONTINUE) || (st == DBGST_RESTART)) break;
[270]650 }
651 return dbg->xm;
652}
653
654int
655main(int argc, char **argv)
656{
657 mrb_state *mrb = mrb_open();
658 int n = -1;
659 struct _args args;
660 mrb_value v;
661 mrdb_state *mrdb;
662 mrdb_state *mrdb_backup;
663 mrb_debug_context* dbg_backup;
664 debug_command *cmd;
665
666 l_restart:
667
668 if (mrb == NULL) {
669 fputs("Invalid mrb_state, exiting mruby\n", stderr);
670 return EXIT_FAILURE;
671 }
672
673 /* parse command parameters */
674 n = parse_args(mrb, argc, argv, &args);
675 if (n == EXIT_FAILURE || args.rfp == NULL) {
676 cleanup(mrb, &args);
677 usage(argv[0]);
678 return n;
679 }
680
681 /* initialize debugger information */
682 mrdb = mrdb_state_get(mrb);
683 mrb_assert(mrdb && mrdb->dbg);
684 mrdb->srcpath = args.srcpath;
685
[331]686 if (mrdb->dbg->xm == DBG_QUIT) {
[270]687 mrdb->dbg->xphase = DBG_PHASE_RESTART;
688 }
689 else {
690 mrdb->dbg->xphase = DBG_PHASE_BEFORE_RUN;
691 }
692 mrdb->dbg->xm = DBG_INIT;
693 mrdb->dbg->ccnt = 1;
[331]694
[270]695 /* setup hook functions */
696 mrb->code_fetch_hook = mrb_code_fetch_hook;
697 mrdb->dbg->break_hook = mrb_debug_break_hook;
698
699 if (args.mrbfile) { /* .mrb */
700 v = mrb_load_irep_file(mrb, args.rfp);
701 }
702 else { /* .rb */
703 mrbc_context *cc = mrbc_context_new(mrb);
704 mrbc_filename(mrb, cc, args.fname);
705 v = mrb_load_file_cxt(mrb, args.rfp, cc);
706 mrbc_context_free(mrb, cc);
707 }
708 if (mrdb->dbg->xm == DBG_QUIT && !mrb_undef_p(v) && mrb->exc) {
709 const char *classname = mrb_obj_classname(mrb, mrb_obj_value(mrb->exc));
710 if (!strcmp(classname, "DebuggerExit")) {
711 cleanup(mrb, &args);
712 return 0;
713 }
714 if (!strcmp(classname, "DebuggerRestart")) {
715 mrdb_backup = mrdb_state_get(mrb);
716 dbg_backup = mrb_debug_context_get(mrb);
717
718 mrdb_state_set(NULL);
719 mrb_debug_context_set(NULL);
720
721 cleanup(mrb, &args);
722 mrb = mrb_open();
723
724 mrdb_state_set(mrdb_backup);
725 mrb_debug_context_set(dbg_backup);
726
727 goto l_restart;
728 }
729 }
730 puts("mruby application exited.");
731 mrdb->dbg->xphase = DBG_PHASE_AFTER_RUN;
732 if (!mrb_undef_p(v)) {
733 if (mrb->exc) {
734 mrb_print_error(mrb);
735 }
736 else {
737 printf(" => ");
738 mrb_p(mrb, v);
739 }
740 }
[331]741
[270]742 mrdb->dbg->prvfile = "-";
743 mrdb->dbg->prvline = 0;
[331]744
[270]745 while (1) {
746 cmd = get_and_parse_command(mrb, mrdb);
747 mrb_assert(cmd);
[331]748
[270]749 if (cmd->id == DBGCMD_QUIT) {
750 break;
751 }
[331]752
753 if ( cmd->func(mrb, mrdb) == DBGST_RESTART ) goto l_restart;
[270]754 }
[331]755
[270]756 cleanup(mrb, &args);
757
758 return 0;
759}
Note: See TracBrowser for help on using the repository browser.