void MotifSearch::full_output(ostream &fout){ fout << "Parameter values:\n"; output_params(fout); fout << "\nInput sequences:\n"; for(unsigned int x = 0; x < nameset.size(); x++) fout << "#" << x << '\t' << nameset[x] << endl; fout << '\n'; archive.write(fout); }
/* fit potential energy parameters via simulated annealing */ int surface_fit(system_t *system) { //override default values if specified in input file double temperature = ((system->fit_start_temp ) ? system->fit_start_temp : TEMPERATURE ); double max_energy = ((system->fit_max_energy ) ? system->fit_max_energy : MAX_ENERGY ); double schedule = ((system->fit_schedule ) ? system->fit_schedule : SCHEDULE ); //used only if qshift is on double quadrupole=0; int i, j, // generic counters nCurves, // number of curves to fit against nPoints, // number of points in each curve nSteps; double *r_input=0; // Master list of r-values curveData_t *curve=0; // Array to hold curve point data param_t *param_ptr; param_g *params; double r_min, r_max, r_inc; double current_error, last_error, global_minimum; qshiftData_t * qshiftData = NULL; //used only with qshift // ee_local variables int a = 0; int globalFound = 0; double oldGlobal = 0; double initEps[2]; double initSig[2]; double globalEps[2]; double globalSig[2]; // Record number of curves for convenient reference nCurves = system->fit_input_list.data.count; // Read the curve data from the input files into a local array curve = readFitInputFiles( system, nCurves ); if(!curve) { error( "SURFACE: An error occurred while reading the surface-fit input files.\n" ); return (-1); } // Record number of points in each curve, for convenient reference nPoints = curve[0].nPoints; // Make a master list of R-values r_input = curve[0].r; curve[0].r = 0; // Free the memory used by all the remaining lists (i.e. all lists // other than the one whose address was just transferred). for( i=1; i<nCurves; i++ ) free(curve[i].r); // Allocate memory for the output and global arrays if ( -1 == alloc_curves ( nCurves, nPoints, curve ) ) { free(r_input); return -1; } // Determine Independent Domain ////////////////////////////////// r_min = r_input[0]; r_max = r_input[nPoints-1]; r_inc = r_input[1] - r_input[0]; // Output the geometry for visual verification output_pqrs ( system, nCurves, curve ); // Get the Initial Error ////////////////////////////////// //obtain curves get_curves ( system, nCurves, curve, r_min, r_max, r_inc ); //calc current error current_error = error_calc ( system, nCurves, nPoints, curve, max_energy); //record parameters. we will determine which ones need to be adjusted later params = record_params ( system ); // print some header info for(param_ptr = params->type_params; param_ptr; param_ptr = param_ptr->next) { printf( "SURFACE: Atom type: %d @ %s\n", param_ptr->ntypes, param_ptr->atomtype ); if(param_ptr->epsilon != 0) { initEps[a] = param_ptr->epsilon; initSig[a] = param_ptr->sigma; a++; } } if ( ! system->fit_boltzmann_weight ) printf("*** any input energy values greater than %f K will not contribute to the fit ***\n", max_energy); //write params and current_error to stdout printf("*** Initial Fit: \n"); output_params ( temperature, current_error, params ); printf("*****************\n"); //set the minimum error we've found global_minimum = current_error; last_error = current_error; for( j=0; j<nCurves; j++ ) for(i = 0; i < nPoints; i++) curve[j].global[i] = curve[j].output[i]; //initialize stuff for qshift if ( system->surf_qshift_on ) { qshiftData = malloc(sizeof(qshiftData_t)); quadrupole = calcquadrupole(system); } // ANNEALING // Loop over temperature. When the temperature reaches MIN_TEMPERATURE // we quit. Assuming we find an error smaller than the initial error // we'll spit out a fit_geometry.pqr file, and you'll want to re-anneal. for(nSteps = 0; temperature > MIN_TEMPERATURE; ++nSteps) { // randomly perturb the parameters surf_perturb ( system, quadrupole, qshiftData, params ); // apply the trial parameters surface_dimer_parameters ( system, params); get_curves ( system, nCurves, curve, r_min, r_max, r_inc ); // calc error current_error = error_calc ( system, nCurves, nPoints, curve, max_energy); int condition = 0; if (system->surf_descent) condition = current_error < last_error; else condition = get_rand() < exp(-(current_error - last_error)/temperature); // DO MC at this 'temperature' if(condition) { //ACCEPT MOVE ///// apply_new_parameters ( params ); last_error = current_error; if(nSteps >= EQUIL) { nSteps = 0; //write params and current_error to stdout output_params ( temperature, current_error, params ); // output the new global minimum if(current_error < global_minimum) { system->fit_best_square_error = global_minimum = current_error; new_global_min ( system, nCurves, nPoints, curve ); // Store the LJ parameters corresponding to global min a = 0; globalFound = 1; oldGlobal = current_error; // keep track for ee_local for(param_ptr = params->type_params; param_ptr; param_ptr = param_ptr->next) { if(param_ptr->epsilon != 0) { globalEps[a] = param_ptr->epsilon; globalSig[a] = param_ptr->sigma; a++; } } } } } else { // MOVE REJECTED //// revert_parameters ( system, params ); } //END DO MONTE CARLO // decrement the temperature temperature = temperature*schedule; // schedule } //END ANNEALING // Output the Fit Curves output_fit ( nCurves, nPoints, curve, max_energy, r_input ); // Exhaustive Enumeration -- Chris Cioce if (system->ee_local) { int b, c, d, nE1, nE2, nS1, nS2; double currEps[2]; double currSig[2]; double newGlobal=0; double E1start, E1stop, E1incr, E2start, E2stop, E2incr, E1c, E2c; // E1, E2 (unused) double S1start, S1stop, S1incr, S2start, S2stop, S2incr, S1c, S2c; // S1, S2 (unused) if(globalFound == 1) { printf("\nEE_LOCAL ~> SA found an improved surface. Using current global minimum parameters for EE.\n"); currEps[0] = globalEps[0]; currEps[1] = globalEps[1]; currSig[0] = globalSig[0]; currSig[1] = globalSig[1]; } else { printf("\nEE_LOCAL ~> SA did not find an improved surface. Using initial parameters for EE.\n"); currEps[0] = initEps[0]; currEps[1] = initEps[1]; currSig[0] = initSig[0]; currSig[1] = initSig[1]; } for(a=0; a<2; a++) { printf("EE_LOCAL ~> InitEps[%d]: %f\tInitSig[%d]: %f\tGlobalEps[%d]: %f\tGlobalSig[%d]: %f\n",a,initEps[a],a,initSig[a],a,globalEps[a],a,globalSig[a]); } E1start = currEps[0] - (currEps[0]*system->range_eps); E1stop = currEps[0] + (currEps[0]*system->range_eps); E1incr = currEps[0] * system->step_eps; E2start = currEps[1] - (currEps[1]*system->range_eps); E2stop = currEps[1] + (currEps[1]*system->range_eps); E2incr = currEps[1] * system->step_eps; S1start = currSig[0] - (currSig[0]*system->range_sig); S1stop = currSig[0] + (currSig[0]*system->range_sig); S1incr = currSig[0] * system->step_sig; S2start = currSig[1] - (currSig[1]*system->range_sig); S2stop = currSig[1] + (currSig[1]*system->range_sig); S2incr = currSig[1] * system->step_sig; nE1 = ((E1stop - E1start) / E1incr) + 1; nE2 = ((E2stop - E2start) / E2incr) + 1; nS1 = ((S1stop - S1start) / S1incr) + 1; nS2 = ((S2stop - S2start) / S2incr) + 1; printf("EE_LOCAL ~> E1start = %f\tE1stop = %f\tE1incr = %f\tnE1 = %d\n",E1start,E1stop,E1incr,nE1); printf("EE_LOCAL ~> E2start = %f\tE2stop = %f\tE2incr = %f\tnE2 = %d\n",E2start,E2stop,E2incr,nE2); printf("EE_LOCAL ~> S1start = %f\tS1stop = %f\tS1incr = %f\tnS1 = %d\n",S1start,S1stop,S1incr,nS1); printf("EE_LOCAL ~> S2start = %f\tS2stop = %f\tS2incr = %f\tnS2 = %d\n",S2start,S2stop,S2incr,nS2); printf("EE_LOCAL ~> Will now perform %d total iterations in parameter subspace...\n",(nE1*nE2*nS1*nS2)); E1c = E1start; E2c = E2start; S1c = S1start; S2c = S2start; // Set initial parameters for(param_ptr = params->type_params; param_ptr; param_ptr = param_ptr->next) { if(param_ptr->epsilon == currEps[0]) { param_ptr->epsilon = E1c; } if(param_ptr->epsilon == currEps[1]) { param_ptr->epsilon = E2c; } if(param_ptr->sigma == currSig[0]) { param_ptr->sigma = S1c; } if(param_ptr->sigma == currSig[1]) { param_ptr->sigma = S2c; } } // apply initial parameters surface_dimer_parameters ( system, params); get_curves ( system, nCurves, curve, r_min, r_max, r_inc ); //calc current error current_error = error_calc ( system, nCurves, nPoints, curve, max_energy); //record parameters. we will determine which ones need to be adjusted later //params = record_params ( system ); //write params and current_error to stdout <-- just for visual verification printf("*** Initial Fit: \n"); output_params ( 0.0, current_error, params ); printf("*****************\n"); // Main loops globalFound = 0; int master = 1; for(a=0; a<=nE1; a++) { for(b=0; b<=nE2; b++) { for(c=0; c<=nS1; c++) { for(d=0; d<=nS2; d++) { //printf("MASTER: %d\ta: %d\t(%f)\tb: %d\t(%f)\tc: %d\t(%f)\td: %d\t(%f)\n", master, a, E1c, b, E2c, c, S1c, d, S2c); // Debug output // apply parameters surface_dimer_parameters ( system, params); get_curves ( system, nCurves, curve, r_min, r_max, r_inc ); // calc current error current_error = error_calc ( system, nCurves, nPoints, curve, max_energy); //output_params ( 0.0, current_error, params ); // Debug output // check for new global minimum if(current_error < global_minimum) { system->fit_best_square_error = global_minimum = current_error; new_global_min ( system, nCurves, nPoints, curve ); // Store the LJ parameters corresponding to global min a = 0; globalFound = 1; newGlobal = current_error; for(param_ptr = params->type_params; param_ptr; param_ptr = param_ptr->next) { if(param_ptr->epsilon != 0) { globalEps[a] = param_ptr->epsilon; globalSig[a] = param_ptr->sigma; a++; } } } // Set updated S2 parameter for(param_ptr = params->type_params; param_ptr; param_ptr = param_ptr->next) { if(param_ptr->sigma == S2c) { param_ptr->sigma = (S2c+S2incr); } } S2c += S2incr; master++; } // END S2 loop // Set updated S1 & S2 parameters for(param_ptr = params->type_params; param_ptr; param_ptr = param_ptr->next) { if(param_ptr->sigma == S1c) { param_ptr->sigma = (S1c+S1incr); } if(param_ptr->sigma == S2c) { param_ptr->sigma = S2start; } } S1c += S1incr; S2c = S2start; } // END S1 loop // Set updated E2 & S1 parameters for(param_ptr = params->type_params; param_ptr; param_ptr = param_ptr->next) { if(param_ptr->epsilon == E2c) { param_ptr->epsilon = (E2c+E2incr); } if(param_ptr->sigma == S1c) { param_ptr->sigma = S1start; } } E2c += E2incr; S1c = S1start; } // END E2 loop // Set updated E1 & E2 parameters for(param_ptr = params->type_params; param_ptr; param_ptr = param_ptr->next) { if(param_ptr->epsilon == E1c) { param_ptr->epsilon = (E1c+E1incr); } if(param_ptr->epsilon == E2c) { param_ptr->epsilon = E2start; } } E1c += E1incr; E2c = E2start; } // END E1 loop // If a new global min is found, write to stdout // TODO: Adjust printf statements to prettify final output :D if(globalFound == 1) { printf("\nEE_LOCAL ~> EE found an improved surface. Parameters written to fit_geometry.pqr\n"); //printf("EE_LOCAL ~> E1: %f\tS1: %f\tE2: %f\tS2: %f\n", globalEps[0], globalSig[0], globalEps[1], globalSig[1]); printf("EE_LOCAL ~> SA Global Min: %f\n", oldGlobal); printf("EE_LOCAL ~> EE Global Min: %f\n", newGlobal); printf(" ----------------------------\n"); printf(" ----------------------------\n"); printf(" ====> %.2f %% improvement\n\n", ((oldGlobal-newGlobal)/oldGlobal)*100); } else { printf("EE_LOCAL ~> EE was unable to find an improved surface versus SA. Oh well, at least you tried...and for that, we thank you!\n\n"); } } // END ee_local // Return all memory back to the system free_all_mem (nCurves, curve, params, qshiftData, r_input); return(0); }
int main(int argc, char *argv[]) { const char *map; int memfd; size_t fbm; const char *ptr, *end; size_t page = get_page_size(); size_t mapbase, maplen; int err = 1; (void)argc; mapbase = memlimit() & ~(page - 1); if (!mapbase) return 2; memfd = open("/dev/mem", O_RDONLY); if (memfd < 0) { fprintf(stderr, "%s: cannot open /dev/mem: %s\n", argv[0], strerror(errno)); return 2; } map = mmap(NULL, page, PROT_READ, MAP_SHARED, memfd, 0); if (map == MAP_FAILED) { fprintf(stderr, "%s: cannot map page 0: %s\n", argv[0], strerror(errno)); return 2; } fbm = *(uint16_t *)(map + 0x413) << 10; if (fbm < mapbase) fbm = mapbase; munmap((void *)map, page); if (fbm < 64*1024 || fbm >= 640*1024) return 1; maplen = 0xa0000 - mapbase; map = mmap(NULL, maplen, PROT_READ, MAP_SHARED, memfd, mapbase); if (map == MAP_FAILED) { fprintf(stderr, "%s: cannot map base memory: %s\n", argv[0], strerror(errno)); return 2; } ptr = map + (fbm - mapbase); end = map + (0xa0000 - mapbase); while (ptr < end) { if (valid_mbft((const struct mBFT *)ptr, end-ptr)) { output_params((const struct mBFT *)ptr); err = 0; break; } ptr += 16; } munmap((void *)map, maplen); return err; }
total_result_type cacti_interface (int cache_size, int line_size, int associativity, int rw_ports, int excl_read_ports, int excl_write_ports, int single_ended_read_ports, int banks, double tech_node, int output_width, int specific_tag, int tag_width, int access_mode, int pure_sram) { int C, B, A, ERP, EWP, RWP, NSER; double tech; double logbanks; double logbanksfloor; int seq_access = 0; int fast_access = 0; int bits_output = output_width; int nr_args = 9; double NSubbanks = (double) banks; double ratioofbankstoports; extern int force_tag, force_tag_size; total_result_type endresult; endresult.result.subbanks = 0.0; result_type result; arearesult_type arearesult; area_type arearesult_subbanked; parameter_type parameters; /* input parameters: C B A ERP EWP */ /*dt: make sure we're using some simple leakage reduction */ dualVt = FALSE; //#ifdef XCACTI //parameters.latchsa = 0; //parameters.ignore_tag = 0; //#endif force_tag = 0; parameters.force_tag = 0; if (specific_tag) { force_tag = 1; force_tag_size = tag_width; parameters.force_tag = 1; parameters.tag_size = tag_width; //parameters.ignore_tag = 1; } switch (access_mode) { case 0: seq_access = fast_access = FALSE; break; case 1: seq_access = TRUE; fast_access = FALSE; break; case 2: seq_access = FALSE; fast_access = TRUE; break; } C = cache_size; A = associativity; B = line_size; if ((B < 1)) { printf ("Block size must >=1\n"); return endresult; //exit(1); } if ((B * 8 < bits_output)) { printf ("Block size must be at least %d\n", bits_output / 8); return endresult; //exit(1); } tech = tech_node; if ((tech <= 0)) { printf ("Feature size must be > 0\n"); return endresult; //exit(1); } if ((tech > 0.8)) { printf ("Feature size must be <= 0.80 (um)\n"); return endresult; //exit(1); } if (nr_args == 6) { RWP = 1; ERP = 0; EWP = 0; NSER = 0; } else if (nr_args == 8) { RWP = 1; ERP = 0; EWP = 0; NSER = 0; bits_output = output_width; seq_access = 1; } else if (nr_args == 9) { RWP = rw_ports; ERP = excl_read_ports; EWP = excl_write_ports; NSER = single_ended_read_ports; } else if (nr_args >= 10) { RWP = rw_ports; ERP = excl_read_ports; EWP = excl_write_ports; NSER = single_ended_read_ports; seq_access = 1; } if ((RWP < 0) || (EWP < 0) || (ERP < 0)) { printf ("Ports must >=0\n"); return endresult; //exit(1); } if (RWP > 2) { printf ("Maximum of 2 read/write ports\n"); return endresult; //exit(1); } if ((RWP + ERP + EWP) < 1) { printf ("Must have at least one port\n"); return endresult; //exit(1); } if (NSubbanks < 1) { printf ("Number of subbanks should be greater than or equal to 1 and should be a power of 2\n"); return endresult; //exit(1); } logbanks = logtwo ((double) (NSubbanks)); logbanksfloor = floor (logbanks); if (logbanks > logbanksfloor) { printf ("Number of subbanks should be greater than or equal to 1 and should be a power of 2\n"); return endresult; //exit(1); } if (C == B * A) { parameters.fully_assoc = 1; A = C / B; } else { parameters.fully_assoc = 0; } C = cache_size / ((int) (NSubbanks)); if ((C < 64)) { printf ("Cache size must >=64\n"); return endresult; //exit(1); } //A = C/B; if (A > 16) { parameters.fully_assoc = 1; A = 16; } /*if ((associativity == 0) || (A == C/B)) { A = C/B; parameters.fully_assoc = 1; } else { if (associativity == 1) { A=1; parameters.fully_assoc = 0; } else { parameters.fully_assoc = 0; A = associativity; if ((A < 1)) { printf("Associativity must >= 1\n"); return endresult; //exit(1); } assoc = logtwo((double)(A)); assocfloor = floor(assoc); if(assoc > assocfloor){ printf("Associativity should be a power of 2\n"); return endresult; //exit(1); } if ((A > 32)) { printf("Associativity must <= 32\n or try FA (fully associative)\n"); return endresult; //exit(1); } } } if (C/(B*A)<=1 && !parameters.fully_assoc) { //printf("Number of sets is too small:\n Need to either increase cache size, or decrease associativity or block size\n (or use fully associative cache)\n"); //return endresult; A = C/B; parameters.fully_assoc = 1; //exit(1); } */ printf ("\n########### Printing input for params for testing...###"); printf ("\n C = %d, B = %d, A = %d", C, B, A); printf ("\n RWP = %d, ERP = %d, EWP = %d, NSER = %d", RWP, ERP, EWP, NSER); printf ("\n banks = %d, tech = %f, bits_output = %d, fast_access = %d, pure_sram = %d", banks, tech, bits_output, fast_access, pure_sram); printf ("\n force_tag = %d, force_tag_size = %d", force_tag, force_tag_size); printf ("\n #################\n"); parameters.cache_size = C; parameters.block_size = B; parameters.nr_bits_out = bits_output; /*dt: testing sequential access mode */ if (seq_access) { parameters.tag_associativity = A; parameters.data_associativity = 1; parameters.sequential_access = 1; } else { parameters.tag_associativity = parameters.data_associativity = A; parameters.sequential_access = 0; } if (fast_access) { parameters.fast_access = 1; } else { parameters.fast_access = 0; } parameters.num_readwrite_ports = RWP; parameters.num_read_ports = ERP; parameters.num_write_ports = EWP; parameters.NSubbanks = banks; parameters.num_single_ended_read_ports = NSER; parameters.number_of_sets = C / (B * A); parameters.fudgefactor = .8 / tech; parameters.tech_size = (double) tech; parameters.pure_sram = pure_sram; //If multiple banks and multiple ports are specified, then if number of banks/total number //of ports > 1 then assume that the multiple ports are implemented via the multiple banks. //Also assume that each bank has only 1 RWP port. There are some problems with this logic that //will be fixed in v5.0 ratioofbankstoports = NSubbanks / (RWP + ERP + EWP); if (ratioofbankstoports >= 1.0) { //We assume that each bank has 1 RWP port. parameters.num_readwrite_ports = 1; parameters.num_read_ports = 0; parameters.num_write_ports = 0; parameters.num_single_ended_read_ports = 0; } if (parameters.number_of_sets < 1) { printf ("Less than one set...\n"); return endresult; //exit(1); } parameters.VddPow = 4.5 / (pow (parameters.fudgefactor, (2.0 / 3.0))); if (parameters.VddPow < 0.7) parameters.VddPow = 0.7; if (parameters.VddPow > 5.0) parameters.VddPow = 5.0; printf ("\n##### Printing parameters for testing...#####\n"); output_params (¶meters); init_tech_params_default_process (); //v4.1: First initialize all tech variables //to 0.8 micron values. init_tech_params function below then reinitializes tech variables to //given process values init_tech_params (parameters.tech_size); calculate_time (&result, &arearesult, &arearesult_subbanked, ¶meters, &NSubbanks); //v4.1: No longer using calculate_area function as area has already been //computed for the given tech node /*arearesult.dataarray_area.scaled_area = calculate_area(arearesult.dataarray_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.datapredecode_area.scaled_area = calculate_area(arearesult.datapredecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.datacolmuxpredecode_area.scaled_area = calculate_area(arearesult.datacolmuxpredecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.datacolmuxpostdecode_area.scaled_area = calculate_area(arearesult.datacolmuxpostdecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.datawritesig_area.scaled_area = (parameters.num_readwrite_ports+parameters.num_read_ports+parameters.num_write_ports)*calculate_area(arearesult.datawritesig_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.tagarray_area.scaled_area = calculate_area(arearesult.tagarray_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.tagpredecode_area.scaled_area = calculate_area(arearesult.tagpredecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.tagcolmuxpredecode_area.scaled_area = calculate_area(arearesult.tagcolmuxpredecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.tagcolmuxpostdecode_area.scaled_area = calculate_area(arearesult.tagcolmuxpostdecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.tagoutdrvdecode_area.scaled_area = calculate_area(arearesult.tagoutdrvdecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.tagoutdrvsig_area.scaled_area = (parameters.num_readwrite_ports+parameters.num_read_ports+parameters.num_write_ports)* calculate_area(arearesult.tagoutdrvsig_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; arearesult.perc_data = 100*area_all_dataramcells/(arearesult.totalarea*CONVERT_TO_MMSQUARE); arearesult.perc_tag = 100*area_all_tagramcells/(arearesult.totalarea*CONVERT_TO_MMSQUARE); arearesult.perc_cont = 100*(arearesult.totalarea*CONVERT_TO_MMSQUARE-area_all_dataramcells-area_all_tagramcells)/(arearesult.totalarea*CONVERT_TO_MMSQUARE); arearesult.sub_eff = (area_all_dataramcells+area_all_tagramcells)*100/(arearesult.totalarea/100000000.0); arearesult.total_eff = (NSubbanks)*(area_all_dataramcells+area_all_tagramcells)*100/ (calculate_area(arearesult_subbanked,parameters.fudgefactor)*CONVERT_TO_MMSQUARE); arearesult.totalarea *= CONVERT_TO_MMSQUARE; arearesult.subbankarea = calculate_area(arearesult_subbanked,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; */ arearesult.dataarray_area.scaled_area = arearesult.dataarray_area.height * arearesult.dataarray_area.width * CONVERT_TO_MMSQUARE; arearesult.datapredecode_area.scaled_area = arearesult.datapredecode_area.height * arearesult.datapredecode_area.width * CONVERT_TO_MMSQUARE; arearesult.datacolmuxpredecode_area.scaled_area = arearesult.datacolmuxpredecode_area.height * arearesult.datacolmuxpredecode_area.width * CONVERT_TO_MMSQUARE; arearesult.datacolmuxpostdecode_area.scaled_area = arearesult.datacolmuxpostdecode_area.height * arearesult.datacolmuxpostdecode_area.width * CONVERT_TO_MMSQUARE; arearesult.datawritesig_area.scaled_area = (parameters.num_readwrite_ports + parameters.num_read_ports + parameters.num_write_ports) * arearesult.datawritesig_area.height * arearesult.datawritesig_area.width * CONVERT_TO_MMSQUARE; arearesult.tagarray_area.scaled_area = arearesult.tagarray_area.height * arearesult.tagarray_area.width * CONVERT_TO_MMSQUARE; arearesult.tagpredecode_area.scaled_area = arearesult.tagpredecode_area.height * arearesult.tagpredecode_area.width * CONVERT_TO_MMSQUARE; arearesult.tagcolmuxpredecode_area.scaled_area = arearesult.tagcolmuxpredecode_area.height * arearesult.tagcolmuxpredecode_area.width * CONVERT_TO_MMSQUARE; arearesult.tagcolmuxpostdecode_area.scaled_area = arearesult.tagcolmuxpostdecode_area.height * arearesult.tagcolmuxpostdecode_area.width * CONVERT_TO_MMSQUARE; arearesult.tagoutdrvdecode_area.scaled_area = arearesult.tagoutdrvdecode_area.height * arearesult.tagoutdrvdecode_area.width * CONVERT_TO_MMSQUARE; arearesult.tagoutdrvsig_area.scaled_area = (parameters.num_readwrite_ports + parameters.num_read_ports + parameters.num_write_ports) * arearesult.tagoutdrvsig_area.height * arearesult.tagoutdrvsig_area.width * CONVERT_TO_MMSQUARE; arearesult.perc_data = 100 * area_all_dataramcells / (arearesult.totalarea * CONVERT_TO_MMSQUARE); arearesult.perc_tag = 100 * area_all_tagramcells / (arearesult.totalarea * CONVERT_TO_MMSQUARE); arearesult.perc_cont = 100 * (arearesult.totalarea * CONVERT_TO_MMSQUARE - area_all_dataramcells - area_all_tagramcells) / (arearesult.totalarea * CONVERT_TO_MMSQUARE); arearesult.sub_eff = (area_all_dataramcells + area_all_tagramcells) * 100 / (arearesult.totalarea / 100000000.0); arearesult.total_eff = (NSubbanks) * (area_all_dataramcells + area_all_tagramcells) * 100 / (arearesult_subbanked.height * arearesult_subbanked.width * CONVERT_TO_MMSQUARE); arearesult.totalarea *= CONVERT_TO_MMSQUARE; arearesult.subbankarea = arearesult_subbanked.height * arearesult_subbanked.width * CONVERT_TO_MMSQUARE; if (result.bitline_delay_data < 0.0) { result.bitline_delay_data = 10 ^ -12; } if (result.bitline_delay_tag < 0.0) { result.bitline_delay_tag = 10 ^ -13; } endresult.result = result; endresult.result.subbanks = banks; endresult.area = arearesult; endresult.params = parameters; return endresult; }
BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node) { const LLPanel::Params& default_params(LLUICtrlFactory::getDefaultParams<LLPanel>()); Params params(default_params); { LLFastTimer timer(FTM_PANEL_SETUP); LLXMLNodePtr referenced_xml; std::string xml_filename = mXMLFilename; // if the panel didn't provide a filename, check the node if (xml_filename.empty()) { node->getAttributeString("filename", xml_filename); setXMLFilename(xml_filename); } if (!xml_filename.empty()) { LLUICtrlFactory::instance().pushFileName(xml_filename); LLFastTimer timer(FTM_EXTERNAL_PANEL_LOAD); if (output_node) { //if we are exporting, we want to export the current xml //not the referenced xml LLXUIParser::instance().readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName()); Params output_params(params); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); LLXUIParser::instance().writeXUI( output_node, output_params, &default_params); return TRUE; } if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml)) { llwarns << "Couldn't parse panel from: " << xml_filename << llendl; return FALSE; } LLXUIParser::instance().readXUI(referenced_xml, params, LLUICtrlFactory::getInstance()->getCurFileName()); // add children using dimensions from referenced xml for consistent layout setShape(params.rect); LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance()); LLUICtrlFactory::instance().popFileName(); } // ask LLUICtrlFactory for filename, since xml_filename might be empty LLXUIParser::instance().readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName()); if (output_node) { Params output_params(params); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); LLXUIParser::instance().writeXUI( output_node, output_params, &default_params); } params.from_xui = true; applyXUILayout(params, parent); { LLFastTimer timer(FTM_PANEL_CONSTRUCTION); initFromParams(params); } // add children LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node); // Connect to parent after children are built, because tab containers // do a reshape() on their child panels, which requires that the children // be built/added. JC if (parent) { S32 tab_group = params.tab_group.isProvided() ? params.tab_group() : parent->getLastTabGroup(); parent->addChild(this, tab_group); } { LLFastTimer timer(FTM_PANEL_POSTBUILD); postBuild(); } } return TRUE; }
/* * Save current graphics and colors to the 'savefile' as a Tcl script. * Input: savefile - filename to save to. * Return: 0 for success, * VIS5D_BAD_VALUE if unable to open file * VIS5D_FAIL if error while writing file. */ int tcl_save( int index, const char *savefile ) { FILE *f; int cyo, chowmany, cwhichones[VIS5D_MAX_CONTEXTS]; int var, i, k; int numvars; float r, g, b, a; char varname[20]; vis5d_get_num_of_ctxs_in_display( index, &chowmany, cwhichones); f = fopen(savefile,"w"); if (!f) { return VIS5D_BAD_VALUE; } /* Prolog */ fprintf(f,"#Vis5D 4.3 Tcl save file\n\n"); for ( cyo = 0; cyo < chowmany; cyo++){ int vindex = cwhichones[cyo]; vis5d_get_ctx_numvars( cwhichones[cyo], &numvars ); /* misc colors */ fprintf(f,"\n#Box color\n"); vis5d_get_color( index, VIS5D_BOX, 0, &r, &g, &b, &a ); fprintf(f,"vis5d_set_color $dtx VIS5D_BOX 0 %15.7g %15.7g %15.7g %15.7g\n", r,g,b,a ); fprintf(f,"\n#Light map color\n"); vis5d_get_color( index, VIS5D_LIGHT_MAP, 0, &r, &g, &b, &a ); fprintf(f,"vis5d_set_color $dtx VIS5D_LIGHT_MAP 0 %15.7g %15.7g %15.7g %15.7g\n", r,g,b,a ); fprintf(f,"\n#Dark map color\n"); vis5d_get_color( index, VIS5D_DARK_MAP, 0, &r, &g, &b, &a ); fprintf(f,"vis5d_set_color $dtx VIS5D_DARK_MAP 0 %15.7g %15.7g %15.7g %15.7g\n", r,g,b,a ); fprintf(f,"\n#Background color\n"); vis5d_get_color( index, VIS5D_BACKGROUND, 0, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_BACKGROUND 0 %15.7g %15.7g %15.7g %15.7g\n", r,g,b,a ); /* Text labels */ fprintf(f,"\n#Text labels\n"); { int i = 1; int x, y; char label[1000]; while (vis5d_get_label( index, i, &x, &y, label )==0) { fprintf(f,"vis5d_make_label $dtx %d %d \"%s\"\n", x, y, label ); i++; } } /* View matrix */ fprintf(f,"\n#Viewing matrix\n"); { float mat[4][4]; int i, j; vis5d_get_matrix( index, mat ); fprintf(f,"vis5d_set_matrix $dtx {"); for (i=0;i<4;i++) { for (j=0;j<4;j++) { fprintf(f," %g", mat[i][j] ); } } fprintf(f," }\n"); } /* Camera */ fprintf(f,"\n#Camera\n"); { int perspec; float front, zoom; vis5d_get_camera( index, &perspec, &front, &zoom ); fprintf(f,"vis5d_set_camera $dtx %d %g %g\n", perspec, front, zoom ); } /* Cloned and computed physical variables */ fprintf(f,"\n#Cloned or computed variables\n"); for (var=0; var<numvars; var++) { int type; vis5d_get_var_type( cwhichones[cyo], var, &type ); if (type==VIS5D_CLONE) { int vartoclone; char origname[20], clonename[20]; vis5d_get_ctx_var_name( cwhichones[cyo], var, origname ); vis5d_get_var_info( cwhichones[cyo], var, (void*) &vartoclone ); vis5d_get_ctx_var_name( cwhichones[cyo], vartoclone, clonename ); if (cyo == 0) { fprintf(f,"vis5d_make_clone_variable $ctx \"%s\" \"%s\"\n", origname, clonename ); } else { fprintf(f,"vis5d_make_clone_variable %d \"%s\" \"%s\"\n", cwhichones[cyo], origname, clonename ); } } else if (type==VIS5D_EXT_FUNC) { char funcname[100]; vis5d_get_var_info( cwhichones[cyo], var, (void*) funcname ); fprintf(f,"vis5d_compute_ext_func $dtx \"%s\"\n", funcname ); } else if (type==VIS5D_EXPRESSION) { char expr[100]; vis5d_get_var_info( cwhichones[cyo], var, (void*) expr ); fprintf(f,"vis5d_make_expr_var $dtx \"%s\"\n", expr ); } } /* Isosurfaces */ fprintf(f,"\n#Isosurfaces\n"); for (var=0; var<numvars; var++) { float isolevel, min, max; int colorvarowner, colorvar; vis5d_get_isosurface( cwhichones[cyo], var, &isolevel ); vis5d_get_ctx_var_range( cwhichones[cyo], var, &min, &max ); vis5d_get_isosurface_color_var( cwhichones[cyo], var, &colorvarowner, &colorvar ); vis5d_get_ctx_var_name( cwhichones[cyo], var, varname ); if (isolevel!=min) { if (cyo == 0) { fprintf(f,"vis5d_set_isosurface $ctx \"%s\" %g\n", varname, isolevel); } else { fprintf(f,"vis5d_set_isosurface %d \"%s\" %g\n", cwhichones[cyo], varname, isolevel); } if (colorvar>-1) { char colorvarname[20]; vis5d_get_ctx_var_name( colorvarowner, colorvar, colorvarname ); if (cyo == 0) { fprintf(f,"vis5d_set_isosurface_color_var_and_owner $ctx \"%s\" %d \"%s\"\n", varname, colorvarowner, colorvarname ); } else { fprintf(f,"vis5d_set_isosurface_color_var_and_owner %d \"%s\" %d \"%s\"\n", cwhichones[cyo], varname, colorvarowner, colorvarname ); } } /* command to recompute the isosurface */ if (cyo == 0) { fprintf(f,"vis5d_make_isosurface $ctx VIS5D_ALL_TIMES \"%s\" 0\n", varname ); } else { fprintf(f,"vis5d_make_isosurface %d VIS5D_ALL_TIMES \"%s\" 0\n", cwhichones[cyo], varname ); } } if (vis5d_enable_graphics(cwhichones[cyo],VIS5D_ISOSURF,var,VIS5D_GET)){ if (cyo == 0) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_ISOSURF %d VIS5D_ON\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_ISOSURF %d VIS5D_ON\n", cwhichones[cyo], var); } } /* WLH 10 Nov 98 */ else { if (cyo == 0) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_ISOSURF %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_ISOSURF %d VIS5D_OFF\n", cwhichones[cyo], var); } } } /* Horizontal contour slices */ fprintf(f,"\n#Horizontal contour slices\n"); for (var=0;var<numvars;var++) { float interval, low, high, level; vis5d_get_hslice( vindex, var, &interval, &low, &high, &level ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_hslice $ctx \"%s\" %g %g %g %g\n", varname, interval, low, high, level ); } else { fprintf(f,"vis5d_set_hslice %d \"%s\" %g %g %g %g\n",vindex, varname, interval, low, high, level ); } if (vis5d_enable_graphics(vindex, VIS5D_HSLICE, var, VIS5D_GET)){ if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HSLICE %d VIS5D_ON\n", var); fprintf(f,"vis5d_make_hslice $ctx VIS5D_ALL_TIMES %d 1\n", var ); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_HSLICE %d VIS5D_ON\n", vindex, var); fprintf(f,"vis5d_make_hslice %d VIS5D_ALL_TIMES %d 1\n", vindex, var ); } } /* WLH 10 Nov 98 */ else { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HSLICE %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_HSLICE %d VIS5D_OFF\n", vindex, var); } } /* MJK 12.04.98 begin */ if (vis5d_enable_sfc_graphics (index, VIS5D_HSLICE, var, VIS5D_GET)== VIS5D_ON){ if (vindex == cwhichones[0]) { /* MJK 3.29.99 fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSLICE %s VIS5D_ON\n",var); */ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSLICE %d VIS5D_ON\n",var); } } else{ if (vindex == cwhichones[0]) { /* MJK 3.29.99 fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSLICE %s VIS5D_OFF\n",var); */ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSLICE %d VIS5D_OFF\n",var); } } /* MJK 12.04.98 end */ } /* Vertical contour slices */ fprintf(f,"\n#Vertical contour slices\n"); for (var=0;var<numvars;var++) { float interval, low, high, r0, c0, r1, c1; vis5d_get_vslice( vindex, var, &interval, &low, &high, &r0,&c0, &r1,&c1 ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_vslice $ctx \"%s\" %g %g %g %g %g %g %g\n", varname, interval, low, high, r0,c0, r1,c1 ); } else { fprintf(f,"vis5d_set_vslice %d \"%s\" %g %g %g %g %g %g %g\n", vindex, varname, interval, low, high, r0,c0, r1,c1 ); } if (vis5d_enable_graphics(vindex, VIS5D_VSLICE, var, VIS5D_GET)){ if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VSLICE %d VIS5D_ON\n", var); fprintf(f,"vis5d_make_vslice $ctx VIS5D_ALL_TIMES %d 1\n", var ); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_VSLICE %d VIS5D_ON\n", vindex, var); fprintf(f,"vis5d_make_vslice %d VIS5D_ALL_TIMES %d 1\n", vindex, var ); } } /* WLH 10 Nov 98 */ else { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VSLICE %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_VSLICE %d VIS5D_OFF\n", vindex, var); } } } /* Horizontal colored slices */ fprintf(f,"\n#Horizontal colored slices\n"); for (var=0;var<numvars;var++) { float level; vis5d_get_chslice( vindex, var, &level ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_chslice $ctx \"%s\" %g\n", varname, level ); } else { fprintf(f,"vis5d_set_chslice %d \"%s\" %g\n",vindex, varname, level ); } if (vis5d_enable_graphics(vindex, VIS5D_CHSLICE, var, VIS5D_GET)){ if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_CHSLICE %d VIS5D_ON\n", var); fprintf(f,"vis5d_make_chslice $ctx VIS5D_ALL_TIMES %d 1\n", var ); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_CHSLICE %d VIS5D_ON\n", vindex, var); fprintf(f,"vis5d_make_chslice %d VIS5D_ALL_TIMES %d 1\n", vindex, var ); } } /* WLH 10 Nov 98 */ else { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_CHSLICE %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_CHSLICE %d VIS5D_OFF\n", vindex, var); } } } /* Vertical colored slices */ fprintf(f,"\n#Vertical colored slices\n"); for (var=0;var<numvars;var++) { float r0, c0, r1, c1; vis5d_get_cvslice( vindex, var, &r0, &c0, &r1, &c1 ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_cvslice $ctx \"%s\" %g %g %g %g\n", varname, r0, c0, r1, c1 ); } else { fprintf(f,"vis5d_set_cvslice %d \"%s\" %g %g %g %g\n",vindex, varname, r0, c0, r1, c1 ); } if (vis5d_enable_graphics(vindex, VIS5D_CVSLICE, var, VIS5D_GET)){ if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_CVSLICE %d VIS5D_ON\n", var); fprintf(f,"vis5d_make_cvslice $ctx VIS5D_ALL_TIMES %d 1\n", var ); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_CVSLICE %d VIS5D_ON\n", vindex, var); fprintf(f,"vis5d_make_cvslice %d VIS5D_ALL_TIMES %d 1\n", vindex, var ); } } /* WLH 10 Nov 98 */ else { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_CVSLICE %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_CVSLICE %d VIS5D_OFF\n", vindex, var); } } } /* Current Display Volume */ fprintf(f, "\n#Current Display Volume\n"); { int current_vol_owner, current_vol; vis5d_get_volume(index, ¤t_vol_owner, ¤t_vol); // JCM: Anywhere vis5d_get_volume() is called, have to introduce extra code to deal with more than one volume if (current_vol_owner > -1){ vis5d_printtcl_volume(f, index, current_vol_owner, current_vol, cwhichones[0]); // JCM } else{ fprintf(f,"vis5d_set_volume_and_owner $dtx -1 -1\n"); } } /* Horizontal wind vector slices */ fprintf(f,"\n#Horizontal wind vector slices\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { float density, scale, level; vis5d_get_hwindslice( index, i, &density, &scale, &level ); fprintf(f,"vis5d_set_hwindslice $dtx %d %g %g %g\n", i, density, scale, level ); if (vis5d_enable_graphics(cwhichones[0], VIS5D_HWIND, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HWIND %d VIS5D_ON\n", i); fprintf(f,"vis5d_make_hwindslice $dtx VIS5D_ALL_TIMES %d 1\n", i); } /* WLH 10 Nov 98 */ else { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HWIND %d VIS5D_OFF\n", i); } /* MJK 12.04.98 begin */ if (vis5d_enable_sfc_graphics (vindex, VIS5D_HWIND, i, VIS5D_GET)== VIS5D_ON){ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HWIND %d VIS5D_ON\n",i); } else{ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HWIND %d VIS5D_OFF\n",i); } /* MJK 12.04.98 end */ } /* Vertical wind vector slices */ fprintf(f,"\n#Vertical wind vector slices\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { float density, scale, r0, c0, r1, c1; vis5d_get_vwindslice( index, i, &density, &scale, &r0, &c0, &r1, &c1 ); fprintf(f,"vis5d_set_vwindslice $dtx %d %g %g %g %g %g %g\n", i, density, scale, r0, c0, r1, c1 ); if (vis5d_enable_graphics(cwhichones[0], VIS5D_VWIND, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VWIND %d VIS5D_ON\n", i); fprintf(f,"vis5d_make_vwindslice $dtx VIS5D_ALL_TIMES %d 1\n", i); } /* WLH 10 Nov 98 */ else { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VWIND %d VIS5D_OFF\n", i); } } /* Horizontal wind stream slices */ fprintf(f,"\n#Horizontal stream slices\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { float density, level; vis5d_get_hstreamslice( index, i, &density, &level ); fprintf(f,"vis5d_set_hstreamslice $dtx %d %g %g\n", i, density, level ); if (vis5d_enable_graphics(cwhichones[0], VIS5D_HSTREAM, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HSTREAM %d VIS5D_ON\n", i); fprintf(f,"vis5d_make_hstreamslice $dtx VIS5D_ALL_TIMES %d 1\n", i); } /* WLH 10 Nov 98 */ else { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HSTREAM %d VIS5D_OFF\n", i); } /* MJK 12.04.98 begin */ if (vis5d_enable_sfc_graphics (vindex, VIS5D_HSTREAM, i, VIS5D_GET)== VIS5D_ON){ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HWIND %d VIS5D_ON\n",i); } else{ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSTREAM %d VIS5D_OFF\n",i); } /* MJK 12.04.98 end */ } /* Vertical wind stream slices */ fprintf(f,"\n#Vertical stream slices\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { float density, r0, c0, r1, c1; vis5d_get_vstreamslice( index, i, &density, &r0, &c0, &r1, &c1 ); fprintf(f,"vis5d_set_vstreamslice $dtx %d %g %g %g %g %g\n", i, density, r0, c0, r1, c1 ); if (vis5d_enable_graphics(cwhichones[0], VIS5D_VSTREAM, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VSTREAM %d VIS5D_ON\n", i); fprintf(f,"vis5d_make_vstreamslice $dtx VIS5D_ALL_TIMES %d 1\n", i); } /* WLH 10 Nov 98 */ else { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VSTREAM %d VIS5D_OFF\n", i); } } /* Trajectories */ fprintf(f,"\n#Trajectories\n"); { float prevstep = 0.0, prevlength = 0.0; int prevribbon = 0; int numtraj = vis5d_get_num_traj( index ); for (i=0;i<numtraj;i++) { float row, col, lev, step, length; int timestep, group, ribbon; vis5d_get_traj_info( index, i, &row, &col, &lev, ×tep, &step, &length, &group, &ribbon ); if (i==0 || step!=prevstep || length!=prevlength || ribbon!=prevribbon) { fprintf(f,"vis5d_set_traj $dtx %g %g %d\n", step, length, ribbon ); } prevstep = step; prevlength = length; prevribbon = ribbon; fprintf(f,"vis5d_make_traj $dtx %g %g %g %d %d\n", row, col, lev, timestep, group ); } for (i=0; i<VIS5D_TRAJ_SETS; i++){ if (vis5d_enable_graphics(cwhichones[0], VIS5D_TRAJ, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_TRAJ %d VIS5D_ON\n", i); } } } /* Isosurface colors */ fprintf(f,"\n#Isosurface colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_ISOSURF, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_ISOSURF $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_ISOSURF %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* HSlice colors */ fprintf(f,"\n#Horizontal contour slice colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_HSLICE, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_HSLICE $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_HSLICE %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* VSlice colors */ fprintf(f,"\n#Vertical contour slice colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_VSLICE, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_VSLICE $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_VSLICE %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* Colored HSlice colors */ fprintf(f,"\n#Horizontal colored slice tickmark colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_CHSLICE, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_CHSLICE $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_CHSLICE %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* Colored VSlice colors */ fprintf(f,"\n#Vertical colored slice tickmark colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_CVSLICE, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_CVSLICE $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_CVSLICE %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* HWind colors */ fprintf(f,"\n#Horizontal wind slice colors\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { vis5d_get_color( index, VIS5D_HWIND, i, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_HWIND %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); } /* VWind colors */ fprintf(f,"\n#Vertical wind slice colors\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { vis5d_get_color( index, VIS5D_VWIND, i, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_VWIND %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); } /* Horizontal Stream colors */ fprintf(f,"\n#Horizontal stream slice colors\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { vis5d_get_color( index, VIS5D_HSTREAM, i, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_HSTREAM %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); } /* Vertical Stream colors */ fprintf(f,"\n#Vertical stream slice colors\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { vis5d_get_color( index, VIS5D_VSTREAM, i, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_VSTREAM %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); } /* Trajectory colors */ fprintf(f,"\n#Trajectory colors\n"); for (i=0;i<VIS5D_TRAJ_SETS;i++) { int colorvarowner, colorvar; vis5d_get_color( index, VIS5D_TRAJ, i, &r, &g, &b, &a ); fprintf(f,"vis5d_set_color $dtx VIS5D_TRAJ %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); vis5d_get_trajectory_color_var( index, i, &colorvarowner, &colorvar ); if (colorvar>=0) { char varname[20]; vis5d_get_ctx_var_name( colorvarowner, colorvar, varname ); fprintf(f,"vis5d_set_trajectory_color_var_and_owner $dtx %d %d \"%s\"\n", i, colorvarowner, varname ); } } /* TO HERE */ /* Isosurface color tables */ fprintf(f,"\n#Isosurface color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; char varname[20]; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_ISOSURF, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_ISOSURF $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_ISOSURF %d", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_ISOSURF, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_ISOSURF $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_ISOSURF %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* Horizontal color slice color tables */ fprintf(f,"\n#Horizontal color slice color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; char varname[20]; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_CHSLICE, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_CHSLICE $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_CHSLICE %d ", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_CHSLICE, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_CHSLICE $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_CHSLICE %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* Vertical color slice color tables */ fprintf(f,"\n#Vertical color slice color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; char varname[20]; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_CVSLICE, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_CVSLICE $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_CVSLICE %d", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_CVSLICE, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_CVSLICE $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_CVSLICE %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* Volume color tables */ fprintf(f,"\n#Volume color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; char varname[20]; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_VOLUME, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_VOLUME $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_VOLUME %d", vindex); } // fprintf(stderr,"%g\n",params[ALPHAVAL]); // DEBUG output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_VOLUME, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_VOLUME $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_VOLUME %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* Trajectory color tables */ fprintf(f,"\n#Trajectory color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_TRAJ, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_TRAJ $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_TRAJ %d", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_TRAJ, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_TRAJ $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_TRAJ %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* MJK 12.04.98 begin */ /* if (vis5d_enable_sfc_map (index, VIS5D_GET) == VIS5D_ON){ fprintf (f,"vis5d_enable_sfc_map $dtx VIS5D_ON\n"); } else{ fprintf (f,"vis5d_enable_sfc_map $dtx VIS5D_OFF\n"); } */ /* MJK 12.04.98 end */ /* Topography color tables */ fprintf(f,"\n#Topography color tables\n"); for (var=-1;var<numvars;var++) { unsigned int *ctable; float params[NUMCOLORTABLEPARAMS]; if (var>=0) { vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_TOPO, vindex, var, params ); } else { int j; for (j=0; j<NUMCOLORTABLEPARAMS; j++) params[j] = 0; strcpy( varname, "-1" ); k = 1; } if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_TOPO $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_TOPO %d", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_TOPO, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_TOPO $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_TOPO %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } } { int colorvar, colorvarowner; vis5d_get_topo_color_var( index, &colorvarowner, &colorvar ); fprintf(f, "\n"); fprintf(f, "vis5d_set_topo_color_var_and_owner $dtx %d %d\n", colorvarowner, colorvar ); } /* MJK 12.04.98 begin */ /* TODO */ /* if (vis5d_graphics_mode (index, VIS5D_BOX, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_BOX VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_CLOCK, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_CLOCK VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_MAP, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_MAP VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_TOPO, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_TOPO VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_LEGENDS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_LEGENDS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_PERSPECTIVE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_PERSPECTIVE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_CONTOUR_NUMBERS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_CONTOUR_NUMBERS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_GRID_COORDS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_GRID_COORDS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_PRETTY, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_PRETTY VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_INFO, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_INFO VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_PROBE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_PROBE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SOUND, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SOUND VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_CURSOR, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_CURSOR VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_ANIMRECORD, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_ANIMRECORD VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_TEXTURE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_TEXTURE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_DEPTHCUE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_DEPTHCUE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_JULIAN, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_JULIAN VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_BARBS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_BARBS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_THTA, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_THTA VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_THTE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_THTE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_W, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_W VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_TICKS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_TICKS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_MIXRAT, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_MIXRAT VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_TEMP, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_TEMP VIS5D_ON\n"); */ fprintf(f, "\nvis5d_draw_frame %d\n", index ); fclose(f); return 0; }
void output_right(enum tof type, struct process *proc, struct library_symbol *libsym, struct timedelta *spent) { assert(! options.summary); struct prototype *func = lookup_symbol_prototype(proc, libsym); if (func == NULL) return; if (current_proc != NULL && (current_proc != proc || current_depth != proc->callstack_depth)) { fprintf(options.output, " <unfinished ...>\n"); current_proc = NULL; } if (current_proc != proc) { begin_of_line(proc, type == LT_TOF_FUNCTIONR, 1); #ifdef USE_DEMANGLE current_column += fprintf(options.output, "<... %s resumed> ", options.demangle ? my_demangle(libsym->name) : libsym->name); #else current_column += fprintf(options.output, "<... %s resumed> ", libsym->name); #endif } struct callstack_element *stel = &proc->callstack[proc->callstack_depth - 1]; struct fetch_context *context = stel->fetch_context; /* Fetch & enter into dictionary the retval first, so that * other values can use it in expressions. */ struct value retval; bool own_retval = false; if (context != NULL) { value_init(&retval, proc, NULL, func->return_info, 0); own_retval = true; if (fetch_retval(context, type, proc, func->return_info, &retval) < 0) value_set_type(&retval, NULL, 0); else if (stel->arguments != NULL && val_dict_push_named(stel->arguments, &retval, "retval", 0) == 0) own_retval = false; } if (stel->arguments != NULL) output_params(stel->arguments, stel->out.params_left, val_dict_count(stel->arguments), &stel->out.need_delim); current_column += fprintf(options.output, ") "); tabto(options.align - 1); fprintf(options.output, "= "); if (context != NULL && retval.type != NULL) { struct format_argument_data data = { &retval, stel->arguments }; format_argument_cb(options.output, &data); } if (own_retval) value_destroy(&retval); if (opt_T) { assert(spent != NULL); fprintf(options.output, " <%lu.%06d>", (unsigned long) spent->tm.tv_sec, (int) spent->tm.tv_usec); } fprintf(options.output, "\n"); #if defined(HAVE_LIBUNWIND) if (options.bt_depth > 0 && proc->unwind_priv != NULL && proc->unwind_as != NULL) { unw_cursor_t cursor; arch_addr_t ip, function_offset; struct library *lib = NULL; int unwind_depth = options.bt_depth; char fn_name[100]; const char *lib_name; size_t distance; /* Verify that we can safely cast arch_addr_t* to * unw_word_t*. */ (void)sizeof(char[1 - 2*(sizeof(unw_word_t) != sizeof(arch_addr_t))]); unw_init_remote(&cursor, proc->unwind_as, proc->unwind_priv); while (unwind_depth) { int rc = unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip); if (rc < 0) { fprintf(options.output, " > Error: %s\n", unw_strerror(rc)); goto cont; } /* We are looking for the library with the base address * closest to the current ip. */ lib_name = "unmapped_area"; distance = (size_t) -1; lib = proc->libraries; while (lib != NULL) { /* N.B.: Assumes sizeof(size_t) == * sizeof(arch_addr_t). * Keyword: double cast. */ if ((ip >= lib->base) && ((size_t)(ip - lib->base) < distance)) { distance = ip - lib->base; lib_name = lib->pathname; } lib = lib->next; } rc = unw_get_proc_name(&cursor, fn_name, sizeof(fn_name), (unw_word_t *) &function_offset); if (rc == 0 || rc == -UNW_ENOMEM) fprintf(options.output, " > %s(%s+%p) [%p]\n", lib_name, fn_name, function_offset, ip); else fprintf(options.output, " > %s(??\?) [%p]\n", lib_name, ip); cont: if (unw_step(&cursor) <= 0) break; unwind_depth--; } fprintf(options.output, "\n"); } #endif /* defined(HAVE_LIBUNWIND) */ #if defined(HAVE_LIBDW) if (options.bt_depth > 0 && proc->leader->dwfl != NULL) { int frames = options.bt_depth; if (dwfl_getthread_frames(proc->leader->dwfl, proc->pid, frame_callback, &frames) < 0) { // Only print an error if we couldn't show anything. // Otherwise just show there might be more... if (frames == options.bt_depth) fprintf(stderr, "dwfl_getthread_frames tid %d: %s\n", proc->pid, dwfl_errmsg(-1)); else fprintf(options.output, " > [...]\n"); } fprintf(options.output, "\n"); } #endif /* defined(HAVE_LIBDW) */ current_proc = NULL; current_column = 0; }
void output_left(enum tof type, struct process *proc, struct library_symbol *libsym) { assert(! options.summary); if (current_proc) { fprintf(options.output, " <unfinished ...>\n"); current_column = 0; } current_proc = proc; current_depth = proc->callstack_depth; begin_of_line(proc, type == LT_TOF_FUNCTION, 1); if (!options.hide_caller && libsym->lib != NULL && libsym->plt_type != LS_TOPLT_NONE) /* We don't terribly mind failing this. */ account_output(¤t_column, fprintf(options.output, "%s->", libsym->lib->soname)); const char *name = libsym->name; #ifdef USE_DEMANGLE if (options.demangle) name = my_demangle(libsym->name); #endif if (account_output(¤t_column, fprintf(options.output, "%s", name)) < 0) return; if (libsym->lib != NULL && libsym->lib->type != LT_LIBTYPE_MAIN && libsym->plt_type == LS_TOPLT_NONE && account_output(¤t_column, fprintf(options.output, "@%s", libsym->lib->soname)) < 0) /* We do mind failing this though. */ return; account_output(¤t_column, fprintf(options.output, "(")); struct prototype *func = lookup_symbol_prototype(proc, libsym); if (func == NULL) { fail: account_output(¤t_column, fprintf(options.output, "???")); return; } struct fetch_context *context = fetch_arg_init(type, proc, func->return_info); if (context == NULL) goto fail; struct value_dict *arguments = malloc(sizeof(*arguments)); if (arguments == NULL) { fetch_arg_done(context); goto fail; } val_dict_init(arguments); ssize_t params_left = -1; int need_delim = 0; if (fetch_params(type, proc, context, arguments, func, ¶ms_left) < 0 || output_params(arguments, 0, params_left, &need_delim) < 0) { val_dict_destroy(arguments); fetch_arg_done(context); arguments = NULL; context = NULL; } struct callstack_element *stel = &proc->callstack[proc->callstack_depth - 1]; stel->fetch_context = context; stel->arguments = arguments; stel->out.params_left = params_left; stel->out.need_delim = need_delim; }