void lbann_callback_dump_minibatch_sample_indices::on_evaluate_forward_prop_end(model *m, Layer *l) {
  switch(m->get_execution_mode()) {
  case execution_mode::validation:
    dump_to_file(m, l, m->get_cur_validation_step());
    break;
  case execution_mode::testing:
    dump_to_file(m, l, m->get_cur_testing_step());
    break;
  default:
    throw lbann_exception("lbann_callback_dump_minibatch_sample_indices: invalid execution phase");
  }
}
예제 #2
0
파일: file.c 프로젝트: Wyrick/RetroArch
bool save_state(const char *path)
{
   RARCH_LOG("Saving state: \"%s\".\n", path);
   size_t size = pretro_serialize_size();
   if (size == 0)
      return false;

   void *data = malloc(size);
   if (!data)
   {
      RARCH_ERR("Failed to allocate memory for save state buffer.\n");
      return false;
   }

   RARCH_LOG("State size: %d bytes.\n", (int)size);
   bool ret = pretro_serialize(data, size);
   if (ret)
      ret = dump_to_file(path, data, size);

   if (!ret)
      RARCH_ERR("Failed to save state to \"%s\".\n", path);

   free(data);
   return ret;
}
예제 #3
0
파일: file.c 프로젝트: Wyrick/RetroArch
// Attempt to save valuable RAM data somewhere ...
static void dump_to_file_desperate(const void *data, size_t size, int type)
{
#if defined(_WIN32) && !defined(_XBOX)
   const char *base = getenv("APPDATA");
#elif defined(__CELLOS_LV2__) || defined(_XBOX)
   const char *base = NULL;
#else
   const char *base = getenv("HOME");
#endif

   if (!base)
      goto error;

   char path[PATH_MAX];
   snprintf(path, sizeof(path), "%s/SSNES-recovery-", base);
   char timebuf[PATH_MAX];

   time_t time_;
   time(&time_);
   strftime(timebuf, sizeof(timebuf), "%Y-%m-%d-%H-%M-%S", localtime(&time_));
   strlcat(path, timebuf, sizeof(path));
   strlcat(path, ramtype2str(type), sizeof(path));

   if (dump_to_file(path, data, size))
      RARCH_WARN("Succeeded in saving RAM data to \"%s\". Phew ... :D\n", path);
   else
      goto error;

   return;

error:
   RARCH_WARN("Failed ... Tough luck ... :(\n");
}
예제 #4
0
static int trav_hook_user(user_info_t *ui, void *p)
{
	char buff[128];
	trav_priv_t *ptrav = p;

	snprintf(buff, sizeof(buff), "%u.%u.%u.%u", NIPQUAD(ui->ip));
	return dump_to_file(ptrav->fp, buff, ui->hdr.recv_bytes, ui->hdr.xmit_bytes);
}
예제 #5
0
void count(mpz_t states,int argc, char **argv, int lanes[NLANES][L], int filaments, int noconsts)
{
	
	int i,j;
	//int temp[500];
	int** constraints;
	Value *test;
	char* total;
	unsigned NbRows, NbColumns;
    Value cb;
    Polyhedron *A;
    Matrix *M;
    struct barvinok_options *options = barvinok_options_new_with_defaults();
	NbRows=0;
    argc = barvinok_options_parse(options, argc, argv, ISL_ARG_ALL);
    //printf("length 1st lane: %d\n", lanes[0][1]);
    
	constraints= malloc(noconsts*sizeof(int *));
	//printf("%lu\n",(filaments+2)*(noconsts));
	for (i=0;i<noconsts;i++){
		constraints[i]=(int*)malloc(sizeof(int)*(filaments+2));
		for(j=0;j<filaments+2;j++){
			constraints[i][j]=0;
			//printf("%d %d %d\n",i,j,constraints[i][j]);
		}
	}
	//printf("from count: fils %d noconsts %d\n",filaments,noconsts);
    gen_constraints(constraints,lanes,filaments,noconsts);
    dump_to_file(constraints,filaments,noconsts);

	
	value_init(cb);
	total=malloc(sizeof(char)*500);
	get_popen_data(total);
    //A = Constraints2Polyhedron(M, options->MaxRays);
   
    
    //value_print(stdout, P_VALUE_FMT, cb);
    mpz_set_str(cb,total,10);
    free(total);
    //printf("%s\n%d\n",total,strlen(total));	
	//gmp_printf("%Zd\n",states);
    //printf("%d\n",tot_int);
    if (options->print_stats)
	barvinok_stats_print(options->stats, stdout);
    value_clear(cb);
    //value_clear(test);
   
    barvinok_options_free(options);
    for (i=0;i<noconsts;i++){
		free(constraints[i]);
	}
	free(constraints);
    
    
   
}
예제 #6
0
static int trav_hook_flow(flow_info_t *fi, void *p)
{
	char buff[128];
	trav_priv_t *ptrav = p;

	snprintf(buff, sizeof(buff), "%u.%u.%u.%u:%u-%u.%u.%u.%u:%u-%u",
		NIPQUAD(fi->tuple.ip_src), ntohs(fi->tuple.port_src),
		NIPQUAD(fi->tuple.ip_dst), ntohs(fi->tuple.port_dst), fi->tuple.proto);
	return dump_to_file(ptrav->fp, buff, fi->hdr.recv_bytes, fi->hdr.xmit_bytes);
}
예제 #7
0
void RTProfiler::record(event_id_t event_id, int event_value){
  RecordItem<int> ri;
  ri.time_stamp = HighResolutionTimer::current_time();
  ri.event_id = event_id;
  ri.event_value = event_value;

  m_oIntItems.push_back(ri);

  if(m_oIntItems.size() >= 1024)
    dump_to_file();
}
예제 #8
0
파일: file.c 프로젝트: Wyrick/RetroArch
void save_ram_file(const char *path, int type)
{
   size_t size = pretro_get_memory_size(type);
   void *data = pretro_get_memory_data(type);

   if (data && size > 0)
   {
      if (!dump_to_file(path, data, size))
      {
         RARCH_ERR("Failed to save SRAM.\n");
         RARCH_WARN("Attempting to recover ...\n");
         dump_to_file_desperate(data, size, type);
      }
   }
}
예제 #9
0
파일: main.c 프로젝트: w4kfu/Stunts
int main(int argc, char **argv)
{
        int fd;
        struct stat st;
        unsigned char *buf = NULL;
	struct conf_c conf = {0};
	struct s_comp comp = {0};

	parse_opt(argc, argv, &conf);
	check_opt(&conf, argv[0]);
        fd = open(conf.in, O_RDONLY);
        if (fd == -1)
        {
                perror("open()");
                exit(EXIT_FAILURE);
        }
        if (fstat(fd, &st) == -1)
        {
                perror("fstat()");
                exit(EXIT_FAILURE);
        }
        if ((buf = malloc(sizeof (char) * st.st_size)) == NULL)
        {
                perror("malloc()");
                exit(EXIT_FAILURE);
        }
        if (read(fd, buf, st.st_size) != st.st_size)
        {
                perror("read()");
                goto clean;
        }
	huff(buf, st.st_size, &comp);
	if (comp.tree)
	{
		if (conf.dot)
			dotty(comp.tree, conf.dot);
		uncomp(&comp, buf + st.st_size);
		if (comp.buf_out)
			dump_to_file(conf.out, comp.buf_out, comp.size);
	}
clean:
        free(buf);
        close(fd);
        return 0;
}
예제 #10
0
TYPE 
main()
{
  STORAGE_CLASS TYPE input_data[2*N_FFT]; 
  int j;
  pin_down(&input_data[0]) ; 

  main16_inpsca(&input_data[0]);
  
  for(j=0;j<(2*N_FFT);j++)
	printf("input_data[%d]: %d\n",j,input_data[j]);
  
#ifdef __DEBUG__
  dump_to_file(&input_data[0]);
#endif

  return (0) ; 
  
}
예제 #11
0
파일: jconf.c 프로젝트: darcyg/twittrouter
void dump_jconf(char *conf_path){
    char* jsonlist[6];
    extern jconf_t *conf;
    //jsonlist[0] = concatstring(packstring("TwitterID", "\""), ":" ,packstring(conf->whitelist, "\""));
    jsonlist[0] = build_json_item("TwitterID",conf->TwitterID);
    jsonlist[1] = build_json_item("CONSUMER_KEY",conf->CONSUMER_KEY);
    jsonlist[2] = build_json_item("CONSUMER_SECRET",conf->CONSUMER_SECRET);
    jsonlist[3] = build_json_item("OAUTH_TOKEN",conf->OAUTH_TOKEN);
    jsonlist[4] = build_json_item("OAUTH_TOKEN_SECRET",conf->OAUTH_TOKEN_SECRET);
    jsonlist[5] = build_json_item("whitelist",conf->whitelist);
    
    int j;
    int stringlen = 0;
    for(j = 0; j < 6; j++) {
        stringlen += strlen(jsonlist[j]);
    }
    int total_len = stringlen + 5 * 4 + 1;
    char *all_item = (char *)malloc(total_len);
    memset(all_item,0, total_len);
    
    for(j = 0; j < 5; j++) {
        strcat(all_item,jsonlist[j]);
        strcat(all_item,",\r\n\t");
    }
    strcat(all_item,jsonlist[5]);
    
    for(j = 0; j < 6; j++) {
        if (jsonlist[j]) free(jsonlist[j]);
    }
    
    char *final_string = (char *)malloc(total_len + 4 + 3 + 1);
    memset(final_string, 0, total_len + 4 + 3 + 1);
    strcat(final_string, "{\r\n\t");
    strcat(final_string, all_item);
    strcat(final_string, "\r\n}");
    
    if(all_item) free(all_item);
    printf("\n%s\n", final_string);
    dump_to_file(final_string, strlen(final_string), conf_path);
    if(final_string) free(final_string);
}
예제 #12
0
static void enum_maps (HANDLE process)
{
	static SYSTEM_INFO sysinfo;
	MEMORY_BASIC_INFORMATION meminfo;
	unsigned int nextbase;

	GetSystemInfo(&sysinfo);

	nextbase = (unsigned int)sysinfo.lpMinimumApplicationAddress;
	while (nextbase < (unsigned int)sysinfo.lpMaximumApplicationAddress) {
		if (VirtualQueryEx(process, (void *)nextbase, &meminfo, sizeof(meminfo)) != sizeof(meminfo)) {
			printf("error: VirtualQueryEx failed.\n");
			break;
		}

		if (meminfo.State == MEM_COMMIT && meminfo.RegionSize > 0)
			dump_to_file(process, meminfo.Protect, meminfo.BaseAddress, meminfo.RegionSize);

		nextbase = (unsigned int)meminfo.BaseAddress + (unsigned int)meminfo.RegionSize;
		if (nextbase < (unsigned int)meminfo.BaseAddress) // overflow
			break;
	}
}
예제 #13
0
 virtual void start(int i) { dump_to_file(i); }
예제 #14
0
파일: dump.c 프로젝트: andreaaraldo/mytstat
void dump_ip(void *pip, void *plast) {
    if (dump_engine && proto2dump[DUMP_IP_COMPLETE].enabled)
        dump_to_file(&proto2dump[DUMP_IP_COMPLETE], pip, plast);
}
예제 #15
0
파일: dump.c 프로젝트: andreaaraldo/mytstat
void dump_flow_stat (struct ip *pip, 
                     void *pproto, 
                     int tproto, 
                     void *pdir,
	                 int dir, 
                     void *hdr, 
                     void *plast) 
{
    int ucb_type;

    if (!dump_engine)
        return;

    if (threaded)
        pthread_mutex_lock(&dump_mutex);

    /***** TCP packets *****/
    if (tproto == PROTOCOL_TCP)
    /* It's TCP, there is still a flow associated to this, and we are not already discarding it */
     {
       struct stcp_pair *p = ((tcb *)pdir)->ptp;

       if (proto2dump[DUMP_TCP_COMPLETE].enabled && (p != NULL) && !(p->stop_dumping_tcp) ) 
         {
            /* are we still interested in this flow packets? */
            if ( ( p->con_type != UNKNOWN_PROTOCOL )  /* we always log unknowns */
                  &&
                 ( (p->con_type & stop_dumping_mask) != 0 ) /* after masking, we are not interested into it */
               )
             {
               p->stop_dumping_tcp = TRUE;
               if (debug>0)
                {
                  fprintf(fp_stderr, "Stopping dumping this flow - con_type = %d\n",p->con_type);
                }
             }
                
            if (!(p->stop_dumping_tcp))
             { 
               /* do we have to dump all the packets of all the flows */
               if (tcp_maxbytes == 0 && tcp_maxpackets == 0)
                {
                  dump_to_file(&proto2dump[DUMP_TCP_COMPLETE], pip, plast);
	            }
	            /* or we have to stop dumping acks and data packets up to reach 
                 * - tcp_maxbytes 
                 * - tcp_maxpackets 
                 */
               else
                {
                  struct tcphdr *ptcp = pproto;
                  /* check if the underlying flow struct tcb has not yet been released */
                  if ( p != NULL)
                   {
                     int tcp_data_length = getpayloadlength (pip, plast) - (4 * ptcp->th_off);

                     tcb *thisdir = (tcb*)pdir;
                     tcb *otherdir = (dir == C2S) ? &(thisdir->ptp->s2c) : &(thisdir->ptp->c2s);

                     if ((
                        /* packets with payload */
                        tcp_data_length > 0 && 
                            /* check the thresholds */
                            ((tcp_maxbytes > 0   && thisdir->seq - thisdir->syn - tcp_data_length <= tcp_maxbytes) || 
                             (tcp_maxpackets > 0 && thisdir->data_pkts <= tcp_maxpackets))
                        ) || (
                        /* this is a pure ack */
                        tcp_data_length == 0 && 
                            (otherdir->seq <= thisdir->ack && /* which is a valid ack */
                              ( /* and we are still interested in otherdir packets */
                                (tcp_maxbytes > 0 && otherdir->seq - otherdir->syn <= tcp_maxbytes) ||
                                (tcp_maxpackets > 0 && otherdir->data_pkts <= tcp_maxpackets) ||
                                (otherdir->fin_count >= 1 && thisdir->ack >= (otherdir->fin_seqno+1))
                            ))
                        ) ||
                        SYN_SET (ptcp) || 
                        FIN_SET(ptcp)
                       ) 
                        {
                            dump_to_file(&proto2dump[DUMP_TCP_COMPLETE], pip, plast);
                        }
                       
                    }
                   else
                    {
                      if (RESET_SET(ptcp))
                       {
                         dump_to_file(&proto2dump[DUMP_TCP_COMPLETE], pip, plast);
                       }
                    }
                 }
            } /* end !stop_dumping_tcp */
        } /* end DUMP_TCP_COMPLETE */

#ifdef STREAMING_CLASSIFIER
        if (proto2dump[DUMP_TCP_VIDEOSTREAMING].enabled && ((tcb*)pdir)->ptp != NULL)
         {
            struct stcp_pair *p = ((tcb *)pdir)->ptp;
            if (p->streaming.video_content_type || p->streaming.video_payload_type)
             {
               dump_to_file(&proto2dump[DUMP_TCP_VIDEOSTREAMING], pip, plast);
             }
         }
#endif
     }
    
    /***** UDP packets *****/
    else 
     {
        ucb *mydir = (ucb*)pdir;

        //specific controls to find kad obfuscated...
        ucb_type = UDP_p2p_to_logtype(mydir);

        /* dump to a specific DPI file */
        if (proto2dump[P2P_UTP].enabled)
         {
            /* 
               Since uTP classification is behavioral, we dump both already classified datagrams,
               and datagrams which are not classified, but that are already in a valid state of 
               the identification state machine.
            */
            if ( ucb_type == P2P_UTP || 
                 ucb_type == P2P_UTPBT ||
                 ( (ucb_type==UDP_UNKNOWN || ucb_type==FIRST_RTP || ucb_type==FIRST_RTCP || ucb_type==P2P_BT) &&
                   (mydir->uTP_state > UTP_UNKNOWN )
                 )
               )
             dump_to_file(&proto2dump[P2P_UTP], pip, plast);
         }
    	else if (proto2dump[ucb_type].enabled) 
    	 {
            dump_to_file(&proto2dump[ucb_type], pip, plast);
         }
        // dump to unknown
        // else if (proto2dump[UDP_UNKNOWN].enabled) {
        //    dump_to_file(&proto2dump[UDP_UNKNOWN], pip, plast);
        // }

        if (proto2dump[DUMP_UDP_COMPLETE].enabled) {
            /* dump all the packets of all the flows */
            if (udp_maxpackets == 0 && udp_maxbytes == 0) {
	            dump_to_file(&proto2dump[DUMP_UDP_COMPLETE], pip, plast);
            }
            else {
                /* check if the underlying flow struct ucb has not yet been released */
                if (((ucb*)pdir)->pup != NULL)
                {
                   ucb *thisdir = (ucb*)pdir;
                   /* dump acks and data packets up to reach 
                    * - udp_maxbytes 
                    * - udp_maxpackets 
                    */
                   if ( (thisdir->data_bytes <= udp_maxbytes) || 
                        (thisdir->packets <= udp_maxpackets)) 
                    {
                        dump_to_file(&proto2dump[DUMP_UDP_COMPLETE], pip, plast);
                    }
                }
                else /* it shouldn't happen, but in case dump the packet in any case */
                    dump_to_file(&proto2dump[DUMP_UDP_COMPLETE], pip, plast);
          }
        }
    }

    if (threaded)
        pthread_mutex_unlock(&dump_mutex);
}
예제 #16
0
파일: tddp.c 프로젝트: dasuxullebt/tddp
int main (int argc, char* argv[]) {
    chksum_db_path = argv[2];
    block_db_path = argv[3];
    if (strcmp(argv[1], "create") == 0) {
        init_block_db();
        int fd = open(CHKSUM_DB_PATH, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
        if (fd < 0) {
            fprintf(stderr, "Error in main: open chksumdb returned %d. Exiting.\n",
                    fd);
            _exit(-1);
        }
        return 0;
    } else if (strcmp(argv[1], "addtape") == 0) {
        init_block_db();
        char* tapepath = argv[4];
        char* ctapepath = argv[5];
        int cdb = open(chksum_db_path, O_LARGEFILE | O_RDWR);
        if (cdb < 0) {
            fprintf(stderr, "Could not checksum-db. %d.\n", cdb);
            _exit(-1);
        }
        load_from_file(cdb);
        int tape = open(tapepath, O_LARGEFILE | O_RDONLY);
        if (tape < 0) {
            perror("Error opening tape.");
            fprintf(stderr, "Could not open tape %s. %d.\n", tapepath, tape);
            _exit(-1);
        }
        int ctape = open(ctapepath, O_LARGEFILE | O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
        if (ctape < 0) {
            fprintf(stderr, "Could not open ctape. %d.\n", ctape);
            _exit(-1);
        }
        /* WE DO NOT YET SUPPORT FILELENGTHS NOT MULTIPLE 512 */
        int k, c;
        char buf[BLOCKSIZE];
beginread:
        for (k = 0; k < BLOCKSIZE;) {
            k += (c = read(tape, buf + k, BLOCKSIZE - k));
            if (c == 0) {
                dump_to_file(cdb);
                fprintf(stderr, "EOF of tape. Anything should be fine. Exiting.");
                return 0;
            } else if (c<0) {
                fprintf(stderr, "Error reading tape. %d\n", tape);
                _exit(-1);
            }
        }
        offset_n_chksum myblk = add_block(buf);
        for (k = 0; k < sizeof(off64_t);) {
            k += (c = write(ctape, &(myblk.offset) + k, sizeof(off64_t) - k));
            if (c < 0) {
                fprintf(stderr, "Could not write ctape: %d\n", c);
                _exit(-1);
            }
        }
        goto beginread;
    } else if (strcmp(argv[1], "restoretape") == 0) {
        /* restoring only to stdout */
        char* ctapepath = argv[4];
        int ctape = open(ctapepath, O_LARGEFILE | O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR);
        if (ctape < 0) {
            fprintf(stderr, "Could not open ctape %s. %d.\n", ctapepath, ctape);
            _exit(-1);
        }
        init_block_db();

        off64_t wr;
        char blockread[BLOCKSIZE];
        while (read(ctape, &wr, sizeof(off64_t)) > 0) {
            lseek64 (blockdb_fd, wr, SEEK_SET);
            read(blockdb_fd, blockread, BLOCKSIZE);
            write(1, blockread, BLOCKSIZE);
        }
    }
}
예제 #17
0
int main(int argc, char * argv[]){
    
    if(geteuid() != 0){
        fprintf(stderr, "This program requires root.\n");
        exit(1);
    }
    
    flags f = {0};
    f.heap_tree_height = 8;

    int opt;
    while((opt = getopt(argc, argv, "p:ti:d:hv")) != -1){
        switch(opt){
            case 'p':
                f.process = (pid_t) atoi(optarg);
                break;
            case 't':
                f.build_heap_tree = 1;
                break;
            case 'i':
                f.heap_tree_height = (size_t) atoi(optarg);
                break;
            case 'd':
                f.dump_file_name = optarg;
                break;
            case 'h':
                print_help();
                exit(0);
                break;
            case 'v':
                f.verbose = 1;
                break;
            default:
                print_help();
                exit(0);

        }
    }
    
    if(optind == 1){
        print_help();
        exit(0);
    }

    if(f.process == 0){
        puts("Missing option -p (process ID)");
        exit(1);
    }
    

    //get maps and mem files from /proc
    char * proc_map_path;
    char * proc_mem_path;
    asprintf(&proc_map_path, "/proc/%d/maps", f.process);
    asprintf(&proc_mem_path, "/proc/%d/mem" , f.process); 
    FILE * proc_map_file = fopen(proc_map_path, "r");
    FILE * proc_mem_file = fopen(proc_mem_path, "r");
   
    
    //hash tree section 
    if(f.build_heap_tree == 1){
        char * proc_map_heap_line;
        
        hash_tree_node * first_hash_tree  = NULL;
        hash_tree_node * second_hash_tree = NULL;
        proc_map_heap_info heap_info_first  ={0};
        proc_map_heap_info heap_info_second ={0};
        uint8_t * first_chunk = NULL;
        uint8_t * second_chunk = NULL;

        //take the first snapshot of the process
        stop_and_wait(f.process);
            fflush(proc_map_file);
            proc_map_heap_line = proc_map_find_heap(proc_map_file);
            parse_proc_map_heap(proc_map_heap_line, &heap_info_first);
            first_chunk = load_heap_from_file(proc_mem_file, heap_info_first.start_address, heap_info_first.size);
            
            printf("%sSnapshot 1:%s\n", RED, NO_COLOR);
            print_heap_info(&heap_info_first);
            
            //unless we close the files we will get old data (there's probably a better solution to this)
            fclose(proc_mem_file);
            fclose(proc_map_file);
            free(proc_map_heap_line);
            proc_map_heap_line = NULL;
        countinue_stopped_process(f.process);
        
        //prompt user for second snapshot
        printf("\n%sPress enter to take second snapshot.%s\n", GREEN, NO_COLOR);
        getchar();

        //take the second snapshot of the process
        proc_map_file = fopen(proc_map_path, "r");
        proc_mem_file = fopen(proc_mem_path, "r");
        stop_and_wait(f.process);
            proc_map_heap_line = proc_map_find_heap(proc_map_file);
            parse_proc_map_heap(proc_map_heap_line, &heap_info_second);
            second_chunk = load_heap_from_file(proc_mem_file,heap_info_second.start_address, heap_info_second.size);

            printf("%sSnapshot 2:%s\n", RED, NO_COLOR);
            print_heap_info(&heap_info_second);
            
            free(proc_map_heap_line);
            proc_map_heap_line = NULL;
        countinue_stopped_process(f.process);       
        
        //If the first snapshot used less memory than the first resize the first chunk
        //so our hashing algorythem still works. The else if probably won't happen.
        if(heap_info_second.size > heap_info_first.size){
            heap_info_first.size = heap_info_second.size;
            first_chunk = realloc(first_chunk, heap_info_second.size);
        }
        else if(heap_info_second.size < heap_info_first.size){
            heap_info_second.size = heap_info_first.size;
            second_chunk = realloc(second_chunk, heap_info_first.size);
        }
        
        //generate the hash_trees
        first_hash_tree = generate_hash_tree(first_chunk, 
                                             heap_info_first.size, 
                                             0,
                                             f.heap_tree_height);
        free(first_chunk);
        first_chunk = NULL;

        second_hash_tree = generate_hash_tree(second_chunk, 
                                              heap_info_second.size, 
                                              0,
                                              f.heap_tree_height);
        free(second_chunk);
        second_chunk = NULL;
        
        
        int same_tree =  diff_hash_tree(first_hash_tree, second_hash_tree);

        //handle verbose hash printing
        if(f.verbose){
            printf("\n%sFIRST%s\n", YELLOW, NO_COLOR);
            print_hash_tree(first_hash_tree,0);
            
            printf("\n%sSECOND%s\n", YELLOW, NO_COLOR);
            print_hash_tree(second_hash_tree,0);

            //diff the hash trees and print the solution
            if(same_tree!=1){            
                printf("\n%sDIFF%s\n", YELLOW, NO_COLOR);
                print_hash_tree(second_hash_tree, 0);
            }else{
                second_hash_tree = NULL;
                puts("SAME TREE!!!");
            }
        }

        //start visualization
        draw_heap_visualization(second_hash_tree, heap_info_second.size, f.heap_tree_height);

    }        
    
    //dump a single heap snapshot to a file
    if(f.dump_file_name != NULL){ 
        proc_map_heap_info heap_info = {0};
        char * proc_map_heap_line = proc_map_find_heap(proc_map_file);
        parse_proc_map_heap(proc_map_heap_line, &heap_info);
        
        FILE * heap_dump_file = fopen(f.dump_file_name, "w");
        stop_and_wait(f.process);
        dump_to_file(proc_mem_file, heap_dump_file, &heap_info);
        countinue_stopped_process(f.process);     
    }

    return 0;
}
예제 #18
0
 RTProfiler::~RTProfiler(){
   dump_to_file();
 }
예제 #19
0
void process_normal_keys(unsigned char key, int x, int y)
{
    ssize_t xHmL;
    double frac[] = {0.01, 0.10, 0.20, 0.50};

    xHmL = xH - xL + 1;
    
    switch(key) {
    case 27:
		exit(0);
        break;
    case ' ':
        dump_to_file(dumpFileName);
        break;
    case '-':
        xL--;
        if(xL < 0) xL = 0;
        break;        
    case '[':
        xL -= frac[0]*xHmL;
        if(xL < 0) xL = 0;
        break;
    case ';':
        xL -= frac[1]*xHmL;
        if(xL < 0) xL = 0;
        break;
    case '=':
        xL++;
        if(xL > xH) xL = xH;
        break;
    case ']':
        xL += frac[0]*xHmL;
        if(xL > xH) xL = xH;
        break;
    case '\'':
        xL += frac[1]*xHmL;
        if(xL > xH) xL = xH;
        break;
    case '_':
        xH--;
        if(xH < xL) xH = xL;
        break;        
    case '{':
        xH -= frac[0]*xHmL;
        if(xH < xL) xH = xL;
        break;
    case ':':
        xH -= frac[1]*xHmL;
        if(xH < xL) xH = xL;
        break;
    case '+':
        xH++;
        if(xH >= wavFile->nPt)
            xH = wavFile->nPt - 1;
        break;
    case '}':
        xH += frac[0]*xHmL;
        if(xH >= wavFile->nPt)
            xH = wavFile->nPt - 1;
        break;
    case '\"':
        xH += frac[1]*xHmL;
        if(xH >= wavFile->nPt)
            xH = wavFile->nPt - 1;
        break;        
    default:
        break;
    }
    printf("xL = %zd, xH = %zd\n", xL, xH);
    glutPostRedisplay();
}
예제 #20
0
파일: exifwriter.c 프로젝트: plageran/ruth
void writeExif( void *origData, void *destData , int origSize , uint32_t *resultSize, int orientation,camera_position_type  *pt, int wb, int ledm ) {
  const char *filename = "/cache/tmp/temp.jpg";

    dump_to_file( filename, (uint8_t *)origData, origSize );
    LOGV("WRITE EXIF Filename %s", filename);
    chmod( filename, S_IRWXU );
    ResetJpgfile();


    memset(&ImageInfo, 0, sizeof(ImageInfo));
    ImageInfo.MeteringMode = -1;

    int gpsTag = 0;
    if( pt != NULL ) {
        LOGV("EXIF ADD GPS DATA ........");
        gpsTag = 6;
    } else{
        LOGV("EXIF NO GPS ........");
    }


    ExifElement_t *t = (ExifElement_t *)malloc( sizeof(ExifElement_t)*(EXIF_TOTAL_DATA+gpsTag) );

    ExifElement_t *it = t;
    // Store file date/time.
    (*it).Tag = TAG_ORIENTATION;
    (*it).Format = FMT_USHORT;
    (*it).DataLength = 1;
    unsigned short v;
    LOGV("EXIF Orientation %d", orientation);
    if( orientation == 90 ) {
        (*it).Value = "6\0";
    } else if( orientation == 180 ) {
        (*it).Value = "3\0";
    } else {
        (*it).Value = "1\0";
    }
    (*it).GpsTag = FALSE;

    it++;

    (*it).Tag = TAG_MAKE;
    (*it).Format = FMT_STRING;
    (*it).Value = "Motorola\0";
    (*it).DataLength = strlen((*it).Value);
    (*it).GpsTag = FALSE;

    it++;

    (*it).Tag = TAG_MODEL;
    (*it).Format = FMT_STRING;
    (*it).Value = "MB200 with CyanogenMOD\0";
    (*it).DataLength = strlen((*it).Value);
    (*it).GpsTag = FALSE;

    it++;

    (*it).Tag = TAG_FLASH;
    (*it).Format = FMT_USHORT;
    (*it).Value = (ledm ? "1\0" : "0\0");
    (*it).DataLength = 1;
    (*it).GpsTag = FALSE;

    it++;

    (*it).Tag = TAG_WHITEBALANCE;
    (*it).Format = FMT_USHORT;
    (*it).Value = (wb ? "1\0" : "0\0");
    (*it).DataLength = 1;
    (*it).GpsTag = FALSE;

    if( pt != NULL ) {
        LOGV("pt->latitude == %f", pt->latitude );
        LOGV("pt->longitude == %f", pt->longitude );
        LOGV("pt->altitude == %d", pt->altitude );

        it++;
        (*it).Tag = 0x01;
        (*it).Format = FMT_STRING;
        if( pt->latitude > 0 ) {
            (*it).Value = "N\0";
        } else {
            (*it).Value = "S\0";
        }
        (*it).DataLength = 2;
        (*it).GpsTag = TRUE;

        it++;
        (*it).Value = coord2degminsec( pt->latitude );
        LOGV("writeExif: latitude is: %s", (*it).Value);

        (*it).Tag = 0x02;
        (*it).Format = FMT_URATIONAL;
        (*it).DataLength = 3;
        (*it).GpsTag = TRUE;

        it++;
        (*it).Tag = 0x03;
        (*it).Format = FMT_STRING;
        if( (*pt).longitude > 0 ) {
            (*it).Value = "E\0";
        } else {
            (*it).Value = "W\0";
        }
        (*it).DataLength = 2;
        (*it).GpsTag = TRUE;

        it++;
        (*it).Value = coord2degminsec( pt->longitude );
        LOGV("writeExif: longitude is: %s", (*it).Value);

        (*it).Tag = 0x04;
        (*it).Format = FMT_URATIONAL;
        (*it).DataLength = 3;
        (*it).GpsTag = TRUE;

        it++;
        (*it).Tag = 0x05;
        (*it).Format = FMT_USHORT;
        if( (*pt).altitude > 0 ) {
            (*it).Value = "0\0";
        } else {
            (*it).Value = "1\0";
        }
        (*it).DataLength = 1;
        (*it).GpsTag = TRUE;

        it++;
        (*it).Value = float2rationnal( fabs( pt->altitude ) );
        LOGV("writeExif: altitude is: %s", (*it).Value);

        (*it).Tag = 0x06;
        (*it).Format = FMT_SRATIONAL;
        (*it).DataLength = 1;
        (*it).GpsTag = TRUE;
    }

   {
        struct stat st;
        if (stat(filename, &st) >= 0) {
            ImageInfo.FileDateTime = st.st_mtime;
            ImageInfo.FileSize = st.st_size;
        }
    }
    strncpy(ImageInfo.FileName, filename, PATH_MAX);
    LOGV("Image EXIF Filename %s", filename);

    ReadMode_t ReadMode;
    ReadMode = READ_METADATA;
    ReadMode |= READ_IMAGE;
    int res = ReadJpegFile(filename, (ReadMode_t)ReadMode );
    LOGV("READ EXIF Filename %s", filename);

    create_EXIF( t, EXIF_TOTAL_DATA, gpsTag);

    WriteJpegFile(filename);
    chmod( filename, S_IRWXU );
    DiscardData();

    FILE *src;
    src = fopen( filename, "r");

    fseek( src, 0L, SEEK_END );
    (*resultSize) = ftell(src);
    fseek( src, 0L, SEEK_SET );

    int read = fread( destData, 1, (*resultSize), src );

    free( t );

    unlink( filename );
}
void lbann_callback_dump_minibatch_sample_indices::on_forward_prop_end(model *m, Layer *l) {
  dump_to_file(m, l, m->get_cur_step());
}