# New Ticket Created by Jürgen Bömmels # Please include the string: [perl #18144] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=18144 >
In order to do some debugging with PackFiles I had resurrected pdump. It now uses a valid interpreter for output. To test it use make pdump pdump life.pbc -- attachment 1 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/40719/32825/696825/pdump.diff
Index: pdump.c =================================================================== RCS file: /cvs/public/parrot/pdump.c,v retrieving revision 1.13 diff -u -r1.13 pdump.c --- pdump.c 6 Mar 2002 15:45:28 -0000 1.13 +++ pdump.c 28 Oct 2002 22:20:58 -0000 @@ -11,6 +11,10 @@ */ #include "parrot/packfile.h" +#include "parrot/interpreter.h" + +void PackFile_dump (struct Parrot_Interp *interpreter, + struct PackFile *pf); int main(int argc, char **argv) @@ -20,7 +24,7 @@ opcode_t *packed; size_t packed_size; struct PackFile *pf; - struct Parrot_Interp *interpreter = make_interpreter(NO_FLAGS); + struct Parrot_Interp *interpreter; if (argc != 2) { fprintf(stderr, "pdump: usage: pdump FILE\n"); @@ -37,9 +41,9 @@ return 1; } - init_world(); - interpreter = make_interpreter(NO_FLAGS); + Parrot_init (interpreter, (void *) &file_stat); + init_world(interpreter); packed_size = file_stat.st_size; @@ -68,8 +72,8 @@ printf("Can't unpack.\n"); return 1; } - PackFile_dump(pf); - PackFile_DELETE(pf); + PackFile_dump(interpreter, pf); + PackFile_destroy(pf); pf = NULL; Index: packdump.c =================================================================== RCS file: /cvs/public/parrot/packdump.c,v retrieving revision 1.4 diff -u -r1.4 packdump.c --- packdump.c 11 Oct 2002 01:46:31 -0000 1.4 +++ packdump.c 28 Oct 2002 22:20:58 -0000 @@ -13,64 +13,82 @@ #include "parrot/parrot.h" #include "parrot/packfile.h" +/* +** FIXME: this should also be segmentized. +** For now just remove some warnings +*/ + +void PackFile_dump (struct Parrot_Interp *, struct PackFile *); +static void PackFile_FixupTable_dump (struct Parrot_Interp *, + struct PackFile_FixupTable *); +static void PackFile_ConstTable_dump (struct Parrot_Interp *, + struct PackFile_ConstTable *); +static void PackFile_Constant_dump (struct Parrot_Interp *, + struct PackFile_Constant *); + void -PackFile_dump(struct PackFile *self) +PackFile_dump(struct Parrot_Interp *interpreter, struct PackFile *self) { size_t i; - PIO_printf(NULL, "FIXUP => {\n"); + PIO_printf(interpreter, "FIXUP => {\n"); - PackFile_FixupTable_dump(self->fixup_table); + PackFile_FixupTable_dump(interpreter, self->fixup_table); - PIO_printf(NULL, "},\n"); + PIO_printf(interpreter, "},\n"); - PIO_printf(NULL, "CONST => [\n"); + PIO_printf(interpreter, "CONST => [\n"); - PackFile_ConstTable_dump(self->const_table); + PackFile_ConstTable_dump(interpreter, self->const_table); - PIO_printf(NULL, "],\n"); + PIO_printf(interpreter, "],\n"); - PIO_printf(NULL, "BCODE => [ # %ld bytes", (long)self->byte_code_size); + PIO_printf(interpreter, "BCODE => [ # %ld bytes", + (long)self->byte_code_size); for (i = 0; i < self->byte_code_size / sizeof(opcode_t); i++) { if (i % 8 == 0) { - PIO_printf(NULL, "\n %08lx: ", (unsigned long)i * sizeof(opcode_t)); + PIO_printf(interpreter, "\n %08lx: ", + (unsigned long)i * sizeof(opcode_t)); } - PIO_printf(NULL, "%08lx ", (unsigned long)self->byte_code[i]); + PIO_printf(interpreter, "%08lx ", (unsigned long)self->byte_code[i]); } - PIO_printf(NULL, "\n]\n"); + PIO_printf(interpreter, "\n]\n"); return; } void -PackFile_FixupTable_dump(struct PackFile_FixupTable *self) +PackFile_FixupTable_dump(struct Parrot_Interp *interpreter, + struct PackFile_FixupTable *self) { UNUSED(self); return; } void -PackFile_ConstTable_dump(struct PackFile_ConstTable *self) +PackFile_ConstTable_dump(struct Parrot_Interp *interpreter, + struct PackFile_ConstTable *self) { opcode_t i; if (!self) { - PIO_eprintf(NULL, "PackFile_ConstTable_dump: self == NULL!\n"); + PIO_eprintf(interpreter, "PackFile_ConstTable_dump: self == NULL!\n"); return; } for (i = 0; i < self->const_count; i++) { - PIO_printf(NULL, " # %ld:\n", (long)i); - PackFile_Constant_dump(self->constants[i]); + PIO_printf(interpreter, " # %ld:\n", (long)i); + PackFile_Constant_dump(interpreter, self->constants[i]); } return; } void -PackFile_Constant_dump(struct PackFile_Constant *self) +PackFile_Constant_dump(struct Parrot_Interp *interpreter, + struct PackFile_Constant *self) { if (!self) { /* TODO: OK to be silent here? */ @@ -80,23 +98,27 @@ switch (self->type) { case PFC_NONE: /* TODO: OK to be silent here? */ - PIO_printf(NULL," [ 'PFC_NONE', undef ],\n"); + PIO_printf(interpreter," [ 'PFC_NONE', undef ],\n"); break; case PFC_NUMBER: - PIO_printf(NULL, " [ 'PFC_NUMBER', %g ],\n", self->number); + PIO_printf(interpreter, " [ 'PFC_NUMBER', %g ],\n", self->number); break; case PFC_STRING: - PIO_printf(NULL, " [ 'PFC_STRING', {\n"); - PIO_printf(NULL, " FLAGS => 0x%04lx,\n", (long)self->string->flags); - PIO_printf(NULL, " ENCODING => %s,\n", self->string->encoding->name); - PIO_printf(NULL, " TYPE => %s,\n", self->string->type->name); - PIO_printf(NULL, " SIZE => %ld,\n", (long)self->string->bufused); + PIO_printf(interpreter, " [ 'PFC_STRING', {\n"); + PIO_printf(interpreter, " FLAGS => 0x%04lx,\n", + (long)self->string->flags); + PIO_printf(interpreter, " ENCODING => %s,\n", + self->string->encoding->name); + PIO_printf(interpreter, " TYPE => %s,\n", + self->string->type->name); + PIO_printf(interpreter, " SIZE => %ld,\n", + (long)self->string->bufused); /* TODO: Won't do anything reasonable for most encodings */ - PIO_printf(NULL, " DATA => '%.*s'\n", - (int)self->string->bufused, (char *)self->string->strstart); - PIO_printf(NULL, " } ],\n"); + PIO_printf(interpreter, " DATA => '%.*s'\n", + (int)self->string->bufused, (char *)self->string->strstart); + PIO_printf(interpreter, " } ],\n"); break; default: