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;
126 uint64_t Addr = *AddrOrErr;
127 uint64_t Size =
P.second;
130 Functions.push_back((
void*)Addr);
134 FunctionDescToIntelJITFormat(*Wrapper, Name->data(), Addr, Size);
140 DILineInfoToIntelJITFormat((uintptr_t)Addr, It->first, It->second));
142 if (LineInfo.size() == 0) {
155 LineInfo.push_back(last);
156 for (
size_t i = LineInfo.size() - 2; i > 0; --i)
157 LineInfo[i].LineNumber = LineInfo[i - 1].LineNumber;
159 SourceFileName = Lines.front().second.FileName;
161 const_cast<char *
>(SourceFileName.c_str());
168 MethodIDs[(
void*)Addr] = FunctionMessage.
method_id;
174 LoadedObjectMap[ObjData] = Functions;
175 DebugObjects[Obj.
getData().
data()] = std::move(DebugObjOwner);
178 void IntelJITEventListener::NotifyFreeingObject(
const ObjectFile &Obj) {
181 if (DebugObjects.find(Obj.
getData().
data()) == DebugObjects.end())
189 ObjectMap::iterator OI = LoadedObjectMap.find(ObjData);
190 if (OI == LoadedObjectMap.end())
192 MethodAddressVector& Functions = OI->second;
195 for (MethodAddressVector::iterator FI = Functions.begin(),
196 FE = Functions.end();
199 void* FnStart =
const_cast<void*
>(*FI);
200 MethodIDMap::iterator
MI = MethodIDs.find(FnStart);
201 if (MI != MethodIDs.end()) {
209 LoadedObjectMap.erase(OI);
223 return new IntelJITEventListener(TestImpl);
static JITEventListener * createIntelJITEventListener()
Information about the loaded object.
std::error_code getError() const
Represents either an error or a value T.
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.
DILineInfo - a format-neutral container for source line information.
pLineNumberInfo line_number_table
StringRef getData() const
SymbolRef::Type getType() const
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
DWARFContextInMemory is the simplest possible implementation of a DWARFContext.
void * method_load_address
unsigned int user_data_size
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
ErrorOr< StringRef > getName() const
ErrorOr< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.