15 #include "llvm/Config/config.h"
33 using namespace llvm::object;
35 #define DEBUG_TYPE "amplifier-jit-event-listener"
42 std::unique_ptr<IntelJITEventsWrapper>
Wrapper;
43 MethodIDMap MethodIDs;
48 ObjectMap LoadedObjectMap;
49 std::map<const char*, OwningBinary<ObjectFile>> DebugObjects;
56 ~IntelJITEventListener() {
59 void NotifyObjectEmitted(
const ObjectFile &Obj,
62 void NotifyFreeingObject(
const ObjectFile &Obj)
override;
65 static LineNumberInfo DILineInfoToIntelJITFormat(uintptr_t StartAddress,
70 Result.
Offset = Address - StartAddress;
98 void IntelJITEventListener::NotifyObjectEmitted(
108 MethodAddressVector Functions;
113 std::vector<LineNumberInfo> LineInfo;
114 std::string SourceFileName;
139 uint64_t Addr = *AddrOrErr;
140 uint64_t Size =
P.second;
143 Functions.push_back((
void*)Addr);
147 FunctionDescToIntelJITFormat(*Wrapper, Name->data(), Addr, Size);
153 DILineInfoToIntelJITFormat((uintptr_t)Addr, It->first, It->second));
155 if (LineInfo.size() == 0) {
168 LineInfo.push_back(last);
169 for (
size_t i = LineInfo.size() - 2;
i > 0; --
i)
170 LineInfo[
i].LineNumber = LineInfo[
i - 1].LineNumber;
172 SourceFileName = Lines.front().second.FileName;
174 const_cast<char *
>(SourceFileName.c_str());
181 MethodIDs[(
void*)Addr] = FunctionMessage.
method_id;
187 LoadedObjectMap[ObjData] = Functions;
188 DebugObjects[Obj.
getData().
data()] = std::move(DebugObjOwner);
191 void IntelJITEventListener::NotifyFreeingObject(
const ObjectFile &Obj) {
194 if (DebugObjects.find(Obj.
getData().
data()) == DebugObjects.end())
202 ObjectMap::iterator OI = LoadedObjectMap.find(ObjData);
203 if (OI == LoadedObjectMap.end())
205 MethodAddressVector& Functions = OI->second;
208 for (MethodAddressVector::iterator FI = Functions.begin(),
209 FE = Functions.end();
212 void* FnStart =
const_cast<void*
>(*FI);
213 MethodIDMap::iterator
MI = MethodIDs.find(FnStart);
214 if (MI != MethodIDs.end()) {
222 LoadedObjectMap.erase(OI);
236 return new IntelJITEventListener(TestImpl);
static JITEventListener * createIntelJITEventListener()
Information about the loaded object.
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.
Error takeError()
Take ownership of the stored error.
DILineInfo - a format-neutral container for source line information.
pLineNumberInfo line_number_table
StringRef getData() const
Tagged union holding either a T or a Error.
Expected< SymbolRef::Type > getType() const
DWARFContextInMemory is the simplest possible implementation of a DWARFContext.
void * method_load_address
static const unsigned End
unsigned int user_data_size
void consumeError(Error Err)
Consume a Error without doing anything.
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
unsigned int line_number_size
int iJIT_NotifyEvent(iJIT_JVM_EVENT EventType, void *EventSpecificData)
virtual object::OwningBinary< object::ObjectFile > getObjectForDebug(const object::ObjectFile &Obj) const =0
unsigned int iJIT_GetNewMethodID(void)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
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...
virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address, uint64_t Size, DILineInfoSpecifier Specifier=DILineInfoSpecifier())=0
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).