w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

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