Beispiel #1
0
void xml_formatter::output(ostream & out)
{
	xml_support->build_subclasses(out);

	xml_support->output_program_structure(out);
	output_symbol_data(out);
	if (need_details) {
		out << open_element(DETAIL_TABLE);
		for (size_t i = 0; i < symbol_details.size(); ++i) {
			int id = symbol_details[i].id;

			if (id >= 0) {
				out << open_element(SYMBOL_DETAILS, true);
				out << init_attr(TABLE_ID, (size_t)id);
				out << close_element(NONE, true);
				out << symbol_details[i].details;
				out << close_element(SYMBOL_DETAILS);
			}
		}
		out << close_element(DETAIL_TABLE);

		// output bytesTable
		out << open_element(BYTES_TABLE);
		out << bytes_out.str();
		out << close_element(BYTES_TABLE);
	}

	out << close_element(PROFILE);
}
Beispiel #2
0
static rc_t open_Passes_src( const KDirectory *hdf5_dir, Passes_src *tab,
                             const char * path, bool cache_content )
{
    rc_t rc;

    init_Passes_src( tab );

    rc = open_element( hdf5_dir, &tab->AdapterHitBefore, path, "AdapterHitBefore",
                  ADAPTER_HIT_BEFORE_BITSIZE, ADAPTER_HIT_BEFORE_COLS, 
                  true, cache_content, false );
    if ( rc == 0 )
        rc = open_element( hdf5_dir, &tab->AdapterHitAfter, path, "AdapterHitAfter",
                  ADAPTER_HIT_AFTER_BITSIZE, ADAPTER_HIT_AFTER_COLS,
                  true, cache_content, false );
    if ( rc == 0 )    
        rc = open_element( hdf5_dir, &tab->PassDirection, path, "PassDirection",
                  PASS_DIRECTION_BITSIZE, PASS_DIRECTION_COLS,
                  true, cache_content, false );
    if ( rc == 0 )    
        rc = open_element( hdf5_dir, &tab->PassNumBases, path, "PassNumBases",
                  PASS_NUM_BASES_BITSIZE, PASS_NUM_BASES_COLS,
                  true, cache_content, false );
    if ( rc == 0 )
        rc = open_element( hdf5_dir, &tab->PassStartBase, path, "PassStartBase",
                  PASS_START_BASE_BITSIZE, PASS_START_BASE_COLS,
                  true, cache_content, false );
    if ( rc != 0 )
        close_Passes_src( tab );
    return rc;
}
Beispiel #3
0
void xml_cg_formatter::
output_symbol_core(ostream & out, cg_symbol::children const cg_symb,
       string const selfname, string const qname,
       size_t lo, size_t hi, bool is_module, tag_t tag)
{
	cg_symbol::children::const_iterator cit;
	cg_symbol::children::const_iterator cend = cg_symb.end();

	for (cit = cg_symb.begin(); cit != cend; ++cit) {
		string const & module = get_image_name((cit)->image_name,
			image_name_storage::int_filename, extra_found_images);
		bool self = false;
		ostringstream str;
		size_t indx;

		// output symbol's summary data for each profile class
		for (size_t p = lo; p <= hi; ++p)
			xml_support->output_summary_data(str, cit->sample.counts, p);

		if (cverb << vxml)
			out << "<!-- symbol_ref=" << symbol_names.name(cit->name) <<
				" -->" << endl;

		if (is_module) {
			out << open_element(MODULE, true);
			out << init_attr(NAME, module) << close_element(NONE, true);
		}

		out << open_element(SYMBOL, true);

		string const symname = symbol_names.name(cit->name);
		assert(symname.size() > 0);

		string const symqname = module + ":" + symname;

		// Find any self references and handle
		if ((symname == selfname) && (tag == CALLEES)) {
			self = true;
			indx = xml_get_symbol_index(qname);
		} else {
			indx = xml_get_symbol_index(symqname);
		}

		out << init_attr(ID_REF, indx);

		if (self)
			out << init_attr(SELFREF, "true");

		out << close_element(NONE, true);
		out << str.str();
		out << close_element(SYMBOL);

		if (is_module)
			out << close_element(MODULE);
	}
}
Beispiel #4
0
void xml_cg_formatter::
output_symbol(ostream & out,
	symbol_entry const * symb, size_t lo, size_t hi, bool is_module)
{
	cg_symbol const * cg_symb = dynamic_cast<cg_symbol const *>(symb);
	ostringstream str;
	size_t indx;

	// output symbol's summary data for each profile class
	for (size_t p = lo; p <= hi; ++p)
		xml_support->output_summary_data(str, symb->sample.counts, p);

	if (cverb << vxml)
		out << "<!-- symbol_ref=" << symbol_names.name(symb->name) <<
			" -->" << endl;

	out << open_element(SYMBOL, true);

	string const name = symbol_names.name(symb->name);
	assert(name.size() > 0);

	string const image = get_image_name(symb->image_name,
		image_name_storage::int_filename, extra_found_images);
	string const qname = image + ":" + name;

	string const selfname = symbol_names.demangle(symb->name) + " [self]";

	indx = xml_get_symbol_index(qname);

	out << init_attr(ID_REF, indx);

	out << close_element(NONE, true);

	out << open_element(CALLERS);
	if (cg_symb)
		output_symbol_core(out, cg_symb->callers, selfname, qname, lo, hi, is_module, CALLERS);
	out << close_element(CALLERS);

	out << open_element(CALLEES);
	if (cg_symb)
		output_symbol_core(out, cg_symb->callees, selfname, qname, lo, hi, is_module, CALLEES);

	out << close_element(CALLEES);

	// output summary
	out << str.str();
	out << close_element(SYMBOL);
}
Beispiel #5
0
void xml_formatter::
output_symbol(ostream & out,
	symbol_entry const * symb, size_t lo, size_t hi, bool is_module)
{
	ostringstream str;
	// pointless reference to is_module, remove insane compiler warning
	size_t indx = is_module ? 0 : 1;

	// output symbol's summary data for each profile class
	bool got_samples = false;

	for (size_t p = lo; p <= hi; ++p) {
		got_samples |= xml_support->output_summary_data(str,
		    symb->sample.counts, p);
	}

	if (!got_samples)
		return;

	if (cverb << vxml)
		out << "<!-- symbol_ref=" << symbol_names.name(symb->name) <<
			" -->" << endl;

	out << open_element(SYMBOL, true);

	string const name = symbol_names.name(symb->name);
	assert(name.size() > 0);
	
	string const image = get_image_name(symb->image_name,
		image_name_storage::int_filename, extra_found_images);
	string const qname = image + ":" + name;

	indx = xml_get_symbol_index(qname);

	out << init_attr(ID_REF, indx);

	if (need_details) {
		ostringstream details;
		symbol_details_t & sd = symbol_details[indx];
		size_t const detail_lo = sd.index;

		string detail_str = output_symbol_details(symb, sd.index, lo, hi);

		if (detail_str.size() > 0) {
			if (sd.id < 0)
				sd.id = indx;
			details << detail_str;
		}

		if (sd.index > detail_lo) {
			sd.details = sd.details + details.str();
			out << init_attr(DETAIL_LO, detail_lo);
			out << init_attr(DETAIL_HI, sd.index-1);
		}
	}
	out << close_element(NONE, true);
	// output summary
	out << str.str();
	out << close_element(SYMBOL);
}
Beispiel #6
0
void xml_formatter::
output_sample_data(ostream & out, sample_entry const & sample, size_t pclass)
{
	out << open_element(COUNT, true);
	out << init_attr(CLASS, classes.v[pclass].name);
	out << close_element(NONE, true);
	out << sample.counts[pclass];
	out << close_element(COUNT);
}
Beispiel #7
0
string  xml_formatter::
output_symbol_details(symbol_entry const * symb,
    size_t & detail_index, size_t const lo, size_t const hi)
{
	if (!has_sample_counts(symb->sample.counts, lo, hi))
		return "";

	sample_container::samples_iterator it = profile->begin(symb);
	sample_container::samples_iterator end = profile->end(symb);

	ostringstream str;
	for (; it != end; ++it) {
		counts_t c;

		for (size_t p = lo; p <= hi; ++p)  {
			size_t count = it->second.counts[p];

			if (count == 0) continue;

			str << open_element(DETAIL_DATA, true);
			str << init_attr(TABLE_ID, detail_index++);

			// first output the vma field
			field_datum datum(*symb, it->second, 0, c, 
					  extra_found_images, 0.0);
			output_attribute(str, datum, ff_vma, VMA);
			if (flags & ff_linenr_info) {
				string sym_file;
				size_t sym_line;
				string samp_file;
				size_t samp_line;
				string sym_info = get_linenr_info(symb->sample.file_loc, true);
				string samp_info = get_linenr_info(it->second.file_loc, true);

				if (extract_linenr_info(samp_info, samp_file, samp_line)) {
					if (extract_linenr_info(sym_info, sym_file, sym_line)) {
						// only output source_file if it is different than the symbol's 
						// source file.  this can happen with inlined functions in
						// #included header files
						if (sym_file != samp_file)
							str << init_attr(SOURCE_FILE, samp_file);
					}
					str << init_attr(SOURCE_LINE, samp_line);
				}
			}
			str << close_element(NONE, true);

			// output buffered sample data
			output_sample_data(str, it->second, p);

			str << close_element(DETAIL_DATA);
		}
	}
	return str.str();
}
Beispiel #8
0
static rc_t open_BaseCalls( const KDirectory *hdf5_dir, BaseCalls *tab,
                            const char * path, bool cache_content, bool * rgn_present )
{
    rc_t rc;

    init_BaseCalls( tab );
    rc = open_BaseCalls_cmn( hdf5_dir, &tab->cmn, false, path, cache_content, false );
    if ( rc == 0 )
    {
        rc_t rc1 = rgn_open( hdf5_dir, &tab->rgn );
        if ( rgn_present != NULL )
            *rgn_present = ( rc1 == 0 );

        open_element( hdf5_dir, &tab->PreBaseFrames, path, "PreBaseFrames", 
                               PRE_BASE_FRAMES_BITSIZE, PRE_BASE_FRAMES_COLS,
                               true, cache_content, true );

        if ( rc == 0 )
        {
            rc = open_element( hdf5_dir, &tab->PulseIndex, path, "PulseIndex", 
                               PULSE_INDEX_BITSIZE_16, PULSE_INDEX_COLS,
                               false, cache_content, false );
            /* try again if it is not 16 bit! */
            if ( rc != 0 )
                rc = open_element( hdf5_dir, &tab->PulseIndex, path, "PulseIndex", 
                                   PULSE_INDEX_BITSIZE_32, PULSE_INDEX_COLS,
                                   true, cache_content, false );
        }

        open_element( hdf5_dir, &tab->WidthInFrames, path, "WidthInFrames",
                               WIDTH_IN_FRAMES_BITSIZE, WIDTH_IN_FRAMES_COLS,
                               true, cache_content, true );

        if ( rc != 0 )
            close_BaseCalls( tab ); /* releases only initialized elements */
    }
    return rc;
}
Beispiel #9
0
rc_t rgn_open( const KDirectory *hdf5_dir, regions *rgn )
{
    rc_t rc;
    rgn_init( rgn );
    /* check if the necessary groups/tables are there */
    rc = check_src_objects( hdf5_dir, region_groups_to_check, 
                            region_tables_to_check, false );
    if ( rc == 0 )
    {
        /* open the region-table... */
        rc = open_element( hdf5_dir, &rgn->hdf5_regions,
                           region_groups_to_check[ 0 ], "Regions", 
                           REGIONS_BITSIZE, REGIONS_COLS, true, false, true );
        if ( rc == 0 )
            rc = rgn_read_complete_table( rgn );
    }
    if ( rc != 0 )
        rgn_free( rgn );
    return rc;
}
Beispiel #10
0
void xml_formatter::
output_the_symbol_data(ostream & out, symbol_entry const * symb, op_bfd * & abfd)
{
	string const name = symbol_names.name(symb->name);
	assert(name.size() > 0);

	string const image = get_image_name(symb->image_name,
		image_name_storage::int_filename, extra_found_images);
	string const qname = image + ":" + name;
	map<string, size_t>::iterator sd_it = symbol_data_table.find(qname);

	if (sd_it != symbol_data_table.end()) {
		// first time we've seen this symbol
		out << open_element(SYMBOL_DATA, true);
		out << init_attr(TABLE_ID, sd_it->second);

		field_datum datum(*symb, symb->sample, 0, counts,
				  extra_found_images);

		output_attribute(out, datum, ff_symb_name, NAME);

		if (flags & ff_linenr_info) {
			output_attribute(out, datum, ff_linenr_info, SOURCE_FILE);
			output_attribute(out, datum, ff_linenr_info, SOURCE_LINE);
		}

		if (name.size() > 0 && name[0] != '?') {
			output_attribute(out, datum, ff_vma, STARTING_ADDR);

			if (need_details) {
				get_bfd_object(symb, abfd);
				if (abfd && abfd->symbol_has_contents(symb->sym_index))
					xml_support->output_symbol_bytes(bytes_out, symb, sd_it->second, *abfd);
			}
		}
		out << close_element();

		// seen so remove (otherwise get several "no symbols")
		symbol_data_table.erase(qname);
	}
}
Beispiel #11
0
void xml_formatter::output_symbol_data(ostream & out)
{
	op_bfd * abfd = NULL;
	sym_iterator it = symbols.begin();
	sym_iterator end = symbols.end();

	out << open_element(SYMBOL_TABLE);
	for ( ; it != end; ++it) {
		symbol_entry const * symb = *it;
		cg_symbol const * cg_symb = dynamic_cast<cg_symbol const *>(symb);
		output_the_symbol_data(out, symb, abfd);
		if (cg_symb) {
			/* make sure callers/callees are included in SYMBOL_TABLE */
			output_cg_children(out, cg_symb->callers, abfd);
			output_cg_children(out, cg_symb->callees, abfd);
		}
	}
	out << close_element(SYMBOL_TABLE);

	delete abfd;
}