Ticket #266: tt266+258-todo-read_pbc.patch

File tt266+258-todo-read_pbc.patch, 42.2 KB (added by rurban, 6 years ago)
  • src/embed.c

     
    374374 
    375375/* 
    376376 
    377 =item C<PackFile * Parrot_readbc> 
     377=item C<PackFile * Parrot_pbc_read> 
    378378 
    379379Read in a bytecode, unpack it into a C<PackFile> structure, and do fixups. 
    380380 
     
    385385PARROT_EXPORT 
    386386PARROT_CAN_RETURN_NULL 
    387387PackFile * 
    388 Parrot_readbc(PARROT_INTERP, ARGIN_NULLOK(const char *fullname)) 
     388Parrot_pbc_read(PARROT_INTERP, ARGIN_NULLOK(const char *fullname), int options) 
    389389{ 
    390390    FILE     *io        = NULL; 
    391391    INTVAL    is_mapped = 0; 
     
    527527 
    528528    pf = PackFile_new(interp, is_mapped); 
    529529 
     530    /* Make the cmdline option available to the unpackers */ 
     531    pf->options = options; 
     532 
    530533    if (!PackFile_unpack(interp, pf, (opcode_t *)program_code, 
    531534            (size_t)program_size)) { 
    532535        Parrot_io_eprintf(interp, "Parrot VM: Can't unpack packfile %s.\n", 
     
    555558 
    556559/* 
    557560 
    558 =item C<void Parrot_loadbc> 
     561=item C<void Parrot_pbc_load> 
    559562 
    560 Loads the C<PackFile> returned by C<Parrot_readbc()>. 
     563Loads the C<PackFile> returned by C<Parrot_pbc_read()>. 
    561564 
    562565=cut 
    563566 
     
    565568 
    566569PARROT_EXPORT 
    567570void 
    568 Parrot_loadbc(PARROT_INTERP, NOTNULL(PackFile *pf)) 
     571Parrot_pbc_load(PARROT_INTERP, NOTNULL(PackFile *pf)) 
    569572{ 
    570573    if (pf == NULL) { 
    571574        Parrot_io_eprintf(interp, "Invalid packfile\n"); 
     
    10401043    INTVAL i; 
    10411044 
    10421045    /* TODO: would be nice to print the name of the file as well */ 
    1043     Parrot_io_printf(interp, "Constant-table\n"); 
     1046    Parrot_io_printf(interp, "=head1 Constant-table\n\n"); 
    10441047 
    10451048    for (i = 0; i < numconstants; ++i) { 
    10461049        PackFile_Constant *c = interp->code->const_table->constants[i]; 
     
    11101113        } 
    11111114    } 
    11121115 
    1113     Parrot_io_printf(interp, "\n"); 
     1116    Parrot_io_printf(interp, "\n=cut\n\n"); 
    11141117} 
    11151118 
    11161119 
     
    11281131 
    11291132PARROT_EXPORT 
    11301133void 
    1131 Parrot_disassemble(PARROT_INTERP) 
     1134Parrot_disassemble(PARROT_INTERP, char *outfile, Parrot_disassemble_options options) 
    11321135{ 
    11331136    PDB_line_t *line; 
    11341137    PDB_t      *pdb             = mem_allocate_zeroed_typed(PDB_t); 
     
    11461149    debugs = (interp->code->debugs != NULL); 
    11471150 
    11481151    print_constant_table(interp); 
     1152    if (options & enum_DIS_HEADER) 
     1153        return; 
    11491154 
    1150     Parrot_io_printf(interp, "%12s-%12s", "Seq_Op_Num", "Relative-PC"); 
     1155    if (!(options & enum_DIS_BARE)) 
     1156        Parrot_io_printf(interp, "# %12s-%12s", "Seq_Op_Num", "Relative-PC"); 
    11511157 
    11521158    if (debugs) { 
    1153         Parrot_io_printf(interp, " %6s:\n", "SrcLn#"); 
     1159        if (!(options & enum_DIS_BARE)) 
     1160            Parrot_io_printf(interp, " %6s:\n", "SrcLn#"); 
    11541161        num_mappings = interp->code->debugs->num_mappings; 
    11551162    } 
    11561163    else { 
     
    11681175            if (op_code_seq_num == interp->code->debugs->mappings[curr_mapping]->offset) { 
    11691176                const int filename_const_offset = 
    11701177                    interp->code->debugs->mappings[curr_mapping]->filename; 
    1171                 Parrot_io_printf(interp, "Current Source Filename %Ss\n", 
     1178                Parrot_io_printf(interp, "# Current Source Filename '%Ss'\n", 
    11721179                        interp->code->const_table->constants[filename_const_offset]->u.string); 
    11731180                curr_mapping++; 
    11741181            } 
    11751182        } 
    11761183 
    1177         Parrot_io_printf(interp, "%012i-%012i", 
    1178                 op_code_seq_num, line->opcode - interp->code->base.data); 
     1184        if (!(options & enum_DIS_BARE)) 
     1185            Parrot_io_printf(interp, "%012i-%012i", 
     1186                             op_code_seq_num, line->opcode - interp->code->base.data); 
    11791187 
    1180         if (debugs) 
     1188        if (debugs && !(options & enum_DIS_BARE)) 
    11811189            Parrot_io_printf(interp, " %06i: ", 
    11821190                    interp->code->debugs->base.data[op_code_seq_num]); 
    11831191 
     
    12311239    pf->cur_cs->base.data = program_code; 
    12321240    pf->cur_cs->base.size = 2; 
    12331241 
    1234     Parrot_loadbc(interp, pf); 
     1242    Parrot_pbc_load(interp, pf); 
    12351243 
    12361244    run_native = func; 
    12371245 
  • src/pbc_info.c

     
    7070 
    7171    interp = Parrot_new(NULL); 
    7272 
    73     pf = Parrot_readbc(interp, argv[1]); 
     73    pf = Parrot_pbc_read(interp, argv[1], 0); 
    7474 
    7575    /* 
    7676     * add some more segments 
  • src/pbc_merge.c

     
    228228=item C<static PackFile* pbc_merge_loadpbc> 
    229229 
    230230This function loads a PBC file and unpacks it. We can't 
    231 use Parrot_readbc because that is specified to also 
     231use Parrot_pbc_read because that is specified to also 
    232232fixup the segments, which we don't want. 
    233233 
    234234=cut 
  • src/exec_start.c

     
    8181        printf("Can't unpack.\n"); 
    8282        return 1; 
    8383    } 
    84     Parrot_loadbc(interp, pf); 
     84    Parrot_pbc_load(interp, pf); 
    8585    PackFile_fixup_subs(interp, PBC_PBC, NULL); 
    8686 
    8787    /* opcode_map has the offset of each opcode in the compiled code 
  • src/parrot_debugger.c

     
    181181    ext      = strrchr(filename, '.'); 
    182182 
    183183    if (ext && STREQ(ext, ".pbc")) { 
    184         Parrot_PackFile pf = Parrot_readbc(interp, filename); 
     184        Parrot_PackFile pf = Parrot_pbc_read(interp, filename, 0); 
    185185 
    186186        if (!pf) 
    187187            return 1; 
    188188 
    189         Parrot_loadbc(interp, pf); 
     189        Parrot_pbc_load(interp, pf); 
    190190        PackFile_fixup_subs(interp, PBC_MAIN, NULL); 
    191191    } 
    192192    else { 
    193193        Parrot_PackFile pf        = PackFile_new(interp, 0); 
    194194        int             pasm_file = 0; 
    195195 
    196         Parrot_loadbc(interp, pf); 
     196        Parrot_pbc_load(interp, pf); 
    197197 
    198198        IMCC_push_parser_state(interp); 
    199199        IMCC_INFO(interp)->state->file = filename; 
  • src/pbc_disassemble.c

     
    88 
    99=head1 SYNOPSIS 
    1010 
    11     pbc_disassemble file.pbc 
     11    pbc_disassemble [-bh?] [-o outfile] [file.pbc] 
    1212 
    1313=head1 DESCRIPTION 
    1414 
     
    1616which in turn uses the C<PDB_disassemble()> function from 
    1717F<src/debug.c>. 
    1818 
     19Without non-option arguments it reads the pbc from STDIN. 
     20 
    1921=head2 Functions 
    2022 
    2123=over 4 
     
    3032#include <stdlib.h> 
    3133#include <ctype.h> 
    3234 
    33 static void do_dis(Parrot_Interp); 
     35static void do_dis(Parrot_Interp, char *, Parrot_disassemble_options); 
    3436 
    3537/* 
    3638 
     39=item C<static void help(void)> 
     40 
     41Print out the user help info. 
     42 
     43=cut 
     44 
     45*/ 
     46 
     47static void help(void) 
     48{ 
     49    printf("pbc_disassemble - dump or convert parrot bytecode (PBC) files\n"); 
     50    printf("usage:\n"); 
     51    printf("pbc_disassemble [-bh] [--bare|--header-only] [file.pbc]\n"); 
     52    printf("pbc_disassemble -o converted.pasm file.pbc\n\n"); 
     53    printf("  -b\t\t   bare .pasm without header and left column\n"); 
     54    printf("  -h\t\t   dump Constant-table header only\n"); 
     55    printf("  -d\t\t   debug output for the pbc reader\n"); 
     56    printf("  -o filename\t ... output to filename\n"); 
     57    exit(EXIT_SUCCESS); 
     58} 
     59 
     60static struct longopt_opt_decl options[] = { 
     61    { 'h', 'h', OPTION_optional_FLAG, { "--header-only" } }, 
     62    { '?', '?', OPTION_optional_FLAG, { "--help" } }, 
     63    { 'b', 'b', OPTION_optional_FLAG, { "--bare" } }, 
     64    { 'd', 'd', OPTION_optional_FLAG, { "--debug" } }, 
     65    { 'o', 'o', OPTION_required_FLAG, { "--output" } } 
     66}; 
     67 
     68/* 
     69 
    3770=item C<int main(int argc, char *argv[])> 
    3871 
    3972The run-loop. Starts up an interpreter, loads the bytecode from the 
     
    4679int 
    4780main(int argc, char *argv[]) 
    4881{ 
     82    Parrot_PackFile pf; 
    4983    Parrot_Interp interp; 
    50     char *filename; 
    51     Parrot_PackFile pf; 
     84    char *outfile = NULL; 
     85    int option = 0; 
     86    int debug = 0; 
     87    struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT; 
     88    int status; 
    5289 
    5390    interp = Parrot_new(NULL); 
    54  
    5591    if (!interp) { 
    5692        return 1; 
    5793    } 
    58  
    59     /* set the top of the stack so GC can trace it for GC-able pointers 
    60      * see trace_system_areas() in src/cpu_dep.c */ 
    61     interp->lo_var_ptr = &interp; 
    62  
    63     if (argc != 2) { 
    64         fprintf(stderr, "Usage: pbc_disassemble programfile \n"); 
    65         Parrot_exit(interp, 1); 
     94    /* init and set top of stack */ 
     95    Parrot_init_stacktop(interp, &status); 
     96    while ((status = longopt_get(interp, 
     97                    argc, argv, options, &opt)) > 0) { 
     98        switch (opt.opt_id) { 
     99            case 'h': 
     100                option += enum_DIS_HEADER; 
     101                break; 
     102            case 'b': 
     103                option += enum_DIS_BARE; 
     104                break; 
     105            case 'd': 
     106                debug = 1; 
     107                break; 
     108            case 'o': 
     109                outfile = opt.opt_arg; 
     110                break; 
     111            case '?': 
     112            default: 
     113                help(); 
     114                break; 
     115        } 
    66116    } 
     117    if (status == -1) { 
     118        help(); 
     119    } 
     120    argc -= opt.opt_index; 
     121    argv += opt.opt_index; 
    67122 
    68     filename = argv[1]; 
     123    pf = Parrot_pbc_read(interp, argc ? *argv : "-", debug); 
    69124 
    70     pf = Parrot_readbc(interp, filename); 
    71  
    72125    if (!pf) { 
     126        printf("Can't read PBC\n"); 
    73127        return 1; 
    74128    } 
    75129 
    76     Parrot_loadbc(interp, pf); 
     130    Parrot_pbc_load(interp, pf); 
    77131 
    78     do_dis(interp); 
     132    do_dis(interp, outfile, option); 
    79133 
    80134    Parrot_exit(interp, 0); 
    81135} 
    82136 
    83137/* 
    84138 
    85 =item C<static void do_dis(PARROT_INTERP)> 
     139=item C<static void do_dis(PARROT_INTERP, outfile, options)> 
    86140 
    87141Do the disassembling. 
    88142 
     
    91145*/ 
    92146 
    93147static void 
    94 do_dis(PARROT_INTERP) 
     148do_dis(PARROT_INTERP, char *outfile, Parrot_disassemble_options options) 
    95149{ 
    96     Parrot_disassemble(interp); 
     150    Parrot_disassemble(interp, outfile, options); 
    97151} 
    98152 
    99153/* 
     
    112166actually run the disassembler to normal C comments (Wed, 16 Nov 2005). 
    113167 
    114168Reini Urban: Renamed from disassemble to pbc_disassemble (2008-07-03). 
     169             add options: help, -h, -o, bare (2009-01-29) 
    115170 
    116171=cut 
    117172 
  • src/pdump.c

     
    177177    printf("usage:\n"); 
    178178    printf("pdump [-tdh] [--terse|--disassemble|--header-only] file.pbc\n"); 
    179179    printf("pdump -o converted.pbc file.pbc\n\n"); 
    180     printf("\t-d ... disassemble bytecode segments\n"); 
    181     printf("\t-h ... dump header only\n"); 
    182     printf("\t-t ... terse output\n"); 
     180    printf("\t-d      disassemble bytecode segments\n"); 
     181    printf("\t-h      dump header only\n"); 
     182    printf("\t-t      terse output\n"); 
     183    printf("\t--debug debug output\n"); 
    183184    printf("\n\t-o converted.pbc repacks a PBC file into " 
    184185           "the platform's native\n"); 
    185186    printf("\t   binary format for better efficiency on reading " 
     
    192193    { '?', '?', OPTION_optional_FLAG, { "--help" } }, 
    193194    { 't', 't', OPTION_optional_FLAG, { "--terse" } }, 
    194195    { 'd', 'd', OPTION_optional_FLAG, { "--disassemble" } }, 
     196    { 'e', 'e', OPTION_optional_FLAG, { "--debug" } }, 
    195197    { 'o', 'o', OPTION_required_FLAG, { "--output" } } 
    196198}; 
    197199 
     
    215217    int disas = 0; 
    216218    int convert = 0; 
    217219    int header = 0; 
     220    int debug = 0; 
    218221    const char *file = NULL; 
    219222    struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT; 
    220223    int status; 
     
    237240            case 'd': 
    238241                disas = 1; 
    239242                break; 
     243            case 'e': 
     244                debug = 1; 
     245                break; 
    240246            case 'o': 
    241247                file = opt.opt_arg; 
    242248                convert = 1; 
     
    254260    argv += opt.opt_index; 
    255261 
    256262 
    257     pf = Parrot_readbc(interp, *argv); 
     263    pf = Parrot_pbc_read(interp, *argv, debug); 
    258264 
    259265    if (!pf) { 
    260266        printf("Can't read PBC\n"); 
    261267        return 1; 
    262268    } 
    263     Parrot_loadbc(interp, pf); 
     269    Parrot_pbc_load(interp, pf); 
    264270    if (convert) { 
    265271        size_t size; 
    266272        opcode_t *pack; 
  • src/packfile/pf_items.c

     
    107107/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */ 
    108108/* HEADERIZER END: static */ 
    109109 
    110 #define TRACE_PACKFILE 0 
     110#if TRACE_PACKFILE 
     111void Parrot_trace_eprintf(ARGIN(const char *s), ...); 
     112#endif 
    111113 
    112114/* 
    113115 * round val up to whole size, return result in bytes 
     
    470472        return *(*stream)++; 
    471473    o = (pf->fetch_op)(*((const unsigned char **)stream)); 
    472474    *((const unsigned char **) (stream)) += pf->header->wordsize; 
    473 #if TRACE_PACKFILE 
    474     Parrot_io_eprintf(NULL, "  PF_fetch_opcode: 0x%lx (%ld)\n", o, o); 
    475 #endif 
     475    TRACE_PRINTF_VAL(("  PF_fetch_opcode: 0x%lx (%ld)\n", o, o)); 
    476476    return o; 
    477477} 
    478478 
     
    606606    FLOATVAL f; 
    607607    double d; 
    608608    if (!pf || !pf->fetch_nv) { 
    609 #if TRACE_PACKFILE 
    610         Parrot_io_eprintf(NULL, "PF_fetch_number: Native [%d bytes]\n", 
    611                 sizeof (FLOATVAL)); 
    612 #endif 
     609        TRACE_PRINTF(("PF_fetch_number: Native [%d bytes]\n", 
     610                      sizeof (FLOATVAL))); 
    613611        memcpy(&f, (const char*)*stream, sizeof (FLOATVAL)); 
     612        TRACE_PRINTF_VAL(("PF_fetch_number: %f\n", f)); 
    614613        (*stream) += (sizeof (FLOATVAL) + sizeof (opcode_t) - 1)/ 
    615614            sizeof (opcode_t); 
    616615        return f; 
    617616    } 
    618617    f = (FLOATVAL) 0; 
    619 #if TRACE_PACKFILE 
    620     Parrot_io_eprintf(NULL, "PF_fetch_number: Byteordering..\n"); 
    621 #endif 
     618    TRACE_PRINTF(("PF_fetch_number: Byteordering..\n")); 
    622619    /* Here is where the size transforms get messy. 
    623620       Floattype 0 = IEEE-754 8 byte double 
    624621       Floattype 1 = x86 little endian 12 byte long double 
     
    626623    if (NUMVAL_SIZE == 8 && pf->header->floattype) { 
    627624        (pf->fetch_nv)((unsigned char *)&d, (const unsigned char *) *stream); 
    628625        f = d; 
     626        TRACE_PRINTF_VAL(("PF_fetch_number: 12->8 byte %f\n", f)); 
    629627    } 
    630628    else { 
    631629        (pf->fetch_nv)((unsigned char *)&f, (const unsigned char *) *stream); 
     630        TRACE_PRINTF_VAL(("PF_fetch_number: %f\n", f)); 
    632631    } 
    633632    if (pf->header->floattype) { 
    634633        *((const unsigned char **) (stream)) += 12; 
     
    718717 
    719718    /* These may need to be separate */ 
    720719    size = (size_t)PF_fetch_opcode(pf, cursor); 
     720    TRACE_PRINTF(("PF_fetch_string(): flags are 0x%04x...\n", flags)); 
     721    TRACE_PRINTF(("PF_fetch_string(): charset_nr is %ld...\n", 
     722                  charset_nr)); 
     723    TRACE_PRINTF(("PF_fetch_string(): size is %ld...\n", size)); 
    721724 
    722 #if TRACE_PACKFILE 
    723     Parrot_io_eprintf(NULL, "PF_fetch_string(): flags are 0x%04x...\n", flags); 
    724     Parrot_io_eprintf(NULL, "PF_fetch_string(): charset_nr is %ld...\n", 
    725            charset_nr); 
    726     Parrot_io_eprintf(NULL, "PF_fetch_string(): size is %ld...\n", size); 
    727 #endif 
    728  
    729725    charset_name = Parrot_charset_c_name(interp, charset_nr); 
    730726    s = string_make(interp, (const char *)*cursor, size, charset_name, flags); 
    731727 
    732 #if TRACE_PACKFILE == 3 
    733     Parrot_io_eprintf(NULL, "PF_fetch_string(): string is: "); 
    734     Parrot_io_putps(interp, Parrot_io_STDERR(interp), s); 
    735     Parrot_io_eprintf(NULL, "\n"); 
     728#if TRACE_PACKFILE == 2 
     729    if (pf->options & 3) { 
     730        /* print only printable characters */ 
     731        Parrot_io_eprintf(NULL, "PF_fetch_string(): string is '%s'\n", s->strstart); 
     732    } 
    736733#endif 
    737734 
    738735/*    s = string_make(interp, *cursor, size, 
     
    740737                               flags); */ 
    741738 
    742739    size = ROUND_UP_B(size, wordsize); 
    743 #if TRACE_PACKFILE == 2 
    744     Parrot_io_eprintf(NULL, "PF_fetch_string(): round size up to %ld.\n", size); 
    745 #endif 
     740    TRACE_PRINTF(("PF_fetch_string(): round size up to %ld.\n", size)); 
    746741    *((const unsigned char **) (cursor)) += size; 
    747742    return s; 
    748743} 
     
    766761    opcode_t padded_size = s->bufused; 
    767762    char *charcursor; 
    768763 
    769 #if TRACE_PACKFILE == 2 
     764#if TRACE_PACKFILE == 3 
    770765    Parrot_io_eprintf(NULL, "PF_store_string(): size is %ld...\n", s->bufused); 
    771766#endif 
    772767 
  • src/pmc/packfile.pmc

     
    8282 
    8383=cut 
    8484 
    85 Implementation note: taken from the bottom end of Parrot_readbc(). 
     85Implementation note: taken from the bottom end of Parrot_pbc_read(). 
    8686*/ 
    8787    VTABLE void set_string_native(STRING *str) { 
    8888        PackFile *pf = PMC_data_typed(SELF, PackFile *); 
  • src/packfile.c

     
    1515This file contains all the functions required for the processing of the 
    1616structure of a PackFile. It is not intended to understand the byte code 
    1717stream itself, but merely to dissect and reconstruct data from the 
    18 various segments. See F<docs/parrotbyte.pod> for information about the 
     18various segments. See F<docs/pdds/pdd13_bytecode.pod> for information about the 
    1919structure of the frozen bytecode. 
    2020 
    2121=over 4 
     
    451451    extern int Parrot_exec_run; 
    452452#endif 
    453453 
    454 #define TRACE_PACKFILE 0 
    455  
    456454/* TODO: This is broken on 64-bit. See TT #254 */ 
    457455#if OPCODE_T_SIZE == 4 
    458456#  define ROUND_16(val) (((val) & 0xf) ? 16 - ((val) & 0xf) : 0) 
     
    462460#  define ALIGN_16(xx, ptr) ptr = (const opcode_t *)(((unsigned long)ptr + 15) & (~15)) 
    463461#endif 
    464462 
     463#if TRACE_PACKFILE 
     464void Parrot_trace_eprintf(ARGIN(const char *s), ...); 
     465void Parrot_trace_eprintf(ARGIN(const char *s), ...) { 
     466    va_list args; 
     467    va_start(args, s); 
     468    vfprintf(stderr, s, args); 
     469    va_end(args); 
     470} 
     471#endif 
     472 
    465473/* 
    466474 
    467475=item C<void PackFile_destroy> 
     
    843851    opcode_t i; 
    844852    PackFile_FixupTable * const ft = self->fixups; 
    845853    PackFile_ConstTable * const ct = self->const_table; 
    846  
    847854#if TRACE_PACKFILE 
    848     Parrot_io_eprintf(NULL, "PackFile: do_sub_pragmas (action=%d)\n", action); 
     855    PackFile            * const pf = self->base.pf; 
    849856#endif 
    850857 
     858    TRACE_PRINTF(("PackFile: do_sub_pragmas (action=%d)\n", action)); 
     859 
    851860    for (i = 0; i < ft->fixup_count; i++) { 
    852861        switch (ft->fixups[i]->type) { 
    853862            case enum_fixup_sub: 
     
    915924    const opcode_t         *cursor; 
    916925    int                     header_read_length; 
    917926    opcode_t                padding; 
     927#if TRACE_PACKFILE 
     928    PackFile        * const pf  = self; 
     929#endif 
    918930 
    919931    self->src  = packed; 
    920932    self->size = packed_size; 
     
    958970    } 
    959971 
    960972    /* Describe what was read for debugging. */ 
    961 #if TRACE_PACKFILE 
    962     Parrot_io_eprintf(NULL, "PackFile_unpack: Wordsize %d.\n", header->wordsize); 
    963     Parrot_io_eprintf(NULL, "PackFile_unpack: Floattype %d (%s).\n", 
    964                 header->floattype, 
    965                 header->floattype ? 
     973    TRACE_PRINTF(("PackFile_unpack: Wordsize %d.\n", header->wordsize)); 
     974    TRACE_PRINTF(("PackFile_unpack: Floattype %d (%s).\n", 
     975                  header->floattype, 
     976                  header->floattype ? 
    966977                  "x86 little endian 12 byte long double" : 
    967                   "IEEE-754 8 byte double"); 
    968     Parrot_io_eprintf(NULL, "PackFile_unpack: Byteorder %d (%sendian).\n", 
    969                 header->byteorder, header->byteorder ? "big " : "little-"); 
    970 #endif 
     978                  "IEEE-754 8 byte double")); 
     979    TRACE_PRINTF(("PackFile_unpack: Byteorder %d (%sendian).\n", 
     980                  header->byteorder, header->byteorder ? "big " : "little-")); 
    971981 
    972982    /* Check the UUID type is valid and, if needed, read a UUID. */ 
    973983    if (header->uuid_type == 0) { 
     
    10111021    } 
    10121022 
    10131023    /* Padding. */ 
    1014 #if TRACE_PACKFILE 
    1015     Parrot_io_eprintf(NULL, "PackFile_unpack: 3 words padding.\n"); 
    1016 #endif 
     1024    TRACE_PRINTF(("PackFile_unpack: 3 words padding.\n")); 
    10171025    padding = PF_fetch_opcode(self, &cursor); 
    10181026    padding = PF_fetch_opcode(self, &cursor); 
    10191027    padding = PF_fetch_opcode(self, &cursor); 
    10201028    UNUSED(padding); 
    10211029 
    1022 #if TRACE_PACKFILE 
    1023     Parrot_io_eprintf(NULL, "PackFile_unpack: Directory read, offset %d.\n", 
    1024                 (INTVAL)cursor - (INTVAL)packed); 
    1025 #endif 
     1030    TRACE_PRINTF(("PackFile_unpack: Directory read, offset %d.\n", 
     1031                  (INTVAL)cursor - (INTVAL)packed)); 
    10261032 
    10271033    self->directory.base.file_offset = (INTVAL)cursor - (INTVAL)self->src; 
    10281034 
     
    10441050    } 
    10451051#endif 
    10461052 
    1047 #if TRACE_PACKFILE 
    1048     Parrot_io_eprintf(NULL, "PackFile_unpack: Unpack done.\n"); 
    1049 #endif 
     1053    TRACE_PRINTF(("PackFile_unpack: Unpack done.\n")); 
    10501054 
    10511055    return cursor - packed; 
    10521056} 
     
    12251229    header->bc_minor    = PARROT_PBC_MINOR; 
    12261230#if NUMVAL_SIZE == 8 
    12271231    header->floattype = 0; 
    1228 #else /* if XXX */ 
     1232#else 
     1233# if (NUMVAL_SIZE == 12) && PARROT_BIGENDIAN 
    12291234    header->floattype = 1; 
     1235# else 
     1236    Parrot_io_eprintf 
     1237        (NULL,  
     1238         "PackFile_set_header: Unsupported floattype NUMVAL_SIZE=%d, PARROT_BIGENDIAN=%d\n", 
     1239         NUMVAL_SIZE, PARROT_BIGENDIAN); 
     1240    return 0; 
     1241# endif 
    12301242#endif 
    12311243} 
    12321244 
     
    12891301    PackFile * const pf = mem_allocate_zeroed_typed(PackFile); 
    12901302    pf->header          = mem_allocate_zeroed_typed(PackFile_Header); 
    12911303    pf->is_mmap_ped     = is_mapped; 
     1304    pf->options         = 0; 
    12921305 
    12931306    /* fill header with system specific data */ 
    12941307    PackFile_set_header(pf->header); 
     
    13791392{ 
    13801393    ASSERT_ARGS(default_unpack) 
    13811394    DECL_CONST_CAST_OF(opcode_t); 
     1395#if TRACE_PACKFILE 
     1396    PackFile * const pf  = self->pf; 
     1397#endif 
    13821398 
    13831399    self->op_count = PF_fetch_opcode(self->pf, &cursor); 
    13841400    self->itype    = PF_fetch_opcode(self->pf, &cursor); 
    13851401    self->id       = PF_fetch_opcode(self->pf, &cursor); 
    13861402    self->size     = PF_fetch_opcode(self->pf, &cursor); 
    1387 #if TRACE_PACKFILE == 2 
    1388     Parrot_io_eprintf(NULL, "default_unpack: op_count=%d, itype=%d, id=%d, size=%d.\n", 
    1389         self->op_count, self->itype, self->id, self->size); 
    1390 #endif 
     1403    TRACE_PRINTF_VAL(("default_unpack: op_count=%d, itype=%d, id=%d, size=%d.\n", 
     1404                      self->op_count, self->itype, self->id, self->size)); 
    13911405 
    13921406    if (self->size == 0) 
    13931407        return cursor; 
     
    14191433        int i; 
    14201434        for (i = 0; i < (int)self->size; i++) { 
    14211435            self->data[i] = PF_fetch_opcode(self->pf, &cursor); 
    1422 #if TRACE_PACKFILE 
    1423             Parrot_io_eprintf(NULL, "default_unpack: transformed op[#%d]/%d %u\n", 
    1424                 i, self->size, self->data[i]); 
    1425 #endif 
     1436            TRACE_PRINTF(("default_unpack: transformed op[#%d]/%d %u\n", 
     1437                          i, self->size, self->data[i])); 
    14261438        } 
    14271439    } 
    14281440 
     
    17921804{ 
    17931805    ASSERT_ARGS(PackFile_Segment_unpack) 
    17941806    PackFile_Segment_unpack_func_t f = self->pf->PackFuncs[self->type].unpack; 
     1807#if TRACE_PACKFILE 
     1808    PackFile * const pf  = self->pf; 
     1809#endif 
    17951810 
    17961811    cursor = default_unpack(self, cursor); 
    17971812 
     
    17991814        return NULL; 
    18001815 
    18011816    if (f) { 
    1802 #if TRACE_PACKFILE 
    1803         Parrot_io_eprintf(NULL, "PackFile_Segment_unpack: special\n"); 
    1804 #endif 
     1817        TRACE_PRINTF(("PackFile_Segment_unpack: special\n")); 
     1818 
    18051819        cursor = (f)(interp, self, cursor); 
    1806 #if TRACE_PACKFILE == 2 
    1807         Parrot_io_eprintf(NULL, "  PackFile_Segment_unpack: cursor=0x%x\n", cursor); 
    1808 #endif 
     1820        TRACE_PRINTF_VAL(("  PackFile_Segment_unpack: offset=0x%x\n", pf->src - cursor)); 
     1821 
    18091822        if (!cursor) 
    18101823            return NULL; 
    18111824    } 
    18121825 
    18131826    ALIGN_16(self->pf->src, cursor); 
    1814 #if TRACE_PACKFILE == 2 
    1815     Parrot_io_eprintf(NULL, "  ALIGN_16: src=0x%x cursor=0x%x\n", self->pf->src, cursor); 
    1816 #endif 
     1827    TRACE_PRINTF_VAL(("ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n", pf->src - cursor, pf->src, cursor)); 
    18171828    return cursor; 
    18181829} 
    18191830 
     
    19271938    size_t                     i; 
    19281939 
    19291940    dir->num_segments = PF_fetch_opcode(pf, &cursor); 
    1930 #if TRACE_PACKFILE 
    1931     Parrot_io_eprintf(interp, "directory_unpack: %ld num_segments\n", dir->num_segments); 
    1932 #endif 
     1941    TRACE_PRINTF(("directory_unpack: %ld num_segments\n", dir->num_segments)); 
    19331942    mem_realloc_n_typed(dir->segments, dir->num_segments, PackFile_Segment *); 
    19341943 
    19351944    for (i = 0; i < dir->num_segments; i++) { 
     
    19421951        if (type >= PF_MAX_SEG) 
    19431952            type = PF_UNKNOWN_SEG; 
    19441953 
    1945 #if TRACE_PACKFILE == 2 
    1946         Parrot_io_eprintf(NULL, "Segment type %d.\n", type); 
    1947 #endif 
     1954        TRACE_PRINTF_VAL(("Segment type %d.\n", type)); 
    19481955        /* get name */ 
    19491956        name = PF_fetch_cstring(pf, &cursor); 
     1957        TRACE_PRINTF_VAL(("Segment name \"%s\".\n", name)); 
    19501958 
    1951 #if TRACE_PACKFILE == 2 
    1952         Parrot_io_eprintf(NULL, "Segment name \"%s\".\n", name); 
    1953 #endif 
    1954  
    19551959        /* create it */ 
    19561960        seg = PackFile_Segment_new_seg(interp, dir, type, name, 0); 
    19571961        mem_sys_free(name); 
    19581962 
    19591963        seg->file_offset = PF_fetch_opcode(pf, &cursor); 
    1960 #if TRACE_PACKFILE == 2 
    1961         Parrot_io_eprintf(NULL, "Segment file_offset %ld.\n", seg->file_offset); 
    1962 #endif 
     1964        TRACE_PRINTF_VAL(("Segment file_offset %ld.\n", seg->file_offset)); 
    19631965        seg->op_count    = PF_fetch_opcode(pf, &cursor); 
    1964 #if TRACE_PACKFILE == 2 
    1965         Parrot_io_eprintf(NULL, "Segment op_count %ld.\n", seg->op_count); 
    1966 #endif 
     1966        TRACE_PRINTF_VAL(("Segment op_count %ld.\n", seg->op_count)); 
    19671967 
    19681968        if (pf->need_wordsize) { 
    19691969#if OPCODE_T_SIZE == 8 
     
    19791979                        pf->header->wordsize); 
    19801980                return 0; 
    19811981            } 
    1982 #if TRACE_PACKFILE == 2 
    1983         Parrot_io_eprintf(NULL, "Segment offset: new pos 0x%x (src=0x%x cursor=0x%x).\n", 
    1984             pos - pf->src, pf->src, cursor); 
    1985 #endif 
     1982            TRACE_PRINTF_VAL(("Segment offset: new pos 0x%x (src=0x%x cursor=0x%x).\n", 
     1983                              pos - pf->src, pf->src, cursor)); 
     1984 
    19861985        } 
    19871986        else 
    19881987            pos = pf->src + seg->file_offset; 
     
    20112010        seg->dir         = dir; 
    20122011    } 
    20132012 
    2014 #if TRACE_PACKFILE == 2 
    2015     Parrot_io_eprintf(NULL, "pre-ALIGN_16: cursor=0x%x\n", cursor); 
     2013    TRACE_PRINTF_VAL(("pre-ALIGN_16: offset=0x%x\n", pf->src - cursor)); 
    20162014    /* FIXME on 64bit reading 32bit */ 
    2017 #endif 
    20182015    ALIGN_16(pf->src, cursor); 
    2019 #if TRACE_PACKFILE == 2 
    2020     Parrot_io_eprintf(NULL, "ALIGN_16: src=0x%x cursor=0x%x\n", pf->src, cursor); 
    2021 #endif 
     2016    TRACE_PRINTF_VAL(("ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n", pf->src - cursor, pf->src, cursor)); 
    20222017 
    20232018    /* and now unpack contents of dir */ 
    20242019    for (i = 0; cursor && i < dir->num_segments; i++) { 
     
    20312026        size_t delta = 0; 
    20322027 
    20332028        cursor = csave; 
    2034 #if TRACE_PACKFILE == 2 
    2035         Parrot_io_eprintf(NULL, "PackFile_Segment_unpack [%d] tmp len=%d.\n", i, tmp); 
    2036 #endif 
     2029        TRACE_PRINTF_VAL(("PackFile_Segment_unpack [%d] tmp len=%d.\n", i, tmp)); 
    20372030        pos    = PackFile_Segment_unpack(interp, dir->segments[i], cursor); 
    20382031 
    20392032        if (!pos) { 
     
    20412034                    dir->segments[i]->name); 
    20422035            return 0; 
    20432036        } 
    2044 #if TRACE_PACKFILE == 2 
    20452037        else 
    2046             Parrot_io_eprintf(NULL, "PackFile_Segment_unpack ok. pos=0x%x\n", pos); 
    2047 #endif 
     2038            TRACE_PRINTF_VAL((NULL, "PackFile_Segment_unpack ok. pos=0x%x\n", pos)); 
    20482039 
    20492040        /* BUG: on 64bit reading 32bit lurking here! */ 
    20502041        if (pf->need_wordsize) { 
     
    20582049        } 
    20592050        else 
    20602051            delta = pos - cursor; 
    2061 #if TRACE_PACKFILE == 2 
    2062         Parrot_io_eprintf(NULL, "  delta=%d pos=0x%x cursor=0x%x\n", 
    2063             delta, pos, cursor); 
    2064 #endif 
     2052        TRACE_PRINTF_VAL(("  delta=%d pos=0x%x cursor=0x%x\n", 
     2053                          delta, pos, cursor)); 
    20652054 
    20662055        if ((size_t)delta != tmp || dir->segments[i]->op_count != tmp) 
    20672056            fprintf(stderr, "PackFile_unpack segment '%s' directory length %d " 
     
    32503239 
    32513240    pf = self->base.pf; 
    32523241    self->fixup_count = PF_fetch_opcode(pf, &cursor); 
    3253 #if TRACE_PACKFILE 
    3254         Parrot_io_eprintf(interp, 
    3255                 "PackFile_FixupTable_unpack(): %ld entries\n", self->fixup_count); 
    3256 #endif 
     3242    TRACE_PRINTF(("PackFile_FixupTable_unpack(): %ld entries\n", self->fixup_count)); 
    32573243 
    32583244    if (self->fixup_count) { 
    32593245        self->fixups = (PackFile_FixupEntry **)mem_sys_allocate_zeroed( 
     
    32783264            case enum_fixup_sub: 
    32793265                entry->name = PF_fetch_cstring(pf, &cursor); 
    32803266                entry->offset = PF_fetch_opcode(pf, &cursor); 
    3281 #if TRACE_PACKFILE == 2 
    3282         Parrot_io_eprintf(interp, 
    3283                 "PackFile_FixupTable_unpack(): type %d, name %s, offset %ld\n", 
    3284                 entry->type, entry->name, entry->offset); 
    3285 #endif 
     3267                TRACE_PRINTF_VAL(("PackFile_FixupTable_unpack(): type %d, name %s, offset %ld\n", 
     3268                                  entry->type, entry->name, entry->offset)); 
    32863269                break; 
    32873270            case enum_fixup_none: 
    32883271                break; 
     
    33013284 
    33023285=item C<void PackFile_FixupTable_new_entry> 
    33033286 
    3304 I<What does this do?> 
     3287Adds a new fix-up entry with label and type. 
     3288Creates a new PackFile FixupTable if none is present. 
    33053289 
    3306 RT #48260: Not yet documented!!! 
    3307  
    33083290=cut 
    33093291 
    33103292*/ 
     
    33403322 
    33413323=item C<static PackFile_FixupEntry * find_fixup> 
    33423324 
    3343 Finds the fix-up entry for C<name> and returns it. 
     3325Finds the fix-up entry in a given FixupTable C<ft> for C<type> and C<name> and returns it. 
    33443326 
     3327This ignores directories, for a recursive version see C<PackFile_find_fixup_entry>. 
     3328 
    33453329=cut 
    33463330 
    33473331*/ 
     
    33673351 
    33683352=item C<static INTVAL find_fixup_iter> 
    33693353 
    3370 I<What does this do?> 
     3354Iterator for C<PackFile_find_fixup_entry> to recurse into directories. 
    33713355 
    3372 RT #48260: Not yet documented!!! 
    3373  
    33743356=cut 
    33753357 
    33763358*/ 
     
    34003382 
    34013383=item C<PackFile_FixupEntry * PackFile_find_fixup_entry> 
    34023384 
    3403 I<What does this do?> 
     3385Searches the whole PackFile recursively for a fix-up entry  
     3386with the given C<type> and C<name>, and returns the found entry or NULL. 
    34043387 
    3405 RT #48260: Not yet documented!!! 
     3388This recurses into directories, compared to the simplier  
     3389C<find_fixup> which just searches one PackFile_FixupTable. 
    34063390 
    34073391=cut 
    34083392 
     
    34993483 
    35003484    self->const_count = PF_fetch_opcode(pf, &cursor); 
    35013485 
    3502 #if TRACE_PACKFILE 
    3503     Parrot_io_eprintf(interp, 
    3504             "PackFile_ConstTable_unpack: Unpacking %ld constants\n", 
    3505             self->const_count); 
    3506 #endif 
     3486    TRACE_PRINTF(("PackFile_ConstTable_unpack: Unpacking %ld constants\n", 
     3487                  self->const_count)); 
    35073488 
    35083489    if (self->const_count == 0) { 
    35093490        return cursor; 
     
    35213502    } 
    35223503 
    35233504    for (i = 0; i < self->const_count; i++) { 
    3524 #if TRACE_PACKFILE 
    3525         Parrot_io_eprintf(interp, 
    3526                 "PackFile_ConstTable_unpack(): Unpacking constant %ld/%ld\n", 
    3527                 i, self->const_count); 
    3528 #endif 
     3505        TRACE_PRINTF(("PackFile_ConstTable_unpack(): Unpacking constant %ld/%ld\n", 
     3506                      i, self->const_count)); 
    35293507 
    35303508#if EXEC_CAPABLE 
    35313509        if (Parrot_exec_run) 
     
    37213699    PackFile * const pf = constt->base.pf; 
    37223700    const opcode_t type = PF_fetch_opcode(pf, &cursor); 
    37233701 
    3724 #if TRACE_PACKFILE 
    3725     Parrot_io_eprintf(NULL, "PackFile_Constant_unpack(): Type is %ld ('%c')...\n", 
    3726             type, (char)type); 
    3727 #endif 
     3702    TRACE_PRINTF(("PackFile_Constant_unpack(): Type is %ld ('%c')...\n", 
     3703                  type, (char)type)); 
    37283704 
    37293705    switch (type) { 
    37303706    case PFC_NUMBER: 
     
    40584034    INTVAL               i, str_len; 
    40594035    PackFile_ByteCode    *code; 
    40604036    char                 *code_name; 
     4037#if TRACE_PACKFILE 
     4038    PackFile * const pf  = seg->pf; 
     4039#endif 
    40614040 
    40624041    /* Unpack keys. */ 
    40634042    self->num_keys = PF_fetch_opcode(seg->pf, &cursor); 
    4064 #if TRACE_PACKFILE 
    4065     Parrot_io_eprintf(interp, 
    4066             "PackFile_Annotations_unpack: Unpacking %ld keys\n", 
    4067             self->num_keys); 
    4068 #endif 
     4043    TRACE_PRINTF(("PackFile_Annotations_unpack: Unpacking %ld keys\n", 
     4044                  self->num_keys)); 
    40694045    self->keys     = mem_allocate_n_typed(self->num_keys, PackFile_Annotations_Key *); 
    40704046    for (i = 0; i < self->num_keys; i++) { 
    40714047        self->keys[i]       = mem_allocate_typed(PackFile_Annotations_Key); 
    40724048        self->keys[i]->name = PF_fetch_opcode(seg->pf, &cursor); 
    40734049        self->keys[i]->type = PF_fetch_opcode(seg->pf, &cursor); 
    4074 #if TRACE_PACKFILE == 2 
    4075     Parrot_io_eprintf(interp, 
    4076             "PackFile_Annotations_unpack: key[%d]/%d name=%s type=%d\n", 
    4077             i, self->num_keys, self->keys[i]->name, self->keys[i]->type); 
    4078 #endif 
     4050        TRACE_PRINTF_VAL(("PackFile_Annotations_unpack: key[%d]/%d name=%s type=%d\n", 
     4051                          i, self->num_keys, self->keys[i]->name, self->keys[i]->type)); 
    40794052    } 
    40804053 
    40814054    /* Unpack groups. */ 
     
    40854058        self->groups[i]                  = mem_allocate_typed(PackFile_Annotations_Group); 
    40864059        self->groups[i]->bytecode_offset = PF_fetch_opcode(seg->pf, &cursor); 
    40874060        self->groups[i]->entries_offset  = PF_fetch_opcode(seg->pf, &cursor); 
    4088 #if TRACE_PACKFILE == 2 
    4089     Parrot_io_eprintf(interp, 
    4090             "PackFile_Annotations_unpack: group[%d]/%d bytecode_offset=%d entries_offset=%d\n", 
    4091             i, self->num_groups, self->groups[i]->bytecode_offset, self->groups[i]->entries_offset); 
    4092 #endif 
     4061        TRACE_PRINTF_VAL(("PackFile_Annotations_unpack: group[%d]/%d bytecode_offset=%d entries_offset=%d\n", 
     4062                          i, self->num_groups, self->groups[i]->bytecode_offset, self->groups[i]->entries_offset)); 
    40934063    } 
    40944064 
    40954065    /* Unpack entries. */ 
     
    44494419PackFile_append_pbc(PARROT_INTERP, ARGIN_NULLOK(const char *filename)) 
    44504420{ 
    44514421    ASSERT_ARGS(PackFile_append_pbc) 
    4452     PackFile * const pf = Parrot_readbc(interp, filename); 
     4422        PackFile * const pf = Parrot_pbc_read(interp, filename, 0); 
    44534423    if (!pf) 
    44544424        return NULL; 
    44554425    PackFile_add_segment(interp, &interp->initial_pf->directory, 
     
    45584528 
    45594529=head1 HISTORY 
    45604530 
     4531Trace macros and 64-bit fixes by Reini Urban, 2009-02-03 
     4532 
    45614533Rework by Melvin; new bytecode format, make bytecode portable. (Do 
    45624534endian conversion and wordsize transforms on the fly.) 
    45634535 
  • docs/embed.pod

     
    2121            return 1; 
    2222        } 
    2323 
    24         pf = Parrot_readbc(interp, "foo.pbc"); 
    25         Parrot_loadbc(interp, pf); 
     24        pf = Parrot_pbc_read(interp, "foo.pbc", 0); 
     25        Parrot_pbc_load(interp, pf); 
    2626        Parrot_runcode(interp, argc, argv); 
    2727 
    2828        Parrot_destroy(interp); 
     
    245245 
    246246=over 4 
    247247 
    248 =item C<Parrot_PackFile Parrot_readbc(PARROT_INTERP, const char *path)> 
     248=item C<Parrot_PackFile Parrot_pbc_read(PARROT_INTERP, const char *path, int debug)> 
    249249 
    250250Reads Parrot bytecode or PIR from the file referenced by C<path>.  Returns 
    251 a packfile structure for use by C<Parrot_loadbc()>. 
     251a packfile structure for use by C<Parrot_pbc_load()>. 
    252252 
    253 =item C<void Parrot_loadbc(PARROT_INTERP, Parrot_PackFile pf)> 
     253=item C<void Parrot_pbc_load(PARROT_INTERP, Parrot_PackFile pf)> 
    254254 
    255255Loads a packfile into the interpreter.  After this operation the interpreter 
    256256is ready to run the bytecode in the packfile. 
  • tools/util/dump_pbc.pl

     
    7070    my %cache; 
    7171 
    7272    foreach (@dis) { 
    73         if    (/^Current Source Filename (.*)/) { 
    74             if ($cur_file ne $1) { 
    75                 $cur_file           = $1; 
     73        if (/^(?:# )?Current Source Filename (.*)/) { 
     74            my $found = $1; 
     75            $found =~ s/^'//; 
     76            $found =~ s/'$//; 
     77            if ($cur_file ne $found) { 
     78                $cur_file           = $found; 
    7679                $cache{$cur_file} ||= slurp_file($cur_file); 
    7780                $cur_line           = -1; 
    7881 
  • tools/dev/pbc_to_exe_gen.pl

     
    267267 
    268268    do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL); 
    269269 
    270     Parrot_loadbc(interp, pf); 
     270    Parrot_pbc_load(interp, pf); 
    271271 
    272272    PackFile_fixup_subs(interp, PBC_MAIN, NULL); 
    273273    Parrot_runcode(interp, argc, argv); 
  • include/parrot/embed.h

     
    2222 
    2323typedef int Parrot_warnclass; 
    2424 
     25typedef enum { 
     26    enum_DIS_BARE      = 1, 
     27    enum_DIS_HEADER    = 2 
     28} Parrot_disassemble_options; 
     29 
    2530PARROT_EXPORT Parrot_Interp Parrot_new(Parrot_Interp parent); 
    2631 
    2732PARROT_EXPORT void Parrot_init_stacktop(Parrot_Interp, void *); 
     
    4449 
    4550PARROT_EXPORT void Parrot_setwarnings(Parrot_Interp, Parrot_warnclass); 
    4651 
    47 PARROT_EXPORT Parrot_PackFile Parrot_readbc(Parrot_Interp, const char *); 
     52PARROT_EXPORT Parrot_PackFile Parrot_pbc_read(Parrot_Interp, const char *, int); 
    4853 
    49 PARROT_EXPORT void Parrot_loadbc(Parrot_Interp, Parrot_PackFile); 
     54PARROT_EXPORT void Parrot_pbc_load(Parrot_Interp, Parrot_PackFile); 
    5055 
    5156PARROT_EXPORT void Parrot_setup_argv(Parrot_Interp, int argc, const char **argv); 
    5257 
     
    5863 
    5964PARROT_EXPORT Parrot_Opcode * Parrot_debug(Parrot_Interp, Parrot_Interp, Parrot_Opcode *pc); 
    6065 
    61 PARROT_EXPORT void Parrot_disassemble(Parrot_Interp); 
     66PARROT_EXPORT void Parrot_disassemble(Parrot_Interp, char *outfile, Parrot_disassemble_options options); 
    6267 
    6368PARROT_EXPORT 
    6469PARROT_DOES_NOT_RETURN 
  • include/parrot/packfile.h

     
    2424#define CONSTANT_SEGMENT_NAME    "CONSTANT" 
    2525#define BYTE_CODE_SEGMENT_NAME   "BYTECODE" 
    2626 
     27#define TRACE_PACKFILE 0 
     28#if TRACE_PACKFILE 
     29#  define TRACE_PRINTF(args)       if (pf->options) Parrot_trace_eprintf args 
     30#  if TRACE_PACKFILE == 2 
     31#    define TRACE_PRINTF_VAL(args) if (pf->options & 2) Parrot_trace_eprintf args 
     32#  else 
     33#    define TRACE_PRINTF_VAL(args) 
     34#  endif 
     35#else 
     36#  define TRACE_PRINTF(args) 
     37#  define TRACE_PRINTF_VAL(args) 
     38#endif 
     39 
    2740/* 
    2841** Structure Definitions: 
    2942*/ 
     
    271284 
    272285    PackFile_ByteCode  * cur_cs;   /* used during PF loading */ 
    273286 
     287    INTVAL    options; 
    274288    INTVAL    need_wordsize; 
    275289    INTVAL    need_endianize; 
    276290 
  • compilers/imcc/main.c

     
    972972              opt_desc, opt_level); 
    973973 
    974974    pf = PackFile_new(interp, 0); 
    975     Parrot_loadbc(interp, pf); 
     975    Parrot_pbc_load(interp, pf); 
    976976 
    977977    IMCC_push_parser_state(interp); 
    978978    IMCC_INFO(interp)->state->file = sourcefile; 
     
    10761076    /* If the input file is Parrot bytecode, then we simply read it 
    10771077       into a packfile, which Parrot then loads */ 
    10781078    if (STATE_LOAD_PBC(interp)) { 
    1079         PackFile * const pf = Parrot_readbc(interp, sourcefile); 
     1079        PackFile * const pf = Parrot_pbc_read(interp, sourcefile, 0); 
    10801080 
    10811081        if (!pf) 
    10821082            IMCC_fatal_standalone(interp, 1, "main: Packfile loading failed\n"); 
    1083         Parrot_loadbc(interp, pf); 
     1083        Parrot_pbc_load(interp, pf); 
    10841084    } 
    10851085    else 
    10861086        compile_to_bytecode(interp, sourcefile, output_file); 
     
    10981098            PackFile *pf; 
    10991099 
    11001100            IMCC_info(interp, 1, "Loading %s\n", output_file); 
    1101             pf = Parrot_readbc(interp, output_file); 
     1101            pf = Parrot_pbc_read(interp, output_file, 0); 
    11021102            if (!pf) 
    11031103                IMCC_fatal_standalone(interp, 1, "Packfile loading failed\n"); 
    1104             Parrot_loadbc(interp, pf); 
     1104            Parrot_pbc_load(interp, pf); 
    11051105            SET_STATE_LOAD_PBC(interp); 
    11061106        } 
    11071107    } 
  • compilers/pirc/src/bcgen.c

     
    380380 
    381381    /* Create a new packfile and load it into the parrot interpreter */ 
    382382    bc->packfile = PackFile_new(interp, 0); 
    383     Parrot_loadbc(interp, bc->packfile); 
     383    Parrot_pbc_load(interp, bc->packfile); 
    384384 
    385385    /* store a pointer to the parrot interpreter, which saves passing around 
    386386     * the interp as an extra argument. 
  • t/src/extend.t

     
    440440static opcode_t* 
    441441the_test(PARROT_INTERP, opcode_t *cur_op, opcode_t *start) 
    442442{ 
    443     PackFile *pf = Parrot_readbc(interp, "$temp_pbc"); 
     443    PackFile *pf = Parrot_pbc_read(interp, "$temp_pbc", 0); 
    444444    STRING   *name = Parrot_str_new_constant(interp, "_sub1"); 
    445445    PMC      *sub, *arg; 
    446446 
    447     Parrot_loadbc(interp, pf); 
     447    Parrot_pbc_load(interp, pf); 
    448448    sub = Parrot_find_global_cur(interp, name); 
    449449    Parrot_call_sub(interp, sub, "v"); 
    450450    Parrot_eprintf(interp, "back\\n"); 
     
    514514static opcode_t* 
    515515the_test(PARROT_INTERP, opcode_t *cur_op, opcode_t *start) 
    516516{ 
    517     PackFile         *pf   = Parrot_readbc(interp, "$temp_pbc"); 
     517    PackFile         *pf   = Parrot_pbc_read(interp, "$temp_pbc", 0); 
    518518    STRING           *name = Parrot_str_new_constant(interp, "_sub1"); 
    519519    PMC              *sub; 
    520520    Parrot_runloop jump_point; 
    521521 
    522     Parrot_loadbc(interp, pf); 
     522    Parrot_pbc_load(interp, pf); 
    523523    sub = Parrot_find_global_cur(interp, name); 
    524524 
    525525    if (setjmp(jump_point.resume)) { 
     
    602602        return 1; 
    603603    } 
    604604 
    605     packfile = Parrot_readbc( interp, "$temp_pbc" ); 
     605    packfile = Parrot_pbc_read( interp, "$temp_pbc", 0 ); 
    606606 
    607607    if (!packfile) { 
    608608        printf( "Boo\\n" ); 
    609609        return 1; 
    610610    } 
    611611 
    612     Parrot_loadbc( interp, packfile ); 
     612    Parrot_pbc_load( interp, packfile ); 
    613613    Parrot_runcode( interp, 1, code ); 
    614614 
    615615    Parrot_destroy( interp ); 
     
    684684        return 1; 
    685685    } 
    686686 
    687     pf = Parrot_readbc( interp, "$temp_pbc" ); 
    688     Parrot_loadbc( interp, pf ); 
     687    pf = Parrot_pbc_read( interp, "$temp_pbc", 0 ); 
     688    Parrot_pbc_load( interp, pf ); 
    689689 
    690690    sub      = Parrot_find_global_cur( interp, Parrot_str_new_constant( interp, "add" ) ); 
    691691    result   = Parrot_call_sub( interp, sub, "III", 100, 200 ); 
  • examples/c/test_main.c

     
    8080 
    8181    filename = parseflags(interp, &argc, &argv); 
    8282 
    83     pf = Parrot_readbc(interp, filename); 
     83    pf = Parrot_pbc_read(interp, filename, 0); 
    8484 
    8585    if (!pf) { 
    8686        return 1; 
    8787    } 
    8888 
    89     Parrot_loadbc(interp, pf); 
     89    Parrot_pbc_load(interp, pf); 
    9090    Parrot_runcode(interp, argc, argv); 
    9191    Parrot_destroy(interp); 
    9292