WIP verify_callstack function
dumps callstack in reverse order so i can visually inspect that it matches the old forward walking logicdb4
parent
ef38688e87
commit
e2fafaed9c
|
@ -21,6 +21,55 @@ template<typename Iterator> void factor_vm::iterate_callstack_object(callstack *
|
|||
}
|
||||
}
|
||||
|
||||
inline void factor_vm::verify_callstack(context *ctx, cell pc)
|
||||
{
|
||||
if (pc == 0)
|
||||
{
|
||||
std::cout << "null return address" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *frame_top = (unsigned char*)ctx->callstack_top;
|
||||
cell addr = pc;
|
||||
|
||||
while(frame_top < (unsigned char*)ctx->callstack_bottom)
|
||||
{
|
||||
std::cout << std::endl;
|
||||
std::cout << "address " << (void*)addr << std::endl;
|
||||
code_block *owner = code->code_block_for_address(addr);
|
||||
std::cout << "owner " << (void*)owner->entry_point() << " ";
|
||||
print_obj(owner->owner);
|
||||
std::cout << std::endl;
|
||||
cell frame_size = owner->stack_frame_size_for_address(addr);
|
||||
std::cout << "frame size " << (void*)frame_size << std::endl;
|
||||
frame_top += frame_size;
|
||||
stack_frame *frame = (stack_frame*)frame_top - 1;
|
||||
if (owner->entry_point() != frame->entry_point)
|
||||
{
|
||||
std::cout << "unexpected frame owner " << (void*)frame->entry_point << " ";
|
||||
print_obj(((code_block*)frame->entry_point - 1)->owner);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
if (frame_size != frame->size)
|
||||
std::cout << "unexpected frame size " << frame->size << std::endl;
|
||||
// XXX x86
|
||||
addr = *(cell*)frame_top;
|
||||
}
|
||||
}
|
||||
|
||||
inline void factor_vm::verify_callstack(context *ctx)
|
||||
{
|
||||
/*
|
||||
std::cout << std::endl << std::endl
|
||||
<< "callstack " << (void*)ctx->callstack_top
|
||||
<< " to " << (void*)ctx->callstack_bottom << std::endl;
|
||||
|
||||
// XXX x86-centric
|
||||
cell return_address = *((cell*)ctx->callstack_top);
|
||||
verify_callstack(ctx, return_address);
|
||||
*/
|
||||
}
|
||||
|
||||
template<typename Iterator> void factor_vm::iterate_callstack(context *ctx, Iterator &iterator)
|
||||
{
|
||||
stack_frame *frame = ctx->callstack_bottom - 1;
|
||||
|
|
|
@ -247,6 +247,7 @@ void factor_vm::print_callstack()
|
|||
if (ctx)
|
||||
{
|
||||
stack_frame_printer printer(this);
|
||||
verify_callstack(ctx);
|
||||
iterate_callstack(ctx,printer);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -257,6 +257,7 @@ void factor_vm::scrub_context(context *ctx)
|
|||
{
|
||||
call_frame_scrubber scrubber(this,ctx);
|
||||
iterate_callstack(ctx,scrubber);
|
||||
verify_callstack(ctx);
|
||||
}
|
||||
|
||||
void factor_vm::scrub_contexts()
|
||||
|
|
|
@ -378,6 +378,7 @@ template<typename Fixup>
|
|||
void slot_visitor<Fixup>::visit_callstack(context *ctx)
|
||||
{
|
||||
call_frame_slot_visitor<Fixup> call_frame_visitor(parent,this);
|
||||
parent->verify_callstack(ctx);
|
||||
parent->iterate_callstack(ctx,call_frame_visitor);
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,11 @@ struct factor_vm
|
|||
{
|
||||
std::set<context *>::const_iterator begin = active_contexts.begin();
|
||||
std::set<context *>::const_iterator end = active_contexts.end();
|
||||
while(begin != end) iterate_callstack(*begin++,iter);
|
||||
while(begin != end)
|
||||
{
|
||||
verify_callstack(*begin);
|
||||
iterate_callstack(*begin++,iter);
|
||||
}
|
||||
}
|
||||
|
||||
// run
|
||||
|
@ -639,6 +643,8 @@ struct factor_vm
|
|||
void primitive_innermost_stack_frame_scan();
|
||||
void primitive_set_innermost_stack_frame_quot();
|
||||
void primitive_callstack_bounds();
|
||||
void verify_callstack(context *ctx);
|
||||
void verify_callstack(context *ctx, cell pc);
|
||||
template<typename Iterator> void iterate_callstack(context *ctx, Iterator &iterator);
|
||||
|
||||
// cpu-*
|
||||
|
|
Loading…
Reference in New Issue