Esempio n. 1
0
void profile_t::set_offset(op_bfd const & abfd)
{
	opd_header const & header = get_header();
	if (header.anon_start || header.is_kernel)
		start_offset = abfd.get_start_offset(header.anon_start);
	cverb << (vdebug) << "start_offset is now " << start_offset << endl;
}
Esempio n. 2
0
void
xml_utils::output_symbol_bytes(ostream & out, symbol_entry const * symb,
			       size_t sym_id, op_bfd const & abfd)
{
	size_t size = symb->size;
	scoped_array<unsigned char> contents(new unsigned char[size]);
	if (abfd.get_symbol_contents(symb->sym_index, contents.get())) {
		string const name = symbol_names.name(symb->name);
		out << open_element(BYTES, true) << init_attr(TABLE_ID, sym_id);
		out << close_element(NONE, true);
		for (size_t i = 0; i < size; ++i) {
			char hex_map[] = "0123456789ABCDEF";
			char hex[2];
			hex[0] = hex_map[(contents[i] >> 4) & 0xf];
			hex[1] = hex_map[contents[i] & 0xf];
			out << hex[0] << hex[1];
		}
		out << close_element(BYTES);
	}
Esempio n. 3
0
void callgraph_container::
add(profile_t const & profile, op_bfd const & caller_bfd, bool caller_bfd_ok,
   op_bfd const & callee_bfd, string const & app_name,
   profile_container const & pc, bool debug_info, size_t pclass)
{
	string const image_name = caller_bfd.get_filename();

	opd_header const & header = profile.get_header();

	// We can't use kernel sample file w/o the binary else we will
	// use it with a zero offset, the code below will abort because
	// we will get incorrect callee sub-range and out of range
	// callee vma. FIXME
	if (header.is_kernel && !caller_bfd_ok)
		return;

	// We must handle start_offset, this offset can be different for the
	// caller and the callee: kernel sample traversing the syscall barrier.
	u32 caller_offset;
	if (header.is_kernel)
		caller_offset = caller_bfd.get_start_offset(0);
	else
		caller_offset = header.anon_start;

	u32 callee_offset;
	if (header.cg_to_is_kernel)
		callee_offset = callee_bfd.get_start_offset(0);
	else
		callee_offset = header.cg_to_anon_start;

	image_name_id image_id = image_names.create(image_name);
	image_name_id callee_image_id = image_names.create(callee_bfd.get_filename());
	image_name_id app_id = image_names.create(app_name);

	call_data caller(pc, profile, caller_bfd, caller_offset, image_id,
	                   app_id, debug_info);
	call_data callee(pc, profile, callee_bfd, callee_offset,
	                   callee_image_id, app_id, debug_info);

	if (cverb << vdebug) {
		caller.verbose_bfd("Caller:");
		callee.verbose_bfd("Callee:");
	}

	// For each symbol in the caller bfd, process all arcs to
	// callee bfd symbols

	for (symbol_index_t i = 0; i < caller_bfd.syms.size(); ++i) {

		caller.caller_sym(i);

		call_data::const_iterator dit = caller.samples.begin();
		call_data::const_iterator dend = caller.samples.end();
		while (dit != dend) {
			// if we can't find the callee, skip an arc
			if (!callee.callee_sym(key_to_callee(dit->first))) {
				++dit;
				continue;
			}

			count_array_t arc_count;
			arc_count[pclass] =
				accumulate_callee(dit, dend, callee.callee_end);

			recorder.add(caller.sym, &callee.sym, arc_count);
		}
	}
}