Beispiel #1
0
static __inline__ void
hipe_push_beam_trap_frame(Process *p, Eterm reg[], unsigned arity)
{
    /* ensure that at least 2 words are available on the BEAM stack */
    if ((p->stop - 2) < p->htop) {
	DPRINTF("calling gc to increase BEAM stack size");
	p->fcalls -= erts_garbage_collect(p, 2, reg, arity);
    }
    p->stop -= 2;
    p->stop[1] = hipe_beam_catch_throw;
    p->stop[0] = make_cp(p->cp);
    ++p->catches;
    p->cp = hipe_beam_pc_return;
}
Beispiel #2
0
void make_cp(char *from_path, char *to_path)
{
	struct stat buf, buf1;
	
	DIR *dir=opendir(from_path);
	
	if(dir==NULL) {
		perror(from_path);
		return;
	}
	
	struct dirent *curr_dir;
	
    while ( (curr_dir = readdir(dir)) != NULL) 
    {	
		if (curr_dir->d_name[0]!='.') {
			strcat(to_path, "/");
			strcat(to_path, curr_dir->d_name); 			
			strcat(from_path, "/");
			strcat(from_path, curr_dir->d_name);	
			
			if (stat(from_path, &buf) < 0)
				perror(curr_dir->d_name);			
			else if( S_ISDIR(buf.st_mode) ) {
				if (stat(to_path, &buf1)<0)
					if( mkdir(to_path, buf.st_mode) )
						perror(to_path);
				make_cp(from_path, to_path);
			}
			else 
				copy_file(from_path, to_path);
			
			int i;
			for(i=strlen(from_path)-1; from_path[i]!='/' && i>0; --i) from_path[i]='\0';
			from_path[i]='\0';
			for(i=strlen(to_path)-1;  to_path[i]!='/' && i>0; --i) to_path[i]='\0';
			to_path[i]='\0';
		}
    }
    
	closedir(dir);
	return;	
}
Beispiel #3
0
static __inline__ void
hipe_push_beam_trap_frame(Process *p, Eterm reg[], unsigned arity)
{
    if (&p->stop[1] < p->hend && p->stop[1] == hipe_beam_catch_throw) {
	/* Trap frame already reserved */
	ASSERT(p->stop[0] == NIL);
    }
    else {
	ASSERT(!(p->flags & F_DISABLE_GC));
	if ((p->stop - 2) < p->htop) {
	    DPRINTF("calling gc to increase BEAM stack size");
	    erts_garbage_collect(p, 2, reg, arity);
	    ASSERT(!((p->stop - 2) < p->htop));
	}
	p->stop -= 2;
	p->stop[1] = hipe_beam_catch_throw;
    }
    p->stop[0] = make_cp(p->cp);
    ++p->catches;
    p->cp = hipe_beam_pc_return;
}
Beispiel #4
0
int main(int argc, char **argv)
{
	int k=0;
	int begin=read_args(argc, argv, &k);
	if (k==1)
		copy_file(argv[argc-2], argv[argc-1]);
	else if (k==2) {
		char temp_str1[MAX_PATH_LENGTH];
		char temp_str2[MAX_PATH_LENGTH];

		struct stat buf, buf1;
		strcpy(temp_str2, argv[argc-1]);
		
		for(int i=begin; i<argc-1; ++i)
		{
			stat(argv[i], &buf);
			strcpy(temp_str1, argv[i]);
			strcpy(temp_str2, argv[argc-1]);
			
			int j=0;
			for( j=strlen(argv[i])-1; argv[i][j]!='/' && j>=0; --j);
			
			strcat(temp_str2, "/");
			strcat(temp_str2, &argv[i][j+1]);
			
			if( S_ISDIR(buf.st_mode) ) {
				if (stat(temp_str2, &buf1)<0)
					if( mkdir(temp_str2, buf.st_mode) )
						perror(temp_str2);
				make_cp (temp_str1, temp_str2);
			}
			else
				copy_file (temp_str1, temp_str2);
		}
	}
	exit(0);
}
Beispiel #5
0
BeamInstr
erts_generic_breakpoint(Process* c_p, BeamInstr* I, Eterm* reg)
{
    GenericBp* g;
    GenericBpData* bp;
    Uint bp_flags;
    ErtsBpIndex ix = erts_active_bp_ix();

    g = (GenericBp *) I[-4];
    bp = &g->data[ix];
    bp_flags = bp->flags;
    ASSERT((bp_flags & ~ERTS_BPF_ALL) == 0);
    if (bp_flags & (ERTS_BPF_LOCAL_TRACE|
		    ERTS_BPF_GLOBAL_TRACE|
		    ERTS_BPF_TIME_TRACE_ACTIVE) &&
	!IS_TRACED_FL(c_p, F_TRACE_CALLS)) {
	bp_flags &= ~(ERTS_BPF_LOCAL_TRACE|
		      ERTS_BPF_GLOBAL_TRACE|
		      ERTS_BPF_TIME_TRACE|
		      ERTS_BPF_TIME_TRACE_ACTIVE);
	if (bp_flags == 0) {	/* Quick exit */
	    return g->orig_instr;
	}
    }

    if (bp_flags & ERTS_BPF_LOCAL_TRACE) {
	ASSERT((bp_flags & ERTS_BPF_GLOBAL_TRACE) == 0);
	(void) do_call_trace(c_p, I, reg, 1, bp->local_ms, erts_tracer_true);
    } else if (bp_flags & ERTS_BPF_GLOBAL_TRACE) {
	(void) do_call_trace(c_p, I, reg, 0, bp->local_ms, erts_tracer_true);
    }

    if (bp_flags & ERTS_BPF_META_TRACE) {
	ErtsTracer old_tracer, new_tracer;

	old_tracer = erts_smp_atomic_read_nob(&bp->meta_tracer->tracer);

	new_tracer = do_call_trace(c_p, I, reg, 1, bp->meta_ms, old_tracer);
	if (!ERTS_TRACER_COMPARE(new_tracer, old_tracer)) {
            if (old_tracer == erts_smp_atomic_cmpxchg_acqb(
                    &bp->meta_tracer->tracer,
                    (erts_aint_t)new_tracer,
                    (erts_aint_t)old_tracer)) {
                ERTS_TRACER_CLEAR(&old_tracer);
            } else {
                ERTS_TRACER_CLEAR(&new_tracer);
            }
	}
    }

    if (bp_flags & ERTS_BPF_COUNT_ACTIVE) {
	erts_smp_atomic_inc_nob(&bp->count->acount);
    }

    if (bp_flags & ERTS_BPF_TIME_TRACE_ACTIVE) {
	Eterm w;
	erts_trace_time_call(c_p, I, bp->time);
	w = (BeamInstr) *c_p->cp;
	if (! (w == (BeamInstr) BeamOp(op_i_return_time_trace) ||
	       w == (BeamInstr) BeamOp(op_return_trace) ||
	       w == (BeamInstr) BeamOp(op_i_return_to_trace)) ) {
	    Eterm* E = c_p->stop;
	    ASSERT(c_p->htop <= E && E <= c_p->hend);
	    if (E - 2 < c_p->htop) {
		(void) erts_garbage_collect(c_p, 2, reg, I[-1]);
		ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p);
	    }
	    E = c_p->stop;

	    ASSERT(c_p->htop <= E && E <= c_p->hend);

	    E -= 2;
	    E[0] = make_cp(I);
	    E[1] = make_cp(c_p->cp);     /* original return address */
	    c_p->cp = beam_return_time_trace;
	    c_p->stop = E;
	}
    }

    if (bp_flags & ERTS_BPF_DEBUG) {
	return (BeamInstr) BeamOp(op_i_debug_breakpoint);
    } else {
	return g->orig_instr;
    }
}