#include "config.h"
#include "oprofiled.h"
#include "opd_printf.h"
#include "opd_events.h"
#include "opd_extended.h"
#include "op_config.h"
#include "op_version.h"
#include "op_hw_config.h"
#include "op_libiberty.h"
#include "op_file.h"
#include "op_abi.h"
#include "op_string.h"
#include "op_cpu_type.h"
#include "op_popt.h"
#include "op_lockfile.h"
#include "op_list.h"
#include "op_fileio.h"
#include <sys/types.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include <dirent.h>
#include <limits.h>
Go to the source code of this file.
Data Structures | |
struct | opd_hashed_name |
Defines | |
#define | OPD_IMAGE_FILTER_HASH_SIZE 32 |
Functions | |
void | opd_open_logfile (void) |
static void | opd_fork (void) |
static void | opd_go_daemon (void) |
static void | opd_write_abi (void) |
static void | opd_alarm (int val __attribute__((unused))) |
static void | opd_sighup (int val __attribute__((unused))) |
static void | opd_sigterm (int val __attribute__((unused))) |
static void | opd_sigchild (int val __attribute__((unused))) |
static void | opd_sigusr1 (int val __attribute__((unused))) |
static void | opd_sigusr2 (int val __attribute__((unused))) |
static void | opd_setup_signals (void) |
static void | add_image_filter (char const *name) |
static void | opd_parse_image_filter (void) |
int | is_image_ignored (char const *name) |
int | opd_read_fs_int (char const *path, char const *name, int fatal) |
static void | opd_handle_verbose_option (char const *name) |
static void | opd_parse_verbose (void) |
static void | opd_options (int argc, char const *argv[]) |
static struct oprofiled_ops * | get_ops (void) |
int | main (int argc, char const *argv[]) |
Variables | |
sig_atomic_t | signal_alarm |
sig_atomic_t | signal_hup |
sig_atomic_t | signal_term |
sig_atomic_t | signal_child |
sig_atomic_t | signal_usr1 |
sig_atomic_t | signal_usr2 |
uint | op_nr_counters |
op_cpu | cpu_type |
int | no_event_ok |
int | vsfile |
int | vsamples |
log samples, voluminous. | |
int | varcs |
log arc, very voluminous. | |
int | vmodule |
kernel module handling | |
int | vmisc |
all others not fitting in above category, not voluminous. | |
int | vext |
extended feature | |
int | separate_lib |
int | separate_kernel |
int | separate_thread |
int | separate_cpu |
int | no_vmlinux |
char * | vmlinux |
char * | kernel_range |
char * | session_dir |
int | no_xen |
char * | xenimage |
char * | xen_range |
static char * | verbose |
static char * | binary_name_filter |
static char * | events |
static char * | ext_feature |
static int | showvers |
static struct oprofiled_ops * | opd_ops |
struct oprofiled_ops | opd_24_ops |
struct oprofiled_ops | opd_26_ops |
static struct list_head | images_filter [OPD_IMAGE_FILTER_HASH_SIZE] |
static struct poptOption | options [] |
Initialisation and setup
Definition in file oprofiled.c.
#define OPD_IMAGE_FILTER_HASH_SIZE 32 |
Definition at line 83 of file oprofiled.c.
Referenced by add_image_filter(), is_image_ignored(), and opd_parse_image_filter().
static void add_image_filter | ( | char const * | name | ) | [static] |
Definition at line 285 of file oprofiled.c.
References images_filter, list_add(), opd_hashed_name::name, opd_hashed_name::next, op_hash_string(), OPD_IMAGE_FILTER_HASH_SIZE, verbprintf, and vmisc.
Referenced by opd_parse_image_filter().
static struct oprofiled_ops* get_ops | ( | void | ) | [static, read] |
Definition at line 477 of file oprofiled.c.
References oprofiled_ops::exit, op_get_interface(), OP_INTERFACE_24, OP_INTERFACE_26, opd_24_ops, and opd_26_ops.
Referenced by main().
int is_image_ignored | ( | char const * | name | ) |
is_image_ignored - check if we must ignore this image
name | the name to check |
Return true if the image should not be profiled
Definition at line 323 of file oprofiled.c.
References binary_name_filter, images_filter, list_entry, list_for_each, opd_hashed_name::name, opd_hashed_name::next, op_hash_string(), and OPD_IMAGE_FILTER_HASH_SIZE.
Referenced by create_cookie(), is_sf_ignored(), and opd_new_image().
int main | ( | int | argc, | |
char const * | argv[] | |||
) |
Definition at line 496 of file oprofiled.c.
References oprofiled_ops::exit, get_ops(), oprofiled_ops::init, init_op_config_dirs(), op_lock_file, op_write_lock_file(), opd_go_daemon(), opd_options(), opd_setup_signals(), opd_write_abi(), session_dir, and oprofiled_ops::start.
static void opd_alarm | ( | int val | __attribute__(unused) | ) | [static] |
opd_alarm - sync files and report stats
Definition at line 178 of file oprofiled.c.
References signal_alarm.
Referenced by opd_setup_signals().
static void opd_fork | ( | void | ) | [static] |
opd_fork - fork and return as child
fork() and exit the parent with _exit(). Failure is fatal.
Definition at line 127 of file oprofiled.c.
Referenced by opd_go_daemon().
static void opd_go_daemon | ( | void | ) | [static] |
Definition at line 144 of file oprofiled.c.
References op_session_dir, and opd_fork().
Referenced by main().
static void opd_handle_verbose_option | ( | char const * | name | ) | [static] |
Definition at line 353 of file oprofiled.c.
References varcs, vext, vmisc, vmodule, vsamples, and vsfile.
Referenced by opd_parse_verbose().
void opd_open_logfile | ( | void | ) |
opd_open_logfile - open the log file
Open the logfile on stdout and stderr. This function assumes that 1 and 2 are the lowest close()d file descriptors. Failure to open on either descriptor is a fatal error.
Definition at line 107 of file oprofiled.c.
References op_log_file.
Referenced by op_open_files(), opd_open_files(), and opd_sighup().
static void opd_options | ( | int | argc, | |
char const * | argv[] | |||
) | [static] |
Definition at line 398 of file oprofiled.c.
References events, ext_feature, kernel_range, no_event_ok, no_vmlinux, no_xen, op_get_cpu_type(), op_get_nr_counters(), op_nr_counters, op_poptGetContext(), opd_ext_initialize(), opd_parse_events(), opd_parse_image_filter(), opd_parse_verbose(), optcon, options, separate_kernel, separate_lib, show_version(), showvers, vmlinux, xen_range, and xenimage.
Referenced by main().
static void opd_parse_image_filter | ( | void | ) | [static] |
Definition at line 301 of file oprofiled.c.
References add_image_filter(), binary_name_filter, images_filter, list_init(), op_xstrndup(), and OPD_IMAGE_FILTER_HASH_SIZE.
Referenced by opd_options().
static void opd_parse_verbose | ( | void | ) | [static] |
Definition at line 380 of file oprofiled.c.
References op_xstrndup(), and opd_handle_verbose_option().
Referenced by opd_options().
int opd_read_fs_int | ( | char const * | path, | |
char const * | name, | |||
int | fatal | |||
) |
return the int in the given oprofilefs file
Definition at line 345 of file oprofiled.c.
References filename, and op_read_int_from_file().
Referenced by opd_24_init(), opd_26_init(), opd_print_24_stats(), and print_if().
static void opd_setup_signals | ( | void | ) | [static] |
Definition at line 214 of file oprofiled.c.
References opd_alarm(), opd_sigchild(), opd_sighup(), opd_sigterm(), opd_sigusr1(), and opd_sigusr2().
Referenced by main().
static void opd_sigchild | ( | int val | __attribute__(unused) | ) | [static] |
Definition at line 196 of file oprofiled.c.
References signal_child.
Referenced by opd_setup_signals().
static void opd_sighup | ( | int val | __attribute__(unused) | ) | [static] |
Definition at line 185 of file oprofiled.c.
References signal_hup.
Referenced by opd_setup_signals().
static void opd_sigterm | ( | int val | __attribute__(unused) | ) | [static] |
Definition at line 191 of file oprofiled.c.
References signal_term.
Referenced by opd_setup_signals().
static void opd_sigusr1 | ( | int val | __attribute__(unused) | ) | [static] |
Definition at line 202 of file oprofiled.c.
References signal_usr1.
Referenced by opd_setup_signals().
static void opd_sigusr2 | ( | int val | __attribute__(unused) | ) | [static] |
Definition at line 208 of file oprofiled.c.
References signal_usr2.
Referenced by opd_setup_signals().
static void opd_write_abi | ( | void | ) | [static] |
Definition at line 163 of file oprofiled.c.
References op_session_dir, and op_write_abi_to_file().
Referenced by main().
char* binary_name_filter [static] |
Definition at line 75 of file oprofiled.c.
Referenced by is_image_ignored(), and opd_parse_image_filter().
Definition at line 55 of file oprofiled.c.
char* events [static] |
Definition at line 76 of file oprofiled.c.
Referenced by oprof_start::alloc_selected_events(), oprof_start::fill_events(), main(), and opd_options().
char* ext_feature [static] |
Definition at line 77 of file oprofiled.c.
Referenced by opd_options().
struct list_head images_filter[OPD_IMAGE_FILTER_HASH_SIZE] [static] |
Definition at line 84 of file oprofiled.c.
Referenced by add_image_filter(), is_image_ignored(), and opd_parse_image_filter().
char* kernel_range |
Definition at line 69 of file oprofiled.c.
Referenced by opd_24_init(), opd_26_init(), and opd_options().
int no_event_ok |
Definition at line 56 of file oprofiled.c.
Referenced by ibs_init(), and opd_options().
int no_vmlinux |
Definition at line 67 of file oprofiled.c.
Referenced by __handle_mmap_event(), _process_vmlinux(), find_kernel_image(), opd_24_init(), opd_create_vmlinux(), opd_handle_kernel_sample(), opd_options(), opd_put_sample(), opd_reread_module_info(), operf_create_vmlinux(), operf_find_kernel_image(), and process_args().
int no_xen |
Definition at line 71 of file oprofiled.c.
Referenced by opd_create_xen(), and opd_options().
uint op_nr_counters |
Definition at line 54 of file oprofiled.c.
Referenced by close_sfile(), create_sfile(), find_counter_event(), get_file(), opd_close_image_samples_files(), opd_options(), opd_parse_events(), operf_sfile_dup(), process_args(), sfile_dup(), and sync_sfile().
struct oprofiled_ops opd_24_ops |
struct oprofiled_ops opd_26_ops |
struct oprofiled_ops* opd_ops [static] |
Definition at line 79 of file oprofiled.c.
struct poptOption options[] [static] |
{ { "session-dir", 0, POPT_ARG_STRING, &session_dir, 0, "place sample database in dir instead of default location", "/var/lib/oprofile", }, { "kernel-range", 'r', POPT_ARG_STRING, &kernel_range, 0, "Kernel VMA range", "start-end", }, { "vmlinux", 'k', POPT_ARG_STRING, &vmlinux, 0, "vmlinux kernel image", "file", }, { "no-vmlinux", 0, POPT_ARG_NONE, &no_vmlinux, 0, "vmlinux kernel image file not available", NULL, }, { "xen-range", 0, POPT_ARG_STRING, &xen_range, 0, "Xen VMA range", "start-end", }, { "xen-image", 0, POPT_ARG_STRING, &xenimage, 0, "Xen image", "file", }, { "image", 0, POPT_ARG_STRING, &binary_name_filter, 0, "image name filter", "profile these comma separated image" }, { "separate-lib", 0, POPT_ARG_INT, &separate_lib, 0, "separate library samples for each distinct application", "[0|1]", }, { "separate-kernel", 0, POPT_ARG_INT, &separate_kernel, 0, "separate kernel samples for each distinct application", "[0|1]", }, { "separate-thread", 0, POPT_ARG_INT, &separate_thread, 0, "thread-profiling mode", "[0|1]" }, { "separate-cpu", 0, POPT_ARG_INT, &separate_cpu, 0, "separate samples for each CPU", "[0|1]" }, { "events", 'e', POPT_ARG_STRING, &events, 0, "events list", "[events]" }, { "version", 'v', POPT_ARG_NONE, &showvers, 0, "show version", NULL, }, { "verbose", 'V', POPT_ARG_STRING, &verbose, 0, "be verbose in log file", "all,sfile,arcs,samples,module,misc", }, { "ext-feature", 'x', POPT_ARG_STRING, &ext_feature, 1, "enable extended feature", "<extended-feature-name>:[args]", }, POPT_AUTOHELP { NULL, 0, 0, NULL, 0, NULL, NULL, }, }
Definition at line 86 of file oprofiled.c.
Referenced by handle_merge_option(), handle_options(), opd_options(), and popt::parse_options().
int separate_cpu |
Definition at line 66 of file oprofiled.c.
Referenced by _process_operf_and_app_args(), create_sfile(), do_match(), mangle_filename(), opd_do_samples(), opd_mangle_filename(), sfile_hash(), and start_profiling().
int separate_kernel |
Definition at line 64 of file oprofiled.c.
Referenced by create_sfile(), do_match(), get_dep_name(), opd_options(), opd_put_sample(), and sfile_hash().
int separate_lib |
Definition at line 63 of file oprofiled.c.
Referenced by create_sfile(), do_match(), get_dep_name(), is_same_image(), opd_mangle_filename(), opd_new_image(), opd_options(), and sfile_hash().
int separate_thread |
Definition at line 65 of file oprofiled.c.
Referenced by _process_operf_and_app_args(), create_sfile(), do_match(), is_same_image(), mangle_filename(), opd_handle_fork(), opd_hash_image(), opd_mangle_filename(), and sfile_hash().
char* session_dir |
Definition at line 70 of file oprofiled.c.
int showvers [static] |
Definition at line 78 of file oprofiled.c.
Referenced by opd_options().
sig_atomic_t signal_alarm |
global variable positioned by signal handler
Definition at line 47 of file oprofiled.c.
Referenced by opd_alarm(), and opd_do_read().
sig_atomic_t signal_child |
Definition at line 50 of file oprofiled.c.
Referenced by opd_do_read(), and opd_sigchild().
sig_atomic_t signal_hup |
Definition at line 48 of file oprofiled.c.
Referenced by opd_do_read(), and opd_sighup().
sig_atomic_t signal_term |
Definition at line 49 of file oprofiled.c.
Referenced by opd_do_read(), and opd_sigterm().
sig_atomic_t signal_usr1 |
Definition at line 51 of file oprofiled.c.
Referenced by opd_do_read(), and opd_sigusr1().
sig_atomic_t signal_usr2 |
Definition at line 52 of file oprofiled.c.
Referenced by opd_do_read(), and opd_sigusr2().
int varcs |
char* verbose [static] |
Definition at line 74 of file oprofiled.c.
int vext |
extended feature
Definition at line 62 of file oprofiled.c.
Referenced by code_ibs_fetch_sample(), code_ibs_op_sample(), get_ibs_op_bta_sample(), ibs_init(), and opd_handle_verbose_option().
int vmisc |
all others not fitting in above category, not voluminous.
Definition at line 61 of file oprofiled.c.
char* vmlinux |
Definition at line 68 of file oprofiled.c.
Referenced by opd_26_exit(), opd_26_init(), opd_add_kernel_map(), opd_init_kernel_image(), and opd_options().
int vmodule |
kernel module handling
Definition at line 60 of file oprofiled.c.
Referenced by code_module_loaded(), opd_add_kernel_map(), opd_clear_module_info(), opd_drop_module_sample(), opd_get_module_info(), opd_handle_module_sample(), opd_handle_verbose_option(), and opd_reread_module_info().
int vsamples |
log samples, voluminous.
Definition at line 58 of file oprofiled.c.
Referenced by code_ibs_fetch_sample(), code_ibs_op_sample(), opd_do_samples(), opd_handle_verbose_option(), opd_put_sample(), sfile_find(), sfile_log_sample_count(), and verb_show_sample().
int vsfile |
log all sample file name manipulation; sample files open, close, sfile LRU etc. voluminous. FIXME need to be splitted (filename manip, files handling) ?
Definition at line 57 of file oprofiled.c.
char* xen_range |
Definition at line 73 of file oprofiled.c.
Referenced by opd_26_init(), and opd_options().
char* xenimage |
Definition at line 72 of file oprofiled.c.
Referenced by opd_26_init(), and opd_options().