Permalink
Browse files

Add a missing_primitive probe

  • Loading branch information...
1 parent 4bc0866 commit 8543558a2e64ce100d270e53b28394a37fe41caf Evan Phoenix committed Sep 11, 2008
Showing with 38 additions and 6 deletions.
  1. +27 −3 vm/builtin/taskprobe.cpp
  2. +8 −0 vm/builtin/taskprobe.hpp
  3. +3 −3 vm/codegen/field_extract.rb
@@ -65,6 +65,8 @@ namespace rubinius {
return PROBE_EXECUTE_INSTRUCTION;
} else if(probe == PROBE_LOAD_RUNTIME_OP) {
return PROBE_LOAD_RUNTIME;
+ } else if(probe == PROBE_PRIMITIVES_OP) {
+ return PROBE_PRIMITIVES;
}
return 0;
@@ -123,9 +125,25 @@ namespace rubinius {
ctx->cm->name->to_str(task->state)->c_str() << "+" <<
std::right << std::setw(4) << ctx->ip << ": " <<
std::left << std::setw(30) <<
- InstructionSequence::get_instruction_name(op) << " " <<
- std::right << std::setw(4) << ctx->js.stack - ctx->stk << " " <<
- std::right << std::setw(10) << (void*) *ctx->js.stack << std::endl;
+ InstructionSequence::get_instruction_name(op) << " ";
+
+ int stack_pos = ctx->js.stack - ctx->stk;
+ std::cout << std::right << std::setw(4) << stack_pos;
+ if(stack_pos >= 0) {
+ std::cout << " " << std::right << std::setw(10) <<
+ (void*) *ctx->js.stack;
+ }
+
+ std::cout << std::endl;
+
+ if(stack_pos >= 0) {
+ OBJECT top = *ctx->js.stack;
+ if(top->reference_p()) {
+ ObjectPosition pos = task->state->om->validate_object(top);
+ assert(pos != cInWrongYoungHalf);
+ assert(pos != cUnknown);
+ }
+ }
}
}
@@ -135,6 +153,12 @@ namespace rubinius {
}
}
+ void TaskProbe::missing_primitive(STATE, std::string prim) {
+ if(enabled_p(PROBE_PRIMITIVES)) {
+ std::cout << "[Unable to resolve primitive: " << prim << "]" << std::endl;
+ }
+ }
+
void TaskProbe::Info::mark(OBJECT t, ObjectMark& mark) { }
}
@@ -13,6 +13,7 @@ namespace rubinius {
#define PROBE_LOOKUP_FAILED (1 << 2)
#define PROBE_EXECUTE_INSTRUCTION (1 << 3)
#define PROBE_LOAD_RUNTIME (1 << 4)
+#define PROBE_PRIMITIVES (1 << 5)
#define PROBE_ALL_OP "all"
#define PROBE_ALL1_OP "1"
@@ -21,6 +22,7 @@ namespace rubinius {
#define PROBE_LOOKUP_FAILED_OP "lookup_failed"
#define PROBE_EXECUTE_INSTRUCTION_OP "execute_instruction"
#define PROBE_LOAD_RUNTIME_OP "load_runtime"
+#define PROBE_PRIMITIVES_OP "primitives"
class Task;
class Module;
@@ -125,6 +127,12 @@ namespace rubinius {
*/
void load_runtime(STATE, std::string file);
+ /**
+ * Printns out the name of the primitive that couldn't be found.
+ * This probe must be enable via the PROBE env var.
+ */
+ void missing_primitive(STATE, std::string prim);
+
class Info : public TypeInfo {
public:
Info(object_type type): TypeInfo(type) { }
@@ -598,9 +598,9 @@ def parse_stream(f)
end
f.puts <<-EOF
-std::string msg = std::string(\"Unable to resolve primitive: \") +
- name->to_str(state)->byte_address();
-std::cout << msg << std::endl;
+ if(!G(current_task)->probe->nil_p()) {
+ G(current_task)->probe->missing_primitive(state, name->to_str(state)->c_str());
+ }
return &Primitives::unknown_primitive;
// commented out while we have soft primitive failures
// throw std::runtime_error(msg.c_str());

0 comments on commit 8543558

Please sign in to comment.