Minor fixes and debug helpers to track externs.
This commit is contained in:
@@ -89,6 +89,7 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info) {
|
||||
MarkLabel(label);
|
||||
}
|
||||
|
||||
Instr* first_instr = 0;
|
||||
if (FLAGS_annotate_disassembly) {
|
||||
if (label) {
|
||||
AnnotateLabel(address, label);
|
||||
@@ -104,14 +105,20 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info) {
|
||||
} else {
|
||||
Comment("%.8X %.8X %s ???", address, i.code, i.type->name);
|
||||
}
|
||||
first_instr = last_instr();
|
||||
}
|
||||
|
||||
// Mark source offset for debugging.
|
||||
// We could omit this if we never wanted to debug.
|
||||
SourceOffset(i.address);
|
||||
if (!first_instr) {
|
||||
first_instr = last_instr();
|
||||
}
|
||||
|
||||
// Stash instruction offset. It's either the SOURCE_OFFSET or the COMMENT.
|
||||
instr_offset_list_[offset] = first_instr;
|
||||
|
||||
if (!i.type) {
|
||||
instr_offset_list_[offset] = prev_instr->next;
|
||||
XELOGCPU("Invalid instruction %.8X %.8X", i.address, i.code);
|
||||
Comment("INVALID!");
|
||||
//TraceInvalidInstruction(i);
|
||||
@@ -136,22 +143,6 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info) {
|
||||
// This printf is handy for sort/uniquify to find instructions.
|
||||
printf("unimplinstr %s\n", i.type->name);
|
||||
}
|
||||
|
||||
// Stash instruction offset. We do this down here so that if the function
|
||||
// splits blocks we don't have weird pointers.
|
||||
if (prev_instr && prev_instr->next) {
|
||||
instr_offset_list_[offset] = prev_instr->next;
|
||||
} else if (prev_instr) {
|
||||
instr_offset_list_[offset] = prev_instr->block->next->instr_head;
|
||||
} else if (current_block_) {
|
||||
instr_offset_list_[offset] = current_block_->instr_head;
|
||||
} else if (block_tail_) {
|
||||
instr_offset_list_[offset] = block_tail_->instr_head;
|
||||
} else {
|
||||
XEASSERTALWAYS();
|
||||
}
|
||||
XEASSERT(instr_offset_list_[offset]->next->opcode == &OPCODE_TRAP_TRUE_info ||
|
||||
instr_offset_list_[offset]->next->src1.offset == i.address);
|
||||
}
|
||||
|
||||
return Finalize();
|
||||
|
||||
@@ -86,17 +86,25 @@ int Function::Call(ThreadState* thread_state, uint64_t return_address) {
|
||||
|
||||
ExternFunction::ExternFunction(
|
||||
uint64_t address, Handler handler, void* arg0, void* arg1) :
|
||||
name_(0),
|
||||
handler_(handler), arg0_(arg0), arg1_(arg1),
|
||||
Function(Function::EXTERN_FUNCTION, address) {
|
||||
}
|
||||
|
||||
ExternFunction::~ExternFunction() {
|
||||
if (name_) {
|
||||
xe_free(name_);
|
||||
}
|
||||
}
|
||||
|
||||
void ExternFunction::set_name(const char* name) {
|
||||
name_ = xestrdupa(name);
|
||||
}
|
||||
|
||||
int ExternFunction::CallImpl(ThreadState* thread_state,
|
||||
uint64_t return_address) {
|
||||
if (!handler_) {
|
||||
XELOGW("undefined extern call to %.8X", address());
|
||||
XELOGW("undefined extern call to %.8X %s", address(), name());
|
||||
return 0;
|
||||
}
|
||||
handler_(thread_state->raw_context(), arg0_, arg1_);
|
||||
|
||||
@@ -68,6 +68,9 @@ public:
|
||||
ExternFunction(uint64_t address, Handler handler, void* arg0, void* arg1);
|
||||
virtual ~ExternFunction();
|
||||
|
||||
const char* name() const { return name_; }
|
||||
void set_name(const char* name);
|
||||
|
||||
Handler handler() const { return handler_; }
|
||||
void* arg0() const { return arg0_; }
|
||||
void* arg1() const { return arg1_; }
|
||||
@@ -76,6 +79,7 @@ protected:
|
||||
virtual int CallImpl(ThreadState* thread_state, uint64_t return_address);
|
||||
|
||||
protected:
|
||||
char* name_;
|
||||
Handler handler_;
|
||||
void* arg0_;
|
||||
void* arg1_;
|
||||
|
||||
Reference in New Issue
Block a user