HELP: callstack
{ $values { "callstack" callstack } }
-{ $description "Outputs a copy of the call stack contents, with the top of the stack at the end of the vector. The stack frame of the caller word is " { $emphasis "not" } " included." } ;
+{ $description "Outputs a copy of the call stack contents, with the top of the stack at the end of the vector. The stack frame of the caller word is " { $emphasis "not" } " included. Each group of three elements in the callstack is frame:"
+ { $list
+ "The first element is the executing word or quotation."
+ "The second element is the executing quotation."
+ "The third element is the offset in the executing quotation, or -1 if the offset can't be determined."
+ }
+} ;
HELP: set-callstack
{ $values { "callstack" callstack } }
return executing.value();
}
+/* If the code block is an unoptimized quotation, we can calculate the
+ scan offset. In all other cases -1 is returned. */
cell code_block::scan(factor_vm* vm, void* addr) const {
- switch (type()) {
- case code_block_unoptimized: {
- tagged<object> obj(owner);
- if (obj.type_p(WORD_TYPE))
- obj = obj.as<word>()->def;
-
- if (obj.type_p(QUOTATION_TYPE))
- return tag_fixnum(
- vm->quot_code_offset_to_scan(obj.value(), offset(addr)));
- else
- return false_object;
- }
- case code_block_optimized:
- case code_block_pic:
- return false_object;
- default:
- critical_error("Bad frame type", type());
- return false_object;
+ if (type() != code_block_unoptimized) {
+ return tag_fixnum(-1);
}
+
+ tagged<object> obj(owner);
+ if (obj.type_p(WORD_TYPE))
+ obj = obj.as<word>()->def;
+ if (!obj.type_p(QUOTATION_TYPE))
+ return tag_fixnum(-1);
+
+ cell ofs = offset(addr);
+ return tag_fixnum(vm->quot_code_offset_to_scan(obj.value(), ofs));
}
cell factor_vm::compute_entry_point_address(cell obj) {