PARROT_EXPORT void PackFile_Fixup_dump(PARROT_INTERP, ARGIN(const PackFile_FixupTable *ft)) { ASSERT_ARGS(PackFile_Fixup_dump) opcode_t i; for (i = 0; i < ft->fixup_count; i++) { Parrot_io_printf(interp, "\t#%d\n", (int) i); switch (ft->fixups[i]->type) { case enum_fixup_label: case enum_fixup_sub: Parrot_io_printf(interp, "\ttype => %d offs => %8d name => '%s',\n", (int)ft->fixups[i]->type, (int)ft->fixups[i]->offset, ft->fixups[i]->name); break; default: Parrot_io_printf(interp, "\ttype => %d ???,\n", (int) ft->fixups[i]->type); break; } } }
static void const_dump(PARROT_INTERP, const PackFile_Segment *segp) { Parrot_io_printf(interp, "%Ss => [\n", segp->name); PackFile_ConstTable_dump(interp, (const PackFile_ConstTable *)segp); Parrot_io_printf(interp, "],\n"); }
static void disas_dump(PARROT_INTERP, const PackFile_Segment *self) { const opcode_t *pc = self->data; const PackFile_ByteCode_OpMapping *map = &((const PackFile_ByteCode *)self)->op_mapping; INTVAL i; Parrot_io_printf(interp, "%Ss => [ # %d ops at offs 0x%x\n", self->name, (int)self->size, (int)self->file_offset + 4); for (i = 0; i < map->n_libs; i++) { INTVAL j, lib_num, table_num; PackFile_ByteCode_OpMappingEntry *entry = &map->libs[i]; Parrot_io_printf(interp, " map #%d => [\n", i); Parrot_io_printf(interp, " oplib: \"%s\" version %d.%d.%d (%d ops)\n", entry->lib->name, entry->lib->major_version, entry->lib->minor_version, entry->lib->patch_version, entry->n_ops); for (j = 0; j < map->libs[i].n_ops; j++) { lib_num = entry->lib_ops[j]; table_num = entry->table_ops[j]; Parrot_io_printf(interp, " %08lx => %08lx (%s)\n", table_num, lib_num, entry->lib->op_info_table[lib_num].full_name); } Parrot_io_printf(interp, " ]\n"); } while (pc < self->data + self->size) { /* n can't be const; the ADD_OP_VAR_PART macro increments it */ size_t n = (size_t)interp->code->op_info_table[*pc]->op_count; size_t i; /* trace_op_dump(interp, self->pf->src, pc); */ Parrot_io_printf(interp, " %04x: ", (int)(pc - self->data)); for (i = 0; i < 6; ++i) if (i < n) Parrot_io_printf(interp, "%08lx ", (unsigned long)pc[i]); else Parrot_io_printf(interp, " "); Parrot_io_printf(interp, "%s\n", interp->code->op_info_table[*pc]->full_name); ADD_OP_VAR_PART(interp, interp->code, pc, n); pc += n; } Parrot_io_printf(interp, "]\n"); }
static void pf_const_dump_str(PARROT_INTERP, ARGIN(const STRING *self)) { ASSERT_ARGS(pf_const_dump_str) Parrot_io_printf(interp, " [ 'PFC_STRING', {\n"); pobj_flag_dump(interp, (long)PObj_get_FLAGS(self)); Parrot_io_printf(interp, " ENCODING => %s,\n", self->encoding->name); Parrot_io_printf(interp, " SIZE => %ld,\n", self->bufused); Parrot_io_printf(interp, " DATA => \"%Ss\"\n", Parrot_str_escape(interp, self)); Parrot_io_printf(interp, " } ],\n"); }
static void pobj_flag_dump(PARROT_INTERP, long flags) { ASSERT_ARGS(pobj_flag_dump) INTVAL idx = 0; int printed_flag_p = 0; Parrot_io_printf(interp, "\tFLAGS => 0x%04lx (", flags); while (flags) { if (flags & 1) { if (printed_flag_p) Parrot_io_printf(interp, ","); Parrot_io_printf(interp, "%s", flag_bit_names[idx]); printed_flag_p++; } idx++; flags >>= 1; } Parrot_io_printf(interp, ")\n"); }
PARROT_EXPORT void PackFile_ConstTable_dump(PARROT_INTERP, ARGIN(const PackFile_ConstTable *self)) { ASSERT_ARGS(PackFile_ConstTable_dump) opcode_t i; for (i = 0; i < self->const_count; i++) { Parrot_io_printf(interp, " # %ld:\n", (long)i); PackFile_Constant_dump(interp, self, self->constants[i]); } }
void pf_const_dump(PARROT_INTERP, ARGIN(const PackFile_ConstTable *self)) { ASSERT_ARGS(pf_const_dump) opcode_t i; for (i = 0; i < self->num.const_count; i++) { Parrot_io_printf(interp, " # %lx:\n", (long)i); Parrot_io_printf(interp, " [ 'PFC_NUMBER', %g ],\n", self->num.constants[i]); } for (i = 0; i < self->str.const_count; i++) { Parrot_io_printf(interp, " # %lx:\n", (long)i); pf_const_dump_str(interp, self->str.constants[i]); } for (i = 0; i < self->pmc.const_count; i++) { Parrot_io_printf(interp, " # %lx:\n", (long)i); pf_const_dump_pmc(interp, self, self->pmc.constants[i]); } }
static void disas_dump(PARROT_INTERP, const PackFile_Segment *self) { const opcode_t *pc = self->data; Parrot_io_printf(interp, "%Ss => [ # %d ops at offs 0x%x\n", self->name, (int)self->size, (int)self->file_offset + 4); while (pc < self->data + self->size) { /* n can't be const; the ADD_OP_VAR_PART macro increments it */ size_t n = (size_t)interp->op_info_table[*pc].op_count; size_t i; /* trace_op_dump(interp, self->pf->src, pc); */ Parrot_io_printf(interp, " %04x: ", (int)(pc - self->data)); for (i = 0; i < 6; ++i) if (i < n) Parrot_io_printf(interp, "%08lx ", (unsigned long)pc[i]); else Parrot_io_printf(interp, " "); Parrot_io_printf(interp, "%s\n", interp->op_info_table[*pc].full_name); ADD_OP_VAR_PART(interp, interp->code, pc, n); pc += n; } Parrot_io_printf(interp, "]\n"); }
static void nums_dump(PARROT_INTERP, const PackFile_Segment *self) { const STRING *debug_name = Parrot_str_concat(interp, self->name, Parrot_str_new_constant(interp, "_DB")); const PackFile_Segment *debug = PackFile_find_segment(interp, self->dir, debug_name, 1); opcode_t * pc = self->data; opcode_t * debug_ops = debug->data; op_info_t ** const op_info = interp->code->op_info_table; while (pc < self->data + self->size) { /* n can't be const; the ADD_OP_VAR_PART macro increments it */ size_t n = (size_t)op_info[*pc]->op_count; Parrot_io_printf(interp, " %04x: %s\n", *(debug_ops++), op_info[*pc]->full_name); ADD_OP_VAR_PART(interp, interp->code, pc, n); pc += n; } }
static void PackFile_Constant_dump(PARROT_INTERP, ARGIN(const PackFile_ConstTable *ct), ARGIN(const PackFile_Constant *self)) { ASSERT_ARGS(PackFile_Constant_dump) PMC *key; size_t i; switch (self->type) { case PFC_NUMBER: Parrot_io_printf(interp, " [ 'PFC_NUMBER', %g ],\n", self->u.number); break; case PFC_STRING: Parrot_io_printf(interp, " [ 'PFC_STRING', {\n"); pobj_flag_dump(interp, (long)PObj_get_FLAGS(self->u.string)); Parrot_io_printf(interp, " CHARSET => %ld,\n", self->u.string->charset); i = self->u.string->bufused; Parrot_io_printf(interp, " SIZE => %ld,\n", (long)i); Parrot_io_printf(interp, " DATA => \"%Ss\"\n", Parrot_str_escape(interp, self->u.string)); Parrot_io_printf(interp, " } ],\n"); break; case PFC_KEY: for (i = 0, key = self->u.key; key; i++) { GETATTR_Key_next_key(interp, key, key); } /* number of key components */ Parrot_io_printf(interp, " [ 'PFC_KEY' (%ld items)\n", i); /* and now type / value per component */ for (key = self->u.key; key;) { opcode_t type = PObj_get_FLAGS(key); Parrot_io_printf(interp, " {\n"); type &= KEY_type_FLAGS; pobj_flag_dump(interp, (long)PObj_get_FLAGS(key)); switch (type) { case KEY_integer_FLAG: Parrot_io_printf(interp, " TYPE => INTEGER\n"); Parrot_io_printf(interp, " DATA => %ld\n", VTABLE_get_integer(interp, key)); Parrot_io_printf(interp, " },\n"); break; case KEY_number_FLAG: { const PackFile_Constant *detail; size_t ct_index; Parrot_io_printf(interp, " TYPE => NUMBER\n"); ct_index = PackFile_find_in_const(interp, ct, key, PFC_NUMBER); Parrot_io_printf(interp, " PFC_OFFSET => %ld\n", ct_index); detail = ct->constants[ct_index]; Parrot_io_printf(interp, " DATA => %ld\n", detail->u.number); Parrot_io_printf(interp, " },\n"); } break; case KEY_string_FLAG: { const PackFile_Constant *detail; size_t ct_index; Parrot_io_printf(interp, " TYPE => STRING\n"); ct_index = PackFile_find_in_const(interp, ct, key, PFC_STRING); Parrot_io_printf(interp, " PFC_OFFSET => %ld\n", ct_index); detail = ct->constants[ct_index]; Parrot_io_printf(interp, " DATA => '%Ss'\n", detail->u.string); Parrot_io_printf(interp, " },\n"); } break; case KEY_integer_FLAG | KEY_register_FLAG: Parrot_io_printf(interp, " TYPE => I REGISTER\n"); Parrot_io_printf(interp, " DATA => %ld\n", VTABLE_get_integer(interp, key)); Parrot_io_printf(interp, " },\n"); break; case KEY_number_FLAG | KEY_register_FLAG: Parrot_io_printf(interp, " TYPE => N REGISTER\n"); Parrot_io_printf(interp, " DATA => %ld\n", VTABLE_get_integer(interp, key)); Parrot_io_printf(interp, " },\n"); break; case KEY_string_FLAG | KEY_register_FLAG: Parrot_io_printf(interp, " TYPE => S REGISTER\n"); Parrot_io_printf(interp, " DATA => %ld\n", VTABLE_get_integer(interp, key)); Parrot_io_printf(interp, " },\n"); break; case KEY_pmc_FLAG | KEY_register_FLAG: Parrot_io_printf(interp, " TYPE => P REGISTER\n"); Parrot_io_printf(interp, " DATA => %ld\n", VTABLE_get_integer(interp, key)); Parrot_io_printf(interp, " },\n"); break; default: Parrot_io_eprintf(NULL, "PackFile_Constant_pack: " "unsupported constant type\n"); Parrot_exit(interp, 1); } GETATTR_Key_next_key(interp, key, key); } Parrot_io_printf(interp, " ],\n"); break; case PFC_PMC: Parrot_io_printf(interp, " [ 'PFC_PMC', {\n"); { PMC * const pmc = self->u.key; Parrot_Sub_attributes *sub; STRING * const null = Parrot_str_new_constant(interp, "(null)"); STRING *namespace_description; pobj_flag_dump(interp, (long)PObj_get_FLAGS(pmc)); switch (pmc->vtable->base_type) { case enum_class_FixedBooleanArray: case enum_class_FixedFloatArray: case enum_class_FixedPMCArray: case enum_class_FixedStringArray: case enum_class_ResizableBooleanArray: case enum_class_ResizableIntegerArray: case enum_class_ResizableFloatArray: case enum_class_ResizablePMCArray: case enum_class_ResizableStringArray: { const int n = VTABLE_get_integer(interp, pmc); STRING* const out_buffer = VTABLE_get_repr(interp, pmc); Parrot_io_printf(interp, "\tclass => %Ss,\n" "\telement count => %d,\n" "\telements => %Ss,\n", pmc->vtable->whoami, n, out_buffer); } break; case enum_class_Sub: case enum_class_Coroutine: PMC_get_sub(interp, pmc, sub); if (sub->namespace_name) { switch (sub->namespace_name->vtable->base_type) { case enum_class_String: namespace_description = Parrot_str_new(interp, "'", 1); namespace_description = Parrot_str_append(interp, namespace_description, VTABLE_get_string(interp, sub->namespace_name)); namespace_description = Parrot_str_append(interp, namespace_description, Parrot_str_new(interp, "'", 1)); break; case enum_class_Key: namespace_description = key_set_to_string(interp, sub->namespace_name); break; default: namespace_description = sub->namespace_name->vtable->whoami; } } else { namespace_description = null; } Parrot_io_printf(interp, "\tclass => %Ss,\n" "\tstart_offs => %d,\n" "\tend_offs => %d,\n" "\tname => '%Ss',\n" "\tsubid => '%Ss',\n" "\tmethod => '%Ss',\n" "\tnsentry => '%Ss',\n" "\tnamespace => %Ss\n" "\tHLL_id => %d,\n", pmc->vtable->whoami, sub->start_offs, sub->end_offs, sub->name, sub->subid, sub->method_name, sub->ns_entry_name, namespace_description, sub->HLL_id); break; case enum_class_FixedIntegerArray: Parrot_io_printf(interp, "\tclass => %Ss,\n" "\trepr => '%Ss'\n", pmc->vtable->whoami, VTABLE_get_repr(interp, pmc)); break; default: Parrot_io_printf(interp, "\tno dump info for PMC %ld %Ss\n", pmc->vtable->base_type, pmc->vtable->whoami); Parrot_io_printf(interp, "\tclass => %Ss,\n", pmc->vtable->whoami); } } Parrot_io_printf(interp, " } ],\n"); break; default: Parrot_io_printf(interp, " [ 'PFC_\?\?\?', type '0x%x' ],\n", self->type); break; } }
static void PackFile_header_dump(PARROT_INTERP, PackFile *pf) { Parrot_io_printf(interp, "HEADER => [\n"); Parrot_io_printf(interp, "\twordsize = %d", pf->header->wordsize); Parrot_io_printf(interp, "\t(interpreter's wordsize/INTVAL = %d/%d)\n", sizeof (opcode_t), sizeof (INTVAL)); Parrot_io_printf(interp, "\tbyteorder = %d", pf->header->byteorder); Parrot_io_printf(interp, "\t(interpreter's byteorder = %d)\n", PARROT_BIGENDIAN); Parrot_io_printf(interp, "\tfloattype = %d", pf->header->floattype); Parrot_io_printf(interp, "\t(interpreter's NUMVAL_SIZE = %d)\n", NUMVAL_SIZE); Parrot_io_printf(interp, "\tparrot-version %d.%d.%d, " "bytecode-version %d.%d\n", pf->header->major, pf->header->minor, pf->header->patch, pf->header->bc_major, pf->header->bc_minor); Parrot_io_printf(interp, "\tUUID: type = %d, size = %d", pf->header->uuid_type, pf->header->uuid_size); if (pf->header->uuid_size) Parrot_io_printf(interp, ", '%s'\n", pf->header->uuid_data); else Parrot_io_printf(interp, "\n"); Parrot_io_printf(interp, "\t%s endianize, %s opcode, %s numval transform\n", pf->need_endianize ? "**need**" : "no", pf->need_wordsize ? "**need**" : "no", pf->fetch_nv ? "**need**" : "no"); Parrot_io_printf(interp, "\tdirformat = %d\n", pf->header->dir_format); Parrot_io_printf(interp, "]\n"); }