File indexing completed on 2026-05-10 08:43:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef LLVM_EXECUTIONENGINE_OPROFILEWRAPPER_H
0020 #define LLVM_EXECUTIONENGINE_OPROFILEWRAPPER_H
0021
0022 #include "llvm/Support/DataTypes.h"
0023 #include <opagent.h>
0024
0025 namespace llvm {
0026
0027
0028 class OProfileWrapper {
0029 typedef op_agent_t (*op_open_agent_ptr_t)();
0030 typedef int (*op_close_agent_ptr_t)(op_agent_t);
0031 typedef int (*op_write_native_code_ptr_t)(op_agent_t,
0032 const char*,
0033 uint64_t,
0034 void const*,
0035 const unsigned int);
0036 typedef int (*op_write_debug_line_info_ptr_t)(op_agent_t,
0037 void const*,
0038 size_t,
0039 struct debug_line_info const*);
0040 typedef int (*op_unload_native_code_ptr_t)(op_agent_t, uint64_t);
0041
0042
0043 typedef int (*op_major_version_ptr_t)();
0044
0045
0046 typedef bool (*IsOProfileRunningPtrT)();
0047
0048
0049 op_agent_t Agent;
0050 op_open_agent_ptr_t OpenAgentFunc;
0051 op_close_agent_ptr_t CloseAgentFunc;
0052 op_write_native_code_ptr_t WriteNativeCodeFunc;
0053 op_write_debug_line_info_ptr_t WriteDebugLineInfoFunc;
0054 op_unload_native_code_ptr_t UnloadNativeCodeFunc;
0055 op_major_version_ptr_t MajorVersionFunc;
0056 op_major_version_ptr_t MinorVersionFunc;
0057 IsOProfileRunningPtrT IsOProfileRunningFunc;
0058
0059 bool Initialized;
0060
0061 public:
0062 OProfileWrapper();
0063
0064
0065
0066 OProfileWrapper(op_open_agent_ptr_t OpenAgentImpl,
0067 op_close_agent_ptr_t CloseAgentImpl,
0068 op_write_native_code_ptr_t WriteNativeCodeImpl,
0069 op_write_debug_line_info_ptr_t WriteDebugLineInfoImpl,
0070 op_unload_native_code_ptr_t UnloadNativeCodeImpl,
0071 op_major_version_ptr_t MajorVersionImpl,
0072 op_major_version_ptr_t MinorVersionImpl,
0073 IsOProfileRunningPtrT MockIsOProfileRunningImpl = 0)
0074 : OpenAgentFunc(OpenAgentImpl),
0075 CloseAgentFunc(CloseAgentImpl),
0076 WriteNativeCodeFunc(WriteNativeCodeImpl),
0077 WriteDebugLineInfoFunc(WriteDebugLineInfoImpl),
0078 UnloadNativeCodeFunc(UnloadNativeCodeImpl),
0079 MajorVersionFunc(MajorVersionImpl),
0080 MinorVersionFunc(MinorVersionImpl),
0081 IsOProfileRunningFunc(MockIsOProfileRunningImpl),
0082 Initialized(true)
0083 {
0084 }
0085
0086
0087
0088
0089
0090 bool op_open_agent();
0091
0092 int op_close_agent();
0093 int op_write_native_code(const char* name,
0094 uint64_t addr,
0095 void const* code,
0096 const unsigned int size);
0097 int op_write_debug_line_info(void const* code,
0098 size_t num_entries,
0099 struct debug_line_info const* info);
0100 int op_unload_native_code(uint64_t addr);
0101 int op_major_version();
0102 int op_minor_version();
0103
0104
0105
0106
0107 bool isAgentAvailable();
0108
0109 private:
0110
0111
0112 bool initialize();
0113
0114
0115
0116 bool checkForOProfileProcEntry();
0117
0118 bool isOProfileRunning();
0119 };
0120
0121 }
0122
0123 #endif