oprofiled.c File Reference

#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>
Include dependency graph for oprofiled.c:

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_opsget_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_opsopd_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 []

Detailed Description

Initialisation and setup

Remarks:
Copyright 2002, 2003 OProfile authors
Read the file COPYING
Author:
John Levon
Philippe Elie Modified by Aravind Menon for Xen These modifications are: Copyright (C) 2005 Hewlett-Packard Co.

Definition in file oprofiled.c.


Define Documentation

#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().


Function Documentation

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

int is_image_ignored ( char const *  name  ) 

is_image_ignored - check if we must ignore this image

Parameters:
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().

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char const *  argv[] 
)
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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

static void opd_options ( int  argc,
char const *  argv[] 
) [static]
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

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]
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().

Definition at line 56 of file oprofiled.c.

Referenced by ibs_init(), and opd_options().

int no_xen

Definition at line 71 of file oprofiled.c.

Referenced by opd_create_xen(), and opd_options().

Definition at line 383 of file init.c.

Referenced by get_ops().

Definition at line 368 of file init.c.

Referenced by get_ops().

struct oprofiled_ops* opd_ops [static]

Definition at line 79 of file oprofiled.c.

struct poptOption options[] [static]
Initial value:
 {
    { "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().

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

log arc, very voluminous.

named "arcs"

Definition at line 59 of file oprofiled.c.

char* verbose [static]

Definition at line 74 of file oprofiled.c.

int vext
int vmisc

all others not fitting in above category, not voluminous.

Definition at line 61 of file oprofiled.c.

char* vmlinux
int vmodule
int vsamples
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().


Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1