Logging undefined extern calls.

This commit is contained in:
Ben Vanik 2014-02-01 00:12:36 -08:00
parent f4d0eb03bc
commit 68b5a0979e
1 changed files with 18 additions and 8 deletions

View File

@ -103,6 +103,12 @@ void Dummy() {
// //
} }
void UndefinedCallExtern(void* raw_context, FunctionInfo* symbol_info) {
XELOGW("undefined extern call to %.8X %s",
symbol_info->address(),
symbol_info->name());
}
uint64_t DynamicRegisterLoad(void* raw_context, uint32_t address) { uint64_t DynamicRegisterLoad(void* raw_context, uint32_t address) {
auto thread_state = *((ThreadState**)raw_context); auto thread_state = *((ThreadState**)raw_context);
auto cbs = thread_state->runtime()->access_callbacks(); auto cbs = thread_state->runtime()->access_callbacks();
@ -339,7 +345,10 @@ table->AddSequence(OPCODE_CALL_INDIRECT_TRUE, [](X64Emitter& e, Instr*& i) {
table->AddSequence(OPCODE_CALL_EXTERN, [](X64Emitter& e, Instr*& i) { table->AddSequence(OPCODE_CALL_EXTERN, [](X64Emitter& e, Instr*& i) {
auto symbol_info = i->src1.symbol_info; auto symbol_info = i->src1.symbol_info;
XEASSERT(symbol_info->behavior() == FunctionInfo::BEHAVIOR_EXTERN); XEASSERT(symbol_info->behavior() == FunctionInfo::BEHAVIOR_EXTERN);
XEASSERTNOTNULL(symbol_info->extern_handler()); if (!symbol_info->extern_handler()) {
e.mov(e.rdx, (uint64_t)symbol_info);
CallNative(e, UndefinedCallExtern);
} else {
// rdx = target host function // rdx = target host function
// r8 = arg0 // r8 = arg0
// r9 = arg1 // r9 = arg1
@ -347,6 +356,7 @@ table->AddSequence(OPCODE_CALL_EXTERN, [](X64Emitter& e, Instr*& i) {
e.mov(e.r8, (uint64_t)symbol_info->extern_arg0()); e.mov(e.r8, (uint64_t)symbol_info->extern_arg0());
e.mov(e.r9, (uint64_t)symbol_info->extern_arg1()); e.mov(e.r9, (uint64_t)symbol_info->extern_arg1());
TransitionToHost(e); TransitionToHost(e);
}
i = e.Advance(i); i = e.Advance(i);
return true; return true;
}); });