19 #include "llvm/Config/config.h" 36 #define DEBUG_TYPE "amplifier-jit-event-listener" 43 std::unique_ptr<IntelJITEventsWrapper>
Wrapper;
44 MethodIDMap MethodIDs;
49 ObjectMap LoadedObjectMap;
50 std::map<ObjectKey, OwningBinary<ObjectFile>> DebugObjects;
54 Wrapper.reset(libraryWrapper);
57 ~IntelJITEventListener() {
63 void notifyFreeingObject(ObjectKey Key)
override;
66 static LineNumberInfo DILineInfoToIntelJITFormat(uintptr_t StartAddress,
71 Result.
Offset = Address - StartAddress;
99 void IntelJITEventListener::notifyObjectLoaded(
111 MethodAddressVector Functions;
116 std::vector<LineNumberInfo> LineInfo;
117 std::string SourceFileName;
142 uint64_t Addr = *AddrOrErr;
143 uint64_t
Size =
P.second;
146 Functions.push_back((
void*)Addr);
150 FunctionDescToIntelJITFormat(*Wrapper, Name->data(), Addr,
Size);
151 DILineInfoTable Lines = Context->getLineInfoForAddressRange(Addr, Size);
156 DILineInfoToIntelJITFormat((uintptr_t)Addr, It->first, It->second));
158 if (LineInfo.size() == 0) {
171 LineInfo.push_back(last);
172 for (
size_t i = LineInfo.size() - 2; i > 0; --i)
173 LineInfo[i].LineNumber = LineInfo[i - 1].LineNumber;
175 SourceFileName = Lines.front().second.FileName;
177 const_cast<char *
>(SourceFileName.c_str());
184 MethodIDs[(
void*)Addr] = FunctionMessage.
method_id;
190 LoadedObjectMap[ObjData] = Functions;
191 DebugObjects[
Key] = std::move(DebugObjOwner);
194 void IntelJITEventListener::notifyFreeingObject(ObjectKey Key) {
197 if (DebugObjects.find(Key) == DebugObjects.end())
205 ObjectMap::iterator OI = LoadedObjectMap.find(ObjData);
206 if (OI == LoadedObjectMap.end())
208 MethodAddressVector& Functions = OI->second;
211 for (MethodAddressVector::iterator FI = Functions.begin(),
212 FE = Functions.end();
215 void* FnStart =
const_cast<void*
>(*FI);
216 MethodIDMap::iterator
MI = MethodIDs.find(FnStart);
217 if (MI != MethodIDs.end()) {
225 LoadedObjectMap.erase(OI);
226 DebugObjects.erase(Key);
239 return new IntelJITEventListener(TestImpl);
static JITEventListener * createIntelJITEventListener()
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.
Error takeError()
Take ownership of the stored error.
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).
A format-neutral container for source line information.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
amdgpu aa AMDGPU Address space based Alias Analysis Wrapper
pLineNumberInfo line_number_table
Tagged union holding either a T or a Error.
LLVMJITEventListenerRef LLVMCreateIntelJITEventListener(void)
void * method_load_address
unsigned int user_data_size
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
void consumeError(Error Err)
Consume a Error without doing anything.
static std::unique_ptr< DWARFContext > create(const object::ObjectFile &Obj, const LoadedObjectInfo *L=nullptr, function_ref< ErrorPolicy(Error)> HandleError=defaultErrorHandler, std::string DWPName="")
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)
Expected< SymbolRef::Type > getType() const
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)
typename SuperClass::iterator iterator
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
StringRef getData() const