IntelJITEventListenerTest.cpp [plain text]
#include "JITEventListenerTestCommon.h"
using namespace llvm;
#include "../../../lib/ExecutionEngine/IntelJITEvents/IntelJITEventsWrapper.h"
#include <map>
#include <list>
namespace {
NativeCodeMap ReportedDebugFuncs;
}
namespace test_jitprofiling {
int NotifyEvent(iJIT_JVM_EVENT EventType, void *EventSpecificData) {
switch (EventType) {
case iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED: {
EXPECT_TRUE(0 != EventSpecificData);
iJIT_Method_Load* msg = static_cast<iJIT_Method_Load*>(EventSpecificData);
ReportedDebugFuncs[msg->method_id];
for(unsigned int i = 0; i < msg->line_number_size; ++i) {
EXPECT_TRUE(0 != msg->line_number_table);
std::pair<std::string, unsigned int> loc(
std::string(msg->source_file_name),
msg->line_number_table[i].LineNumber);
ReportedDebugFuncs[msg->method_id].push_back(loc);
}
}
break;
case iJVM_EVENT_TYPE_METHOD_UNLOAD_START: {
EXPECT_TRUE(0 != EventSpecificData);
unsigned int UnloadId
= *reinterpret_cast<unsigned int*>(EventSpecificData);
EXPECT_TRUE(1 == ReportedDebugFuncs.erase(UnloadId));
}
default:
break;
}
return 0;
}
iJIT_IsProfilingActiveFlags IsProfilingActive(void) {
return iJIT_SAMPLING_ON;
}
unsigned int GetNewMethodID(void) {
static unsigned int id = 0;
return ++id;
}
}
class IntelJITEventListenerTest
: public JITEventListenerTestBase<IntelJITEventsWrapper> {
public:
IntelJITEventListenerTest()
: JITEventListenerTestBase<IntelJITEventsWrapper>(
new IntelJITEventsWrapper(test_jitprofiling::NotifyEvent, 0,
test_jitprofiling::IsProfilingActive, 0, 0,
test_jitprofiling::GetNewMethodID))
{
EXPECT_TRUE(0 != MockWrapper);
Listener.reset(JITEventListener::createIntelJITEventListener(
MockWrapper.take()));
EXPECT_TRUE(0 != Listener);
EE->RegisterJITEventListener(Listener.get());
}
};
TEST_F(IntelJITEventListenerTest, NoDebugInfo) {
TestNoDebugInfo(ReportedDebugFuncs);
}
TEST_F(IntelJITEventListenerTest, SingleLine) {
TestSingleLine(ReportedDebugFuncs);
}
TEST_F(IntelJITEventListenerTest, MultipleLines) {
TestMultipleLines(ReportedDebugFuncs);
}
testing::Environment* const jit_env =
testing::AddGlobalTestEnvironment(new JITEnvironment);