16 #include "llvm/Config/config.h" 34 #define DEBUG_TYPE "oprofile-jit-event-listener" 39 std::unique_ptr<OProfileWrapper>
Wrapper;
42 std::map<ObjectKey, OwningBinary<ObjectFile>> DebugObjects;
45 OProfileJITEventListener(std::unique_ptr<OProfileWrapper> LibraryWrapper)
50 ~OProfileJITEventListener();
55 void notifyFreeingObject(ObjectKey
Key)
override;
59 if (!
Wrapper->op_open_agent()) {
61 LLVM_DEBUG(
dbgs() <<
"Failed to connect to OProfile agent: " << err_str
68 OProfileJITEventListener::~OProfileJITEventListener() {
69 if (
Wrapper->isAgentAvailable()) {
70 if (
Wrapper->op_close_agent() == -1) {
80 void OProfileJITEventListener::notifyObjectLoaded(
83 if (!
Wrapper->isAgentAvailable()) {
104 uint64_t
Addr = *AddrOrErr;
105 uint64_t
Size =
P.second;
109 LLVM_DEBUG(
dbgs() <<
"Failed to tell OProfile about native function " 110 <<
Name <<
" at [" << (
void *)
Addr <<
"-" 117 size_t num_entries = Lines.size();
118 struct debug_line_info *debug_line;
119 debug_line = (
struct debug_line_info *)calloc(
120 num_entries,
sizeof(
struct debug_line_info));
122 for (
auto& It : Lines) {
123 debug_line[i].vma = (
unsigned long)It.first;
124 debug_line[i].lineno = It.second.Line;
125 debug_line[i].filename =
126 const_cast<char *>(Lines.front().second.FileName.c_str());
130 if (
Wrapper->op_write_debug_line_info((
void *)
Addr, num_entries,
132 LLVM_DEBUG(
dbgs() <<
"Failed to tell OProfiler about debug object at [" 142 void OProfileJITEventListener::notifyFreeingObject(ObjectKey
Key) {
143 if (
Wrapper->isAgentAvailable()) {
147 if (DebugObjects.find(
Key) == DebugObjects.end())
160 uint64_t
Addr = *AddrOrErr;
165 <<
"Failed to tell OProfile about unload of native function at " 166 << (
void *)
Addr <<
"\n");
173 DebugObjects.erase(
Key);
180 return new OProfileJITEventListener(std::make_unique<OProfileWrapper>());
Information about the loaded object.
This class represents lattice values for constants.
Expected< StringRef > getName() const
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
This class is the base class for all object file types.
virtual basic_symbol_iterator symbol_begin() const =0
amdgpu aa AMDGPU Address space based Alias Analysis Wrapper
std::string StrError()
Returns a string representation of the errno value, using whatever thread-safe variant of strerror() ...
LLVMJITEventListenerRef LLVMCreateOProfileJITEventListener(void)
Tagged union holding either a T or a Error.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
virtual basic_symbol_iterator symbol_end() const =0
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
static std::unique_ptr< DWARFContext > create(const object::ObjectFile &Obj, const LoadedObjectInfo *L=nullptr, std::string DWPName="", std::function< void(Error)> RecoverableErrorHandler=WithColor::defaultErrorHandler, std::function< void(Error)> WarningHandler=WithColor::defaultWarningHandler)
virtual object::OwningBinary< object::ObjectFile > getObjectForDebug(const object::ObjectFile &Obj) const =0
Expected< SymbolRef::Type > getType() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
std::vector< std::pair< SymbolRef, uint64_t > > computeSymbolSizes(const ObjectFile &O)
This is a value type class that represents a single symbol in the list of symbols in the object file.
LLVMAttributeRef wrap(Attribute Attr)
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
StringRef - Represent a constant reference to a string, i.e.
static JITEventListener * createOProfileJITEventListener()