From: Yeh, J. <jas...@am...> - 2005-12-21 21:30:12
|
CodeAnalyst interfaces with Oprofile in the ways similar to how opreport uses libpp. Raw data is not used by CodeAnalyst. Instead it uses processed data through linking with libpp. Here are two ways that CodeAnalyst uses libpp to access data of current profile. The snippets of the code are at the end of this email for less cluttering: I. Use Oprofile's post processing code to generates summary in the following manner: 1. Create profile_spec. 2. Generate a list of sample files. 3. Arrange sample files into profile classes. 4. Create summary_container from profile classes. 5. CodeAnalyst saves the summary. II. Use Oprofile's post processing code to retrieve the results for each binary file in terms of symbols: 1. Create profile_spec. 2. Generate a list of sample files. 3. Arrange sample files into profile classes. 4. Invert profile classes. 5. For each inverted profile class add symbols into one profile_container. 6. Select all symbols from profile_container 7. Sort the symbols by file name and by reverse sort.=20 8. For each symbol, CodeAnalyst saves the data. If this level of API is believed to be practical and viable, I can go through headers in libpp in the same fashion Maynard Johnson has done for libdb/odb.h. Regards, Jason /****** Code segment for case 1 *****/ profile_spec const spec =3D profile_spec::create (non_options, extra_found_images); list < string > sample_files; try { sample_files =3D spec.generate_file_list (exclude_dependent, EXCLUDE_CG_DATA); m_mod_classes =3D arrange_profiles (sample_files, merge_by); } catch (...) { ... } summary_container summaries (m_mod_classes.v); // Store the count into the app_sample_map vector < app_summary >::const_iterator it =3D summaries.apps.begin = (); for (; it !=3D summaries.apps.end (); it++) { .... } /***** Code segment of case 2 *****/ profile_spec const spec =3D profile_spec::create (non_options, extra_found_images); list < string > sample_files; try { sample_files =3D spec.generate_file_list (exclude_dependent, EXCLUDE_CG_DATA); } catch (...) { ... } addr_classes =3D arrange_profiles (sample_files, merge_by); // Don't need debug info, but need details profile_container samples (false, true); list < inverted_profile > iprofiles =3D invert_profiles (options::archive_path, addr_classes, options::extra_found_images); list < inverted_profile >::iterator it =3D iprofiles.begin (); list < inverted_profile >::iterator const end =3D iprofiles.end (); for (; it !=3D end; ++it) { try { populate_for_image (options::archive_path, samples, *it, options::symbol_filter); } catch(...) { ... } } profile_container::symbol_choice choice; choice.threshold =3D 0; symbol_collection symbols =3D samples.select_symbols (choice); options::sort_by.sort (symbols, options::reverse_sort, options::long_filenames); symbol_collection::const_iterator sit =3D symbols.begin (); symbol_collection::const_iterator send =3D symbols.end (); for (; sit !=3D send; sit++) { .... } |