Beispiel #1
0
static void debug_memory(struct context* ctx)
{
	/* dump memory as user requested */
	if (rr_flags->dump_on == ctx->trace.stop_reason
	    || rr_flags->dump_on == DUMP_ON_ALL
	    || rr_flags->dump_at == ctx->trace.global_time) {
		char pid_str[PATH_MAX];
		snprintf(pid_str, sizeof(pid_str) - 1, "%s/%d_%d_rep",
			 get_trace_path(),
			 ctx->child_tid, ctx->trace.global_time);
		print_process_memory(ctx, pid_str);
	}

	/* check memory checksum */
	if (validate
	    && ((rr_flags->checksum == CHECKSUM_ALL)
		|| (rr_flags->checksum == CHECKSUM_SYSCALL
		    && ctx->trace.state == STATE_SYSCALL_EXIT)
		|| (rr_flags->checksum <= ctx->trace.global_time))) {
		validate_process_memory(ctx);
	}
}
Beispiel #2
0
/*
 * Produce a consensus trace from a specific region of this contig.
 */
Read *cons_trace(EdStruct *xx, int start, int end, int strand,
		 int match, int exception) {
    int *seqList, i, j, count, next;
    Read *r;
    int max_points = 10000;
    char *con = NULL;
    diff_cons_seq *rlist = NULL;
    char fileName[256];
    char t_type[5];
    int form;
    int offset = 0, w;

    /* Get the consensus sequence */
    if (NULL == (con = (char *)xmalloc(end - start + 2)))
	goto error;
    DBcalcConsensus(xx, start, end - start + 1, con, NULL, BOTH_STRANDS);

    /* Allocate a list of read pointers and positions */
    if (NULL == (rlist = (diff_cons_seq *)xcalloc(DBI_gelCount(xx),
						  sizeof(*rlist))))
	goto error;

    /* Allocate a read structure */
    if (NULL == (r = read_allocate(max_points, end - start + 1)))
	goto error;

    /* Derive the initial list of sequences covering the start point */
    count = 0;
    seqList = DBI_list(xx);
    for (i = 1;
	 i <= DBI_gelCount(xx) && DB_RelPos(xx, DBI_order(xx)[i]) <= start;
	 i++) {
	int seq = DBI_order(xx)[i];
	DBgetSeq(DBI(xx), seq);
	if (DB_RelPos(xx, seq) + DB_Length(xx, seq) > start &&
	    strand_matches(xx, seq, strand) &&
	    seq != exception) {
	    if (get_trace_path(xx, seq, fileName, t_type) == 0) {
		form = trace_type_str2int(t_type);
		rlist[count].r = read_reading(fileName, form);
		if (rlist[count].r) {
		    rlist[count].seq = DBgetSeq(DBI(xx), seq);
		    rlist[count].opos =
			get_trace_pos(rlist[count].r, xx, seq, 0,
				      DB_Start(xx, seq),
				      DB_Start(xx, seq) + DB_Length(xx, seq),
				      DB_Seq(xx, seq), 0);

		    seqList[count++] = seq;
		}
	    }
	}
    }
    if (i <= DBI_gelCount(xx))
	next = i;
    else
	next = 0;

    /*
     * Loop along the sequence updating seqList as we go.
     * At each point we know how many sequences there are so we can
     * produce the consensus from these sequences.
     */
    for (i = start; i <= end; i++) {
	w = do_cons_base(xx, con, i, start, count, seqList, rlist, r, offset,
			 match, &max_points);
	if (w == -1)
	    goto error;
	offset += w;

	/* Update seqList for the next position */
	if (i < end) {
	    /* Remove sequences */
	    for (j = 0; j < count; j++) {
		int seq = seqList[j];
		if (DB_RelPos(xx, seq) + DB_Length(xx, seq) - 1 <= i) {
		    read_deallocate(rlist[j].r);
		    xfree(rlist[j].opos);
		    memmove(&seqList[j], &seqList[j+1],
			    (count-1-j) * sizeof(*seqList));
		    memmove(&rlist[j], &rlist[j+1],
			    (count-1-j) * sizeof(*rlist));
		    count--;
		    j--;
		}
	    }

	    /* Add sequences */
	    while (next && DB_RelPos(xx, next) <= i+1) {
		/* printf("next=%d %d %d\n",
		       next, DB_RelPos(xx, next), i+1); */
		DBgetSeq(DBI(xx), next);
		if (strand_matches(xx, next, strand) &&
		    get_trace_path(xx, next, fileName, t_type) == 0) {
		    form = trace_type_str2int(t_type);
		    rlist[count].r = read_reading(fileName, form);
		    if (rlist[count].r) {
			rlist[count].seq = DBgetSeq(DBI(xx), next);
			rlist[count].opos =
			    get_trace_pos(rlist[count].r, xx, next, 0,
					  DB_Start(xx, next),
					  DB_Start(xx,next)+DB_Length(xx,next),
					  DB_Seq(xx, next), 0);

			seqList[count++] = next;
		    }
		}
		if (++next > DBI_gelCount(xx))
		    next = 0;
	    }
	}
    }

    for (i = 0; i < count; i++) {
	read_deallocate(rlist[i].r);
	xfree(rlist[i].opos);
    }

    tidy_up(r, end-start + 1, offset);

    xfree(con);
    xfree(rlist);
    return r;

 error:
    if (con) xfree(con);
    if (rlist) xfree(rlist);
    return NULL;
}