Пример #1
0
/*
 * f_prtmtab - Prints out a header, then entries from both magic
 *	tables, mtab1 and mtab2, if any exist.
 */
void
f_prtmtab(void)
{
	Entry	*mtab;
	Entry	*ep;
	int	count;

	(void) printf("%-7s %-7s %-10s %-7s %-11s %s\n",
		"level", "off", "type", "opcode", "value", "string");
	for (mtab = mtab1, count = 1; count <= 2; count++, mtab = mtab2) {
		if (mtab == (Entry *)NULL) {
			continue;
		}
		for (ep = mtab; ep->e_off != -1L; ep++) {
			(void) printf("%-7d %-7ld %-10s %-7c ",
			    ep->e_level,
			    ep->e_off, type_to_name(ep),
			    op_to_name(ep->e_opcode));
			if (ep->e_type == STR) {
				showstr(ep->e_value.str, 10);
			} else {	/* numeric */
				(void) printf("%-#11llo", ep->e_value.num);
			}
			(void) printf(" %s", ep->e_str);
			if (ep->e_opcode & SUB)
				(void) printf("\tsubst");
			(void) printf("\n");
		}
	}
}
Пример #2
0
void dump(struct uState* S, uint8_t* pc, int len) {
  uint8_t* end = pc + len;
  while (pc < end) {
    // If the high bit is set, it's an opcode index.
    if (*pc & 0x80) {
      printf(" %s", op_to_name(S, *pc++));
      continue;
    }
    // Otherwise it's a variable length encoded integer.
    number val = *pc & 0x3f;
    if (*pc++ & 0x40) {
      int b = 6;
      do {
        val |= (number)(*pc & 0x7f) << b;
        b += 7;
      } while (*pc++ & 0x80);
    }
    printf(" %"PRId64, val);
  }
}