00001 /** 00002 * @file opagent.h 00003 * Interface to report symbol names and dynamically generated code to Oprofile 00004 * 00005 * @remark Copyright 2007 OProfile authors 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * @author Jens Wilke 00022 * @Modifications Daniel Hansel 00023 * 00024 * Copyright IBM Corporation 2007 00025 * 00026 */ 00027 00028 #ifndef _LIB_OPAGENT_H 00029 #define _LIB_OPAGENT_H 00030 00031 #include <sys/types.h> 00032 00033 #if defined(__cplusplus) 00034 extern "C" { 00035 #endif 00036 00037 struct debug_line_info { 00038 unsigned long vma; 00039 unsigned int lineno; 00040 /* The filename format is unspecified, absolute path, relative etc. */ 00041 char const * filename; 00042 }; 00043 00044 typedef void * op_agent_t; 00045 00046 /** 00047 * This function must be called by agents before any other function. 00048 * Creates and opens a JIT dump file in /var/lib/oprofile/jitdump 00049 * using the naming convention <process_id>.dump. 00050 * 00051 * Returns a valid op_agent_t handle or NULL. If NULL is returned, errno 00052 * is set to indicate the nature of the error. 00053 **/ 00054 op_agent_t op_open_agent(void); 00055 00056 /** 00057 * Frees all resources and closes open file handles. 00058 * 00059 * hdl: Handle returned from an earlier call to op_open_agent() 00060 * 00061 * Returns 0 on success; -1 otherwise. If -1 is returned, errno is 00062 * set to indicate the nature of the error. 00063 **/ 00064 int op_close_agent(op_agent_t hdl); 00065 00066 /** 00067 * Signal the dynamic generation of native code from a virtual machine. 00068 * Writes a JIT dump record to the open JIT dump file using 00069 * the passed information. 00070 * 00071 * hdl: Handle returned from an earlier call to op_open_agent() 00072 * symbol_name: The name of the symbol being dynamically compiled. 00073 * This name can (and should) contain all necessary 00074 * information to disambiguate it from symbols of the 00075 * same name; e.g., class, method signature. 00076 * vma: The virtual memory address of the executable code. 00077 * code: Pointer to the location of the compiled code. 00078 * Theoretically, this may be a different location from 00079 * that given by the vma argument. For some JIT compilers, 00080 * obtaining the code may be impractical. For this (or any other) 00081 * reason, the agent can choose to pass NULL for this paraemter. 00082 * If NULL is passed, no code will be copied into the JIT dump 00083 * file. 00084 * code_size: Size of the compiled code. 00085 * 00086 * Returns 0 on success; -1 otherwise. If -1 is returned, errno is 00087 * set to indicate the nature of the error. 00088 **/ 00089 int op_write_native_code(op_agent_t hdl, char const * symbol_name, 00090 uint64_t vma, void const * code, 00091 const unsigned int code_size); 00092 00093 /** 00094 * Add debug line information to a piece of code. An op_write_native_code() 00095 * with the same code pointer should have occurred before this call. It's not 00096 * necessary to provide one lineno information entry per machine instruction; 00097 * the array can contain hole. 00098 * 00099 * hdl: Handle returned from an earlier call to op_open_agent() 00100 * code: Pointer to the location of the code with debug info 00101 * nr_entry: Number of entries in compile_map 00102 * compile_map: Array of struct debug_line_info. See the JVMTI agent 00103 * library implementation for an example of what information 00104 * should be retrieved from a VM to fill out this data structure. 00105 * 00106 * Returns 0 on success; -1 otherwise. If -1 is returned, errno is 00107 * set to indicate the nature of the error. 00108 **/ 00109 int op_write_debug_line_info(op_agent_t hdl, void const * code, 00110 size_t nr_entry, 00111 struct debug_line_info const * compile_map); 00112 00113 /** 00114 * Signal the invalidation of native code from a virtual machine. 00115 * 00116 * hdl: Handle returned from an earlier call to op_open_agent() 00117 * vma: The virtual memory address of the compiled code being unloaded. 00118 * An op_write_native_code() with the same vma should have 00119 * occurred before this call. 00120 * 00121 * Returns 0 on success; -1 otherwise. If -1 is returned, errno is 00122 * set to indicate the nature of the error. 00123 **/ 00124 int op_unload_native_code(op_agent_t hdl, uint64_t vma); 00125 00126 /** 00127 * Returns the major version number of the libopagent library that will be used. 00128 **/ 00129 int op_major_version(void); 00130 00131 /** 00132 * Returns the minor version number of the libopagent library that will be used. 00133 **/ 00134 int op_minor_version(void); 00135 00136 /* idea how to post additional information for a piece of code. 00137 we use the code address as reference 00138 int op_write_loader_name(const void* code_addr, char const * loader_name); 00139 */ 00140 00141 #if defined(__cplusplus) 00142 } 00143 #endif 00144 00145 #endif
1.6.1