00001 /** 00002 * @file opd_image.h 00003 * Management of binary images 00004 * 00005 * @remark Copyright 2002 OProfile authors 00006 * @remark Read the file COPYING 00007 * 00008 * @author John Levon 00009 * @author Philippe Elie 00010 */ 00011 00012 #ifndef OPD_IMAGE_H 00013 #define OPD_IMAGE_H 00014 00015 #include "op_list.h" 00016 #include "op_config_24.h" 00017 #include "op_types.h" 00018 00019 #include <time.h> 00020 00021 struct opd_24_sfile; 00022 00023 /** 00024 * A binary (library, application, kernel or module) 00025 * is represented by a struct opd_image. 00026 */ 00027 struct opd_image { 00028 /** used by container of opd_images */ 00029 struct list_head hash_next; 00030 /** how many time this opd_image is referenced */ 00031 int ref_count; 00032 /** all samples files belonging to this image */ 00033 struct opd_24_sfile ** sfiles[NR_CPUS]; 00034 /** name of this image */ 00035 char * name; 00036 /** the application name where belongs this image, NULL if image has 00037 * no owner (such as vmlinux or module) */ 00038 char * app_name; 00039 /** thread id, on 2.2 kernel always == to tgid */ 00040 pid_t tid; 00041 /** thread group id */ 00042 pid_t tgid; 00043 /** time of last modification */ 00044 time_t mtime; 00045 /** kernel image or not */ 00046 int kernel; 00047 /** non zero if this image must be profiled */ 00048 int ignored; 00049 }; 00050 00051 /** callback function passed to opd_for_each_image() */ 00052 typedef void (*opd_image_cb)(struct opd_image *); 00053 00054 /** 00055 * @param imagecb callback to apply onto each existing image struct 00056 * 00057 * the callback receive a struct opd_image * (not a const struct) and is 00058 * allowed to freeze the image struct itself. 00059 */ 00060 void opd_for_each_image(opd_image_cb imagecb); 00061 00062 /** 00063 * initialize opd_image container 00064 */ 00065 void opd_init_images(void); 00066 00067 /** 00068 * @param image the image pointer 00069 * 00070 * Decrement reference count of image, if reference count is zero flush and 00071 * close the samples files then freeze all memory belonging to this image. 00072 */ 00073 void opd_delete_image(struct opd_image * image); 00074 00075 /** 00076 * opd_get_kernel_image - get a kernel image 00077 * @param name of image 00078 * @param app_name application owner of this kernel image. non-null only 00079 * when separate_kernel_sample != 0 00080 * @param tid thread id 00081 * @param tgid thread group id 00082 * 00083 * Create and initialise an image adding it to the image lists and to image 00084 * hash list. Note than at creation reference count is zero, it's caller 00085 * responsabilities to incr this count. 00086 */ 00087 struct opd_image * opd_get_kernel_image(char const * name, 00088 char const * app_name, pid_t tid, pid_t tgid); 00089 00090 /** 00091 * opd_get_image - get an image from the image structure 00092 * @param name name of image 00093 * @param app_name the application name where belongs this image 00094 * @param kernel is the image a kernel/module image 00095 * @param tid thread id 00096 * @param tgid thread group id 00097 * 00098 * Get the image specified by the file name name from the 00099 * image structure. If it is not present, the image is 00100 * added to the structure. In either case, the image number 00101 * is returned. 00102 */ 00103 struct opd_image * opd_get_image(char const * name, char const * app_name, 00104 int kernel, pid_t tid, pid_t tgid); 00105 00106 /** 00107 * opd_get_nr_images - return number of images 00108 */ 00109 int opd_get_nr_images(void); 00110 00111 #endif /* OPD_IMAGE_H */
1.6.1