예제 #1
0
PARROT_EXPORT
void
Parrot_set_trace(PARROT_INTERP, UINTVAL flag)
{
    Parrot_pcc_trace_flags_on(interp, interp->ctx, flag);
    Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
}
예제 #2
0
PARROT_EXPORT
void
Parrot_set_flag(PARROT_INTERP, INTVAL flag)
{
    /* These two macros (from interpreter.h) do exactly what they look like. */

    Interp_flags_SET(interp, flag);
    switch (flag) {
        case PARROT_BOUNDS_FLAG:
        case PARROT_PROFILE_FLAG:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
            break;
        default:
            break;
    }
}
예제 #3
0
PARROT_EXPORT
void
Parrot_set_run_core(PARROT_INTERP, Parrot_Run_core_t core)
{
    switch (core) {
        case PARROT_SLOW_CORE:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
            break;
        case PARROT_FAST_CORE:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "fast"));
            break;
        case PARROT_SWITCH_CORE:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "switch"));
            break;
        case PARROT_CGP_CORE:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "cgp"));
            break;
        case PARROT_CGOTO_CORE:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "cgoto"));
            break;
        case PARROT_EXEC_CORE:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "exec"));
            break;
        case PARROT_GC_DEBUG_CORE:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "gc_debug"));
            break;
        case PARROT_DEBUGGER_CORE:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "debugger"));
            break;
        case PARROT_PROFILING_CORE:
            Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "profiling"));
            break;
        default:
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
                "Invalid runcore requested\n");
    }
}
예제 #4
0
파일: main.c 프로젝트: kapace/parrot
int
main(int argc, const char *argv[])
{
    int nextarg;
    Parrot_Interp     interp;
    PDB_t *pdb;
    const char       *scriptname = NULL;
    const unsigned char * configbytes = Parrot_get_config_hash_bytes();
    const int configlength = Parrot_get_config_hash_length();

    interp = Parrot_new(NULL);

    Parrot_set_executable_name(interp, Parrot_str_new(interp, argv[0], 0));

    Parrot_set_configuration_hash_legacy(interp, configlength, configbytes);

    Parrot_debugger_init(interp);
    pdb = interp->pdb;
    pdb->state       = PDB_ENTER;

    Parrot_block_GC_mark(interp);
    Parrot_block_GC_sweep(interp);

    nextarg = 1;
    if (argv[nextarg] && strcmp(argv[nextarg], "--script") == 0)
    {
        scriptname = argv [++nextarg];
        ++nextarg;
    }

    if (argv[nextarg]) {
        const char *filename = argv[nextarg];
        const char *ext      = strrchr(filename, '.');

        if (ext && STREQ(ext, ".pbc")) {
            Parrot_PackFile pf = Parrot_pbc_read(interp, filename, 0);

            if (!pf)
                return 1;

            Parrot_pbc_load(interp, pf);
            PackFile_fixup_subs(interp, PBC_MAIN, NULL);
        }
        else {
            STRING          *errmsg = NULL;
            Parrot_PackFile  pf     = PackFile_new(interp, 0);

            Parrot_pbc_load(interp, pf);
            Parrot_compile_file(interp, filename, &errmsg);
            if (errmsg)
                Parrot_ex_throw_from_c_args(interp, NULL, 1, "%S", errmsg);
            PackFile_fixup_subs(interp, PBC_POSTCOMP, NULL);

            /* load the source for debugger list */
            PDB_load_source(interp, filename);

            PackFile_fixup_subs(interp, PBC_MAIN, NULL);
        }

    }
    else {
        /* Generate some code to be able to enter into runloop */

        STRING *compiler = Parrot_str_new_constant(interp, "PIR");
        STRING *errstr = NULL;
        const char source []= ".sub aux :main\nexit 0\n.end\n";
        Parrot_compile_string(interp, compiler, source, &errstr);

        if (!STRING_IS_NULL(errstr))
            Parrot_io_eprintf(interp, "%Ss\n", errstr);
    }

    Parrot_unblock_GC_mark(interp);
    Parrot_unblock_GC_sweep(interp);

    if (scriptname)
        PDB_script_file(interp, scriptname);
    else
        PDB_printwelcome();

    Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "debugger"));
    PDB_run_code(interp, argc - nextarg, argv + nextarg);

    Parrot_x_exit(interp, 0);
}
예제 #5
0
파일: main.c 프로젝트: biddyweb/parrot
int
main(int argc, const char *argv[])
{
    int nextarg;
    Parrot_Interp     interp;
    PDB_t *pdb;
    const char       *scriptname = NULL;

    interp = Parrot_interp_new(NULL);

    Parrot_debugger_init(interp);
    pdb = interp->pdb;
    pdb->state       = PDB_ENTER;

    Parrot_block_GC_mark(interp);
    Parrot_block_GC_sweep(interp);

    nextarg = 1;
    if (argv[nextarg] && strcmp(argv[nextarg], "--script") == 0) {
        scriptname = argv [++nextarg];
        ++nextarg;
    }

    if (argv[nextarg]) {
        const char * const filename = argv[nextarg];

        if (*filename == '-') {
            fprintf(stderr, "parrot_debugger takes no -x or --xxxx flag arguments\n");
            exit(1);
        }
        else {
            STRING *   const filename_str = Parrot_str_new(interp, filename, 0);
            PackFile * const pfraw        = Parrot_pf_read_pbc_file(interp, filename_str);
            Parrot_PackFile pf;

            if (pfraw == NULL)
                return 1;

            pf = Parrot_pf_get_packfile_pmc(interp, pfraw, filename_str);
            if (pf == NULL)
                return 1;

            Parrot_pf_set_current_packfile(interp, pf);
            Parrot_pf_prepare_packfile_init(interp, pf);
        }
    }
    else {
        /* Generate some code to be able to enter into runloop */
        STRING * const compiler_s = Parrot_str_new_constant(interp, "PIR");
        PMC *    const compiler   = Parrot_interp_get_compiler(interp, compiler_s);
        STRING * const source     = Parrot_str_new_constant(interp,
                                        ".sub aux :main\nexit 0\n.end\n");
        PMC *    const code       = Parrot_interp_compile_string(interp, compiler, source);

        if (PMC_IS_NULL(code))
            Parrot_warn(interp, PARROT_WARNINGS_NONE_FLAG,
                "Unexpected compiler problem at debugger start");
    }

    Parrot_unblock_GC_mark(interp);
    Parrot_unblock_GC_sweep(interp);

    if (scriptname)
        PDB_script_file(interp, scriptname);
    else
        PDB_printwelcome();

    Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "debugger"));
    PDB_run_code(interp, argc - nextarg, argv + nextarg);

    Parrot_x_exit(interp, 0);
}