00001 /** 00002 * @file opd_mapping.h 00003 * Management of process mappings 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_MAPPING_H 00013 #define OPD_MAPPING_H 00014 00015 #include "op_list.h" 00016 00017 struct opd_image; 00018 struct opd_proc; 00019 struct op_note; 00020 00021 /** 00022 * represent a mmap'ed area, we create such area only for vma area with exec 00023 * access right 00024 */ 00025 struct opd_map { 00026 /** next mapping for this image */ 00027 struct list_head next; 00028 /** owning image */ 00029 struct opd_image * image; 00030 /** mapping start vma */ 00031 unsigned long start; 00032 /** mapping offset */ 00033 unsigned long offset; 00034 /** mapping end vma */ 00035 unsigned long end; 00036 }; 00037 00038 /** 00039 * opd_init_hash_map - initialise the hashmap 00040 */ 00041 void opd_init_hash_map(void); 00042 00043 /** 00044 * op_cleanup_hash_name 00045 * 00046 * release resource owned by hash_name array 00047 */ 00048 void opd_cleanup_hash_name(void); 00049 00050 /** 00051 * opd_handle_mapping - deal with mapping notification 00052 * @param note mapping notification 00053 * 00054 * Deal with one notification that a process has mapped 00055 * in a new executable file. The mapping information is 00056 * added to the process structure. 00057 */ 00058 void opd_handle_mapping(struct op_note const * note); 00059 00060 /** 00061 * opd_put_mapping - add a mapping to a process 00062 * @param proc process to add map to 00063 * @param image mapped image pointer 00064 * @param start start of mapping 00065 * @param offset file offset of mapping 00066 * @param end end of mapping 00067 * 00068 * Add the mapping specified to the process proc growing the maps array 00069 * if necessary. 00070 */ 00071 void opd_add_mapping(struct opd_proc * proc, struct opd_image * image, 00072 unsigned long start, unsigned long offset, unsigned long end); 00073 00074 /** 00075 * opd_kill_maps - delete mapping information for a process 00076 * @param proc process to work on 00077 * 00078 * Frees structures holding mapping information 00079 */ 00080 void opd_kill_maps(struct opd_proc * proc); 00081 00082 /** 00083 * opd_is_in_map - check whether an EIP is within a mapping 00084 * @param map map to check 00085 * @param eip EIP value 00086 * 00087 * Return %1 if the EIP value @eip is within the boundaries 00088 * of the map @map, %0 otherwise. 00089 */ 00090 inline static int opd_is_in_map(struct opd_map * map, unsigned long eip) 00091 { 00092 return (eip >= map->start && eip < map->end); 00093 } 00094 00095 00096 /* 00097 * opd_map_offset - return offset of sample against map 00098 * @param map map to use 00099 * @param eip EIP value to use 00100 * 00101 * Returns the offset of the EIP value @eip into 00102 * the map @map, which is the same as the file offset 00103 * for the relevant binary image. 00104 */ 00105 inline static unsigned long opd_map_offset(struct opd_map * map, 00106 unsigned long eip) 00107 { 00108 return (eip - map->start) + map->offset; 00109 } 00110 00111 #endif /* OPD_MAPPING_H */
1.6.1