18 #include "llvm/Config/config.h" 35 #define DEBUG_TYPE "amplifier-jit-event-listener" 42 std::unique_ptr<IntelJITEventsWrapper>
Wrapper;
43 MethodIDMap MethodIDs;
48 ObjectMap LoadedObjectMap;
49 std::map<ObjectKey, OwningBinary<ObjectFile>> DebugObjects;
53 Wrapper.reset(libraryWrapper);
56 ~IntelJITEventListener() {
62 void notifyFreeingObject(ObjectKey Key)
override;
65 static LineNumberInfo DILineInfoToIntelJITFormat(uintptr_t StartAddress,
70 Result.
Offset = Address - StartAddress;
98 void IntelJITEventListener::notifyObjectLoaded(
110 MethodAddressVector Functions;
115 std::vector<LineNumberInfo> LineInfo;
116 std::string SourceFileName;
141 uint64_t Addr = *AddrOrErr;
142 uint64_t
Size =
P.second;
153 uint64_t
Index = Sec->getIndex();
156 Functions.push_back((
void*)Addr);
160 FunctionDescToIntelJITFormat(*Wrapper, Name->data(), Addr,
Size);
162 Context->getLineInfoForAddressRange({Addr, Index},
Size);
167 DILineInfoToIntelJITFormat((uintptr_t)Addr, It->first, It->second));
169 if (LineInfo.size() == 0) {
182 LineInfo.push_back(last);
183 for (
size_t i = LineInfo.size() - 2; i > 0; --i)
184 LineInfo[i].LineNumber = LineInfo[i - 1].LineNumber;
186 SourceFileName = Lines.front().second.FileName;
188 const_cast<char *
>(SourceFileName.c_str());
195 MethodIDs[(
void*)Addr] = FunctionMessage.
method_id;
201 LoadedObjectMap[ObjData] = Functions;
202 DebugObjects[
Key] = std::move(DebugObjOwner);
205 void IntelJITEventListener::notifyFreeingObject(ObjectKey Key) {
208 if (DebugObjects.find(Key) == DebugObjects.end())
216 ObjectMap::iterator OI = LoadedObjectMap.find(ObjData);
217 if (OI == LoadedObjectMap.end())
219 MethodAddressVector& Functions = OI->second;
222 for (MethodAddressVector::iterator FI = Functions.begin(),
223 FE = Functions.end();
226 void* FnStart =
const_cast<void*
>(*FI);
227 MethodIDMap::iterator
MI = MethodIDs.find(FnStart);
228 if (MI != MethodIDs.end()) {
236 LoadedObjectMap.erase(OI);
237 DebugObjects.erase(Key);
250 return new IntelJITEventListener(TestImpl);
static JITEventListener * createIntelJITEventListener()
Information about the loaded object.
This class represents lattice values for constants.
Expected< StringRef > getName() const
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
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.
A format-neutral container for source line information.
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)
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
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)
virtual section_iterator section_end() const =0
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
StringRef getData() const