Skip to content
Browse files

Remove STATE argument from debug functions

use 'rbt' to get a ruby backtrace, and 'rp' to have the VM show an
object
  • Loading branch information...
1 parent 358411b commit bc4b80f33d6a9bf131555939304c3f6cd0c4cd53 Evan Phoenix committed Aug 26, 2008
Showing with 26 additions and 7 deletions.
  1. +2 −2 .gdbinit
  2. +1 −0 vm/compiled_file.cpp
  3. +2 −2 vm/type_info.cpp
  4. +15 −3 vm/vm.cpp
  5. +6 −0 vm/vm.hpp
View
4 .gdbinit
@@ -1,7 +1,7 @@
define rbt
-p machine_print_callstack(0)
+p __printbt__()
end
define rp
-p __show__(state, $arg0)
+p __show__($arg0)
end
View
1 vm/compiled_file.cpp
@@ -39,6 +39,7 @@ namespace rubinius {
Message msg(state);
msg.total_args = 0;
msg.recv = G(main);
+ msg.name = cm->name;
msg.module = G(object);
msg.name = cm->name;
View
4 vm/type_info.cpp
@@ -79,8 +79,8 @@ namespace rubinius {
/* For use in gdb. */
extern "C" {
/* A wrapper because gdb can't do virtual dispatch. */
- void __show__(STATE, OBJECT obj) {
- obj->show(state);
+ void __show__(OBJECT obj) {
+ obj->show(VM::current_state());
}
}
}
View
18 vm/vm.cpp
@@ -41,6 +41,8 @@ namespace rubinius {
VMLLVMMethod::init("vm/instructions.bc");
boot_threads();
+
+ VM::register_state(this);
}
VM::~VM() {
@@ -50,6 +52,17 @@ namespace rubinius {
llvm_cleanup();
}
+ // HACK so not thread safe or anything!
+ static VM* __state = NULL;
+
+ VM* VM::current_state() {
+ return __state;
+ }
+
+ void VM::register_state(VM *vm) {
+ __state = vm;
+ }
+
void VM::boot_threads() {
Thread* thr = Thread::create(this);
@@ -226,7 +239,6 @@ namespace rubinius {
if(kind_of<BlockContext>(ctx)) {
std::cout << "__block__";
} else {
- // HACK reports Object#[] instead of Hash::[], etc
if(MetaClass* meta = try_as<MetaClass>(ctx->module)) {
if(Module* mod = try_as<Module>(meta->attached_instance)) {
std::cout << mod->name->c_str(this) << ".";
@@ -262,8 +274,8 @@ namespace rubinius {
/* For debugging. */
extern "C" {
- void __printbt__(STATE) {
- state->print_backtrace();
+ void __printbt__() {
+ VM::current_state()->print_backtrace();
}
}
};
View
6 vm/vm.hpp
@@ -57,6 +57,12 @@ namespace rubinius {
VM(size_t bytes = default_bytes);
~VM();
+ // Returns the current VM state object.
+ static VM* current_state();
+
+ // Registers a VM* object as the current state.
+ static void register_state(VM*);
+
void bootstrap_class();
void bootstrap_ontology();
void bootstrap_symbol();

0 comments on commit bc4b80f

Please sign in to comment.
Something went wrong with that request. Please try again.