opd_image.c File Reference

#include "opd_image.h"
#include "opd_printf.h"
#include "opd_sample_files.h"
#include "opd_24_stats.h"
#include "oprofiled.h"
#include "op_file.h"
#include "op_config_24.h"
#include "op_libiberty.h"
#include "op_string.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
Include dependency graph for opd_image.c:

Go to the source code of this file.

Defines

#define OPD_IMAGE_HASH_SIZE   2048

Functions

void opd_init_images (void)
int opd_get_nr_images (void)
void opd_delete_image (struct opd_image *image)
void opd_for_each_image (opd_image_cb image_cb)
static size_t opd_hash_image (char const *name, pid_t tid, pid_t tgid)
static struct opd_imageopd_new_image (char const *name, char const *app_name, int kernel, pid_t tid, pid_t tgid)
static int is_same_image (struct opd_image const *image, char const *app_name, pid_t tid, pid_t tgid)
static struct opd_imageopd_find_image (char const *name, char const *app_name, pid_t tid, pid_t tgid)
struct opd_imageopd_get_image (char const *name, char const *app_name, int kernel, pid_t tid, pid_t tgid)
struct opd_imageopd_get_kernel_image (char const *name, char const *app_name, pid_t tid, pid_t tgid)

Variables

static int nr_images
static struct list_head opd_images [OPD_IMAGE_HASH_SIZE]

Detailed Description

Management of binary images

Remarks:
Copyright 2002 OProfile authors
Read the file COPYING
Author:
John Levon
Philippe Elie

Definition in file opd_image.c.


Define Documentation

#define OPD_IMAGE_HASH_SIZE   2048

Definition at line 31 of file opd_image.c.

Referenced by opd_for_each_image(), opd_hash_image(), and opd_init_images().


Function Documentation

static int is_same_image ( struct opd_image const *  image,
char const *  app_name,
pid_t  tid,
pid_t  tgid 
) [static]

is_same_image - check for identical image

Parameters:
image image to compare
name name of image
app_name image must belong to this application name
tid thread id
tgid thread group id

on entry caller have checked than strcmp(image->name, name) == 0 return 0 if the couple (name, app_name) refers to same image

Definition at line 177 of file opd_image.c.

References opd_image::app_name, opd_image::name, separate_lib, separate_thread, opd_image::tgid, and opd_image::tid.

Referenced by opd_find_image().

Here is the caller graph for this function:

void opd_delete_image ( struct opd_image image  ) 
Parameters:
image the image pointer

Decrement reference count of image, if reference count is zero flush and close the samples files then freeze all memory belonging to this image.

Definition at line 49 of file opd_image.c.

References opd_image::app_name, opd_image::hash_next, opd_image::kernel, list_del(), opd_image::name, nr_images, opd_close_image_samples_files(), opd_image::ref_count, opd_image::tgid, opd_image::tid, verbprintf, and vmisc.

Referenced by opd_24_exit(), opd_kill_maps(), and opd_remove_kernel_mapping().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct opd_image* opd_find_image ( char const *  name,
char const *  app_name,
pid_t  tid,
pid_t  tgid 
) [static, read]

opd_find_image - find an image

Parameters:
name name of image to find
hash hash of image to find
app_name the application name where belongs this image
tid thread id
tgid thread group id

Returns the image pointer for the file specified by name, or NULL.

Definition at line 221 of file opd_image.c.

References is_same_image(), list_entry, list_for_each, opd_image::name, opd_24_stats, opd_hash_image(), OPD_IMAGE_HASH_ACCESS, OPD_IMAGE_HASH_DEPTH, and opd_images.

Referenced by opd_get_image().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_for_each_image ( opd_image_cb  imagecb  ) 
Parameters:
imagecb callback to apply onto each existing image struct

the callback receive a struct opd_image * (not a const struct) and is allowed to freeze the image struct itself.

Definition at line 79 of file opd_image.c.

References opd_image::hash_next, list_entry, list_for_each_safe, OPD_IMAGE_HASH_SIZE, and opd_images.

Referenced by opd_24_exit(), and opd_sighup().

Here is the caller graph for this function:

struct opd_image* opd_get_image ( char const *  name,
char const *  app_name,
int  kernel,
pid_t  tid,
pid_t  tgid 
) [read]

opd_get_image - get an image from the image structure

Parameters:
name name of image
app_name the application name where belongs this image
kernel is the image a kernel/module image
tid thread id
tgid thread group id

Get the image specified by the file name name from the image structure. If it is not present, the image is added to the structure. In either case, the image number is returned.

Definition at line 249 of file opd_image.c.

References opd_find_image(), and opd_new_image().

Referenced by opd_add_ascii_map(), opd_get_ascii_maps(), opd_get_kernel_image(), opd_handle_fork(), and opd_handle_mapping().

Here is the call graph for this function:

Here is the caller graph for this function:

struct opd_image* opd_get_kernel_image ( char const *  name,
char const *  app_name,
pid_t  tid,
pid_t  tgid 
) [read]

opd_get_kernel_image - get a kernel image

Parameters:
name of image
app_name application owner of this kernel image. non-null only when separate_kernel_sample != 0
tid thread id
tgid thread group id

Create and initialise an image adding it to the image lists and to image hash list. Note than at creation reference count is zero, it's caller responsabilities to incr this count.

Definition at line 260 of file opd_image.c.

References opd_get_image().

Referenced by opd_add_kernel_map(), opd_get_module_info(), and opd_init_kernel_image().

Here is the call graph for this function:

Here is the caller graph for this function:

int opd_get_nr_images ( void   ) 

opd_get_nr_images - return number of images

Definition at line 43 of file opd_image.c.

References nr_images.

Referenced by opd_print_24_stats().

Here is the caller graph for this function:

static size_t opd_hash_image ( char const *  name,
pid_t  tid,
pid_t  tgid 
) [static]

opd_hash_image - hash an image

Parameters:
hash hash of image name
tid thread id
tgid thread group id

return the hash code for the passed parameters

Definition at line 103 of file opd_image.c.

References op_hash_string(), OPD_IMAGE_HASH_SIZE, and separate_thread.

Referenced by opd_find_image(), and opd_new_image().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_init_images ( void   ) 

initialize opd_image container

Definition at line 35 of file opd_image.c.

References list_init(), OPD_IMAGE_HASH_SIZE, and opd_images.

Referenced by opd_24_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct opd_image* opd_new_image ( char const *  name,
char const *  app_name,
int  kernel,
pid_t  tid,
pid_t  tgid 
) [static, read]

opd_new_image - create an image sample file

Parameters:
app_name the application name where belongs this image
name name of the image to add
kernel is the image a kernel/module image
tid thread id
tgid thread group id

image at funtion entry is uninitialised name is copied i.e. should be GC'd separately from the image structure if appropriate.

Initialise an opd_image struct for the image image without opening the associated samples files. At return the image is fully initialized.

Definition at line 129 of file opd_image.c.

References opd_image::app_name, opd_image::hash_next, opd_image::ignored, is_image_ignored(), opd_image::kernel, list_add(), list_init(), opd_image::mtime, opd_image::name, NR_CPUS, nr_images, op_get_mtime(), opd_hash_image(), opd_images, opd_image::ref_count, separate_lib, opd_image::sfiles, opd_image::tgid, opd_image::tid, verbprintf, and vmisc.

Referenced by opd_get_image().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int nr_images [static]

Definition at line 28 of file opd_image.c.

Referenced by opd_delete_image(), opd_get_nr_images(), and opd_new_image().

struct list_head opd_images[OPD_IMAGE_HASH_SIZE] [static]

Definition at line 32 of file opd_image.c.

Referenced by opd_find_image(), opd_for_each_image(), opd_init_images(), and opd_new_image().


Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1