Example #1
0
 std::string to_string() const {
     std::ostringstream out;
     dump_field(n_workers) << ", ";
     dump_field(n_stripes) << ", ";
     dump_field(n_additions);
     return out.str();
 }
Example #2
0
int riscv_batch_run(struct riscv_batch *batch)
{
	if (batch->used_scans == 0) {
		LOG_DEBUG("Ignoring empty batch.");
		return ERROR_OK;
	}

	keep_alive();

	LOG_DEBUG("running a batch of %ld scans", (long)batch->used_scans);
	riscv_batch_add_nop(batch);

	for (size_t i = 0; i < batch->used_scans; ++i) {
		jtag_add_dr_scan(batch->target->tap, 1, batch->fields + i, TAP_IDLE);
		if (batch->idle_count > 0)
			jtag_add_runtest(batch->idle_count, TAP_IDLE);
	}

	LOG_DEBUG("executing queue");
	if (jtag_execute_queue() != ERROR_OK) {
		LOG_ERROR("Unable to execute JTAG queue");
		return ERROR_FAIL;
	}

	for (size_t i = 0; i < batch->used_scans; ++i)
		dump_field(batch->fields + i);

	return ERROR_OK;
}
static void dump_insn(FILE *fp, struct insn *insn)
{
	fprintf(fp, "Instruction = {\n");
	dump_field(fp, "prefixes", "\t",	&insn->prefixes);
	dump_field(fp, "rex_prefix", "\t",	&insn->rex_prefix);
	dump_field(fp, "vex_prefix", "\t",	&insn->vex_prefix);
	dump_field(fp, "opcode", "\t",		&insn->opcode);
	dump_field(fp, "modrm", "\t",		&insn->modrm);
	dump_field(fp, "sib", "\t",		&insn->sib);
	dump_field(fp, "displacement", "\t",	&insn->displacement);
	dump_field(fp, "immediate1", "\t",	&insn->immediate1);
	dump_field(fp, "immediate2", "\t",	&insn->immediate2);
	fprintf(fp, "\t.attr = %x, .opnd_bytes = %d, .addr_bytes = %d,\n",
		insn->attr, insn->opnd_bytes, insn->addr_bytes);
	fprintf(fp, "\t.length = %d, .x86_64 = %d, .kaddr = %p}\n",
		insn->length, insn->x86_64, insn->kaddr);
}
/* Dump all the fields of interest */
static void
dump_fields(RefIndex list, FieldInfo *fields, jvalue *fvalues, int n_fields)
{
    int i;
    
    debug_message("\nHPROF LIST OF ALL FIELDS:\n");
    for ( i = 0 ; i < n_fields ; i++ ) {
        if ( fields[i].name_index != 0 ) {
            dump_field(fields, fvalues, n_fields, i, fvalues[i], fields[i].primType);
        }
    }
    dump_ref_list(list);
}
/* Verify field data */
static void
verify_field(RefIndex list, FieldInfo *fields, jvalue *fvalues, int n_fields,
                jint index, jvalue value, jvmtiPrimitiveType primType)
{
    HPROF_ASSERT(fvalues != NULL);
    HPROF_ASSERT(n_fields > 0);
    HPROF_ASSERT(index < n_fields);
    HPROF_ASSERT(index >= 0 );
    if ( primType!=fields[index].primType ) {
        dump_fields(list, fields, fvalues, n_fields);
        debug_message("\nPROBLEM WITH:\n");
        dump_field(fields, fvalues, n_fields, index, value, primType);
        debug_message("\n");
        HPROF_ERROR(JNI_FALSE, "Trouble with fields and heap data");
    }
    if ( primType == JVMTI_PRIMITIVE_TYPE_BOOLEAN && 
         ( value.b != 1 && value.b != 0 ) ) {
        dump_fields(list, fields, fvalues, n_fields);
        debug_message("\nPROBLEM WITH:\n");
        dump_field(fields, fvalues, n_fields, index, value, primType);
        debug_message("\n");
        HPROF_ERROR(JNI_FALSE, "Trouble with fields and heap data");
    }
}
Example #6
0
File: dfs.cpp Project: joken/stonez
int solve(Field f, Position p, int flip, int rotate, int i, int nowscore) {
  if (i >= number_of_stones) {
    return 0;
  }
  int u = i;

  if (flip == 1) {
    u += fliped;
  }

  u += rot[rotate / 90];

  std::vector<Position> next_positions;
  int score = 0;

  if (score = put_stone(f, p, u, next_positions)) {
    score += nowscore;
    if (score > max_score) {
      max_score = score;
      max_score_field = f;
      fprintf(stderr, "max score %d!\n", score);
    }
    f.answer[i] = make_answer(p, flip, rotate);
    printf("score: %d\n", score);
    dump_field(f);
    print_answer(f.answer);
    int rot_buf[] = {0, 90, 180, 270};
    for (auto && f_p : next_positions) {
      for (int j = i + 1; j < number_of_stones; ++j) {
        for (auto && s_p : stones[j].fills) {
          for (int k = 0; k < 4; ++k) {
            solve(f, Position{f_p.y - s_p.y, f_p.x - s_p.x}, 0, rot_buf[k], j, score);
            solve(f, Position{f_p.y - s_p.y, f_p.x - s_p.x}, 1, rot_buf[k], j, score);
          }
        }
      }
    }
  }

  return 0;
}
Example #7
0
 std::string to_string() const {
     std::ostringstream out;
     dump_field(n_elements) << ", ";
     dump_field(n_additions);
     return out.str();
 }
Example #8
0
/*
 *      sscript_save - save a script lump to file
 */
int sscript_save(struct WADINFO *wad, int16_t n, const char *file)
{
    FILE *fp = NULL;
    unsigned char *data = NULL;
    int32_t size = 0;
    const char *lumpname = wad->dir[n].name;

    data = (unsigned char *) WADRreadEntry(wad, n, &size);
    if (size % PAGESZ) {
        Warning("SS10", "script %s: weird size %ld", lump_name(lumpname),
                (long) size);
        size = PAGESZ * (size / PAGESZ);
    }
    fp = fopen(file, "w");
    if (fp == NULL) {
        nf_err("SS15", "%s: %s", file, strerror(errno));
        return 1;
    }
    fprintf(fp, "# DeuTex Strife script source version 1\n");
    /* Save all pages */
    {
        int p;
        for (p = 0; p < size / PAGESZ; p++) {
            unsigned long ofs = PAGESZ * p;
            int o;

            fputc('\n', fp);
            fprintf(fp, "page %d {\n", p);
            dump_field(fp, data, &ofs, FT_I32, "    unknown0   ");
            dump_field(fp, data, &ofs, FT_I32, "    unknown1   ");
            dump_field(fp, data, &ofs, FT_I32, "    unknown2   ");
            dump_field(fp, data, &ofs, FT_I32, "    unknown3   ");
            dump_field(fp, data, &ofs, FT_I32, "    unknown4   ");
            dump_field(fp, data, &ofs, FT_I32, "    unknown5   ");
            dump_field(fp, data, &ofs, FT_S16, "    character  ");
            dump_field(fp, data, &ofs, FT_NAME, "    voice      ");
            dump_field(fp, data, &ofs, FT_NAME, "    background ");
            dump_field(fp, data, &ofs, FT_S320, "    statement  ");

            for (o = 0; o < 5; o++) {
                /* If the option is zeroed out, omit it */
                if (mem_is_zero((char *) (data + ofs), OPTIONSZ)) {
                    ofs += OPTIONSZ;
                    continue;
                }

                /* Else, decode it */
                fputc('\n', fp);
                fprintf(fp, "    option %d {\n", o);
                dump_field(fp, data, &ofs, FT_I32, "        whata   ");
                dump_field(fp, data, &ofs, FT_I32, "        whatb   ");
                dump_field(fp, data, &ofs, FT_I32, "        whatc   ");
                dump_field(fp, data, &ofs, FT_I32, "        whatd   ");
                dump_field(fp, data, &ofs, FT_I32, "        whate   ");
                dump_field(fp, data, &ofs, FT_I32, "        price   ");
                dump_field(fp, data, &ofs, FT_I32, "        whatg   ");
                dump_field(fp, data, &ofs, FT_S32, "        option  ");
                dump_field(fp, data, &ofs, FT_S80, "        success ");
                dump_field(fp, data, &ofs, FT_I32, "        whath   ");
                dump_field(fp, data, &ofs, FT_I32, "        whati   ");
                dump_field(fp, data, &ofs, FT_S80, "        failure ");
                fputs("    }\n", fp);
            }

            fputs("}\n", fp);
            /* Sanity check */
            if (ofs % PAGESZ)
                Bug("SS20", "script %s: page %d: bad script offset %d",
                    lump_name(lumpname), p, (int) ofs);
        }
    }

    free(data);
    if (fclose(fp)) {
        nf_err("SS45", "%s: %s", file, strerror(errno));
        return 1;
    }
    return 0;
}