#include <errno.h>
#include <dirent.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <cverb.h>
#include <iostream>
#include "operf_counter.h"
#include "operf_utils.h"
#include "op_types.h"
#include "operf_process_info.h"
#include "file_manip.h"
#include "operf_kernel.h"
#include "operf_sfile.h"
#include "op_fileio.h"
#include "op_libiberty.h"
#include "operf_stats.h"
Go to the source code of this file.
Defines | |
#define | OFFLINE 0x30 |
Functions | |
static void | update_trans_last (struct operf_transient *trans) |
static void | clear_trans (struct operf_transient *trans) |
static void | __handle_fork_event (event_t *event) |
static void | __handle_comm_event (event_t *event) |
static void | __handle_mmap_event (event_t *event) |
static struct operf_transient * | __get_operf_trans (struct sample_data *data, bool hypervisor_domain, bool kernel_mode) |
static void | __handle_callchain (u64 *array, struct sample_data *data) |
static void | __map_hypervisor_sample (u64 ip, u32 pid) |
static void | __handle_sample_event (event_t *event, u64 sample_type) |
static int | __mmap_trace_file (struct mmap_info &info) |
static void | op_record_process_exec_mmaps (pid_t pid, pid_t tgid, int output_fd, operf_record *pr) |
static int | _record_one_process_info (pid_t pid, bool sys_wide, operf_record *pr, int output_fd) |
static void | _record_module_info (int output_fd, operf_record *pr) |
Variables | |
verbose | vmisc |
all others not fitting in above category, not voluminous. | |
volatile bool | quit |
volatile bool | read_quit |
operf_read | operfRead |
int | sample_reads |
unsigned int | pagesize |
char * | app_name |
pid_t | app_PID |
verbose | vrecord |
verbose | vconvert |
map< pid_t, operf_process_info * > | process_map |
multimap< string, struct operf_mmap * > | all_images_map |
map< u64, struct operf_mmap * > | kernel_modules |
struct operf_mmap * | kernel_mmap |
bool | first_time_processing |
bool | throttled |
size_t | mmap_size |
size_t | pg_sz |
static list< event_t * > | unresolved_events |
static struct operf_transient | trans |
static bool | sfile_init_done |
Helper methods for perf_events-based OProfile.
Created on: Dec 7, 2011
Modified by Maynard Johnson <maynardj@us.ibm.com> (C) Copyright IBM Corporation 2012
Definition in file operf_utils.cpp.
#define OFFLINE 0x30 |
Referenced by OP_perf_utils::op_get_next_online_cpu().
static struct operf_transient* __get_operf_trans | ( | struct sample_data * | data, | |
bool | hypervisor_domain, | |||
bool | kernel_mode | |||
) | [static, read] |
Definition at line 485 of file operf_utils.cpp.
References operf_transient::app_filename, operf_transient::app_len, sample_data::cpu, operf_transient::cpu, operf_transient::cur_procinfo, cverb, operf_transient::end_addr, operf_mmap::end_addr, operf_mmap::filename, operf_process_info::find_mapping_for_sample(), first_time_processing, operf_process_info::get_app_name(), sample_data::id, operf_transient::image_len, operf_transient::image_name, operf_transient::in_kernel, sample_data::ip, operf_transient::is_anon, operf_mmap::is_anon_mapping, operf_mmap::is_hypervisor, kernel_modules, OPERF_INVALID_CTX, OPERF_LOST_NO_MAPPING, OPERF_NO_APP_KERNEL_SAMPLE, OPERF_NO_APP_USER_SAMPLE, operf_stats, operf_transient::pc, sample_data::pid, process_map, operf_transient::sample_id, operf_transient::start_addr, operf_mmap::start_addr, operf_transient::tgid, sample_data::tid, operf_transient::tid, and trans.
Referenced by __handle_callchain(), and __handle_sample_event().
static void __handle_callchain | ( | u64 * | array, | |
struct sample_data * | data | |||
) | [static] |
Definition at line 598 of file operf_utils.cpp.
References __get_operf_trans(), sample_data::callchain, operf_transient::current, cverb, operf_transient::in_kernel, sample_data::ip, ip_callchain::ips, ip_callchain::nr, OPERF_BT_LOST_NO_MAPPING, operf_sfile_find(), operf_sfile_log_arc(), operf_stats, trans, and update_trans_last().
Referenced by __handle_sample_event().
static void __handle_comm_event | ( | event_t * | event | ) | [static] |
Definition at line 296 of file operf_utils.cpp.
References app_name, app_PID, comm_event::comm, event_union::comm, cverb, operf_process_info::pid, comm_event::pid, and process_map.
Referenced by __handle_mmap_event(), and OP_perf_utils::op_write_event().
static void __handle_fork_event | ( | event_t * | event | ) | [static] |
Definition at line 231 of file operf_utils.cpp.
References operf_process_info::add_forked_pid_association(), app_name, operf_process_info::connect_forked_process_to_parent(), cverb, event_union::fork, operf_process_info::get_app_name(), operf_process_info::is_appname_valid(), operf_process_info::is_valid(), operf_process_info::pid, fork_event::pid, fork_event::ppid, and process_map.
Referenced by OP_perf_utils::op_write_event().
static void __handle_mmap_event | ( | event_t * | event | ) | [static] |
Definition at line 364 of file operf_utils.cpp.
References __handle_comm_event(), operf_process_info::add_deferred_mapping(), all_images_map, app_name, app_PID, cverb, operf_mmap::end_addr, operf_mmap::filename, mmap_event::filename, event_union::header, operf_mmap::is_anon_mapping, kernel_modules, kptr_restrict, mmap_event::len, event_union::mmap, my_uid, no_vmlinux, op_basename(), operf_create_module(), operf_get_vmlinux_name(), mmap_event::pgoff, operf_mmap::pgoff, mmap_event::pid, process_map, mmap_event::start, and operf_mmap::start_addr.
Referenced by OP_perf_utils::op_write_event().
Definition at line 674 of file operf_utils.cpp.
References __get_operf_trans(), __handle_callchain(), __map_hypervisor_sample(), clear_trans(), sample_data::cpu, operf_transient::current, cverb, operf_transient::end_addr, operf_transient::event, first_time_processing, operf_read::get_event_by_counter(), operf_read::get_eventnum_by_perf_event_id(), event_union::header, sample_data::id, operf_transient::image_name, sample_data::ip, operf_transient::is_anon, operf_event::no_user, OPERF_LOST_INVALID_HYPERV_ADDR, operf_sfile_find(), operf_sfile_log_sample(), operf_stats, operf_transient::pc, sample_data::pid, operf_transient::start_addr, operf_transient::tgid, operf_transient::tid, sample_data::tid, trans, unresolved_events, and update_trans_last().
Referenced by OP_perf_utils::op_reprocess_unresolved_events(), and OP_perf_utils::op_write_event().
Definition at line 637 of file operf_utils.cpp.
References app_name, app_PID, cverb, operf_process_info::process_hypervisor_mapping(), and process_map.
Referenced by __handle_sample_event().
static int __mmap_trace_file | ( | struct mmap_info & | info | ) | [static] |
Definition at line 970 of file operf_utils.cpp.
References mmap_info::buf, cverb, mmap_info::head, mmap_size, mmap_info::offset, and mmap_info::traceFD.
Referenced by OP_perf_utils::op_mmap_trace_file().
static void _record_module_info | ( | int | output_fd, | |
operf_record * | pr | |||
) | [static] |
Definition at line 1247 of file operf_utils.cpp.
References operf_record::add_to_total(), align_64bit(), cverb, mmap_event::filename, mmap_event::header, mmap_event::len, op_get_line(), OP_perf_utils::op_write_output(), mmap_event::pgoff, mmap_event::pid, mmap_event::start, and mmap_event::tid.
static int _record_one_process_info | ( | pid_t | pid, | |
bool | sys_wide, | |||
operf_record * | pr, | |||
int | output_fd | |||
) | [static] |
Definition at line 1095 of file operf_utils.cpp.
References operf_record::add_to_total(), align_64bit(), comm_event::comm, cverb, comm_event::header, op_record_process_exec_mmaps(), OP_perf_utils::op_write_output(), comm_event::pid, and comm_event::tid.
Referenced by OP_perf_utils::op_record_process_info().
static void clear_trans | ( | struct operf_transient * | trans | ) | [inline, static] |
Definition at line 225 of file operf_utils.cpp.
References operf_transient::cur_procinfo, and operf_transient::tgid.
Referenced by __handle_sample_event().
static void op_record_process_exec_mmaps | ( | pid_t | pid, | |
pid_t | tgid, | |||
int | output_fd, | |||
operf_record * | pr | |||
) | [static] |
Definition at line 1033 of file operf_utils.cpp.
References operf_record::add_to_total(), align_64bit(), cverb, operf_mmap::end_addr, mmap_event::filename, mmap_event::header, mmap_event::len, OP_perf_utils::op_write_output(), mmap_event::pgoff, mmap_event::pid, mmap_event::start, operf_mmap::start_addr, and mmap_event::tid.
Referenced by _record_one_process_info().
static void update_trans_last | ( | struct operf_transient * | trans | ) | [inline, static] |
Definition at line 219 of file operf_utils.cpp.
References operf_transient::current, operf_transient::last, operf_transient::last_pc, and operf_transient::pc.
Referenced by __handle_callchain(), and __handle_sample_event().
multimap<string, struct operf_mmap *> all_images_map |
Definition at line 54 of file operf_utils.cpp.
Referenced by __handle_mmap_event(), and OP_perf_utils::op_release_resources().
char* app_name |
Definition at line 61 of file operf.cpp.
Referenced by __handle_comm_event(), __handle_fork_event(), __handle_mmap_event(), __map_hypervisor_sample(), find_app_file_in_dir(), get_PATH_based_pathname(), opd_add_kernel_map(), process_args(), run_app(), and validate_app_name().
pid_t app_PID |
Definition at line 62 of file operf.cpp.
Referenced by __handle_comm_event(), __handle_mmap_event(), __map_hypervisor_sample(), _run(), main(), op_sig_stop(), process_args(), and start_profiling().
Definition at line 57 of file operf_utils.cpp.
Referenced by __get_operf_trans(), __handle_sample_event(), and operf_read::convertPerfData().
struct operf_mmap* kernel_mmap |
Definition at line 56 of file operf_utils.cpp.
map<u64, struct operf_mmap *> kernel_modules |
Definition at line 55 of file operf_utils.cpp.
Referenced by __get_operf_trans(), and __handle_mmap_event().
size_t mmap_size |
Definition at line 59 of file operf_utils.cpp.
Referenced by __mmap_trace_file(), and OP_perf_utils::op_mmap_trace_file().
unsigned int pagesize |
Definition at line 43 of file operf_counter.cpp.
Referenced by OP_perf_utils::op_get_kernel_event_data(), operf_record::prepareToRecord(), operf_record::setup(), and operf_record::~operf_record().
size_t pg_sz |
Definition at line 60 of file operf_utils.cpp.
Referenced by OP_perf_utils::op_mmap_trace_file().
map<pid_t, operf_process_info *> process_map |
Definition at line 53 of file operf_utils.cpp.
Referenced by __get_operf_trans(), __handle_comm_event(), __handle_fork_event(), __handle_mmap_event(), __map_hypervisor_sample(), and OP_perf_utils::op_release_resources().
volatile bool quit |
Definition at line 39 of file operf_counter.cpp.
Referenced by OP_perf_utils::op_perfrecord_sigusr1_handler(), and operf_record::recordPerfData().
volatile bool read_quit |
Definition at line 40 of file operf_counter.cpp.
Referenced by OP_perf_utils::op_perfread_sigusr1_handler().
int sample_reads |
Definition at line 41 of file operf_counter.cpp.
Referenced by OP_perf_utils::op_get_kernel_event_data(), and operf_record::recordPerfData().
bool sfile_init_done [static] |
Definition at line 64 of file operf_utils.cpp.
Referenced by OP_perf_utils::op_write_event().
bool throttled |
Definition at line 58 of file operf_utils.cpp.
Referenced by operf_read::convertPerfData(), main(), and OP_perf_utils::op_write_event().
struct operf_transient trans [static] |
Definition at line 63 of file operf_utils.cpp.
Referenced by __get_operf_trans(), __handle_callchain(), __handle_sample_event(), add_anon_mapping(), anon_match(), cache_spu_context_info(), clear_anon_maps(), clear_trans_current(), clear_trans_last(), code_cookie_switch(), code_cpu_switch(), code_ctx_switch(), code_ibs_fetch_sample(), code_ibs_op_sample(), code_kernel_enter(), code_module_loaded(), code_spu_ctx_switch(), code_spu_profiling(), code_trace_begin(), code_user_enter(), code_xen_enter(), create_sfile(), do_lru(), enough_remaining(), find_anon_mapping(), find_kernel_image(), get_anon_maps(), get_file(), get_ibs_op_bta_sample(), ibs_sfile_get(), opd_ext_sfile_get(), opd_log_ibs_count(), opd_log_ibs_event(), opd_log_ibs_fetch(), opd_log_ibs_op(), opd_put_ibs_sample(), opd_put_sample(), opd_put_spu_sample(), pop_buffer_value(), process_spu_samples(), sfile_find(), sfile_hash(), sfile_log_arc(), sfile_log_sample(), sfile_log_sample_count(), trans_ibs_fetch(), trans_ibs_op(), trans_ibs_op_bta(), trans_ibs_op_ls(), trans_ibs_op_ls_memaccess(), trans_ibs_op_mask_reserved(), trans_ibs_op_nb(), trans_ibs_op_rip_invalid(), trans_match(), update_trans_for_spu(), update_trans_last(), verbose_arc(), and verbose_sample().
list<event_t *> unresolved_events [static] |
Definition at line 62 of file operf_utils.cpp.
Referenced by __handle_sample_event(), and OP_perf_utils::op_reprocess_unresolved_events().
all others not fitting in above category, not voluminous.
Definition at line 61 of file oprofiled.c.