Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added gdb rps for simple show. Fixups for TypeInfo::show helpers.

  • Loading branch information...
commit b7f342ce6b051b5ca9d9ed9efa0d6354d9fed658 1 parent ac089cf
@brixen brixen authored
View
4 .gdbinit
@@ -5,3 +5,7 @@ end
define rp
p __show__($arg0)
end
+
+define rps
+p __show_simple__($arg0)
+end
View
4 vm/builtin/array.cpp
@@ -141,14 +141,14 @@ namespace rubinius {
size_t size = ary->size();
size_t stop = size < 5 ? size : 5;
- class_info(self);
+ class_info(state, self);
std::cout << ": " << size << "\n";
++level;
for(size_t i = 0; i < stop; i++) {
indent(level);
OBJECT obj = ary->get(state, i);
if(obj == ary) {
- class_info(obj, true);
+ class_info(state, obj, true);
} else {
obj->show(state, level);
}
View
2  vm/builtin/block_environment.cpp
@@ -110,7 +110,7 @@ namespace rubinius {
void BlockEnvironment::Info::show(STATE, OBJECT self, int level) {
BlockEnvironment* be = as<BlockEnvironment>(self);
- class_header(self);
+ class_header(state, self);
indent(++level); std::cout << "home: "; be->home->show(state, level);
indent(level); std::cout << "home_block: "; be->home_block->show(state, level);
indent(level); std::cout << "local_count: "; be->local_count->show(state, level);
View
2  vm/builtin/compactlookuptable.cpp
@@ -88,7 +88,7 @@ namespace rubinius {
Array* keys = tbl->keys(state);
size_t size = keys->size();
- class_info(self);
+ class_info(state, self);
std::cout << ": " << size << "\n";
indent(level+1);
for(size_t i = 0; i < size; i++) {
View
2  vm/builtin/compiledmethod.cpp
@@ -115,7 +115,7 @@ namespace rubinius {
void CompiledMethod::Info::show(STATE, OBJECT self, int level) {
CompiledMethod* cm = as<CompiledMethod>(self);
- class_header(self);
+ class_header(state, self);
indent(++level); std::cout << "exceptions: "; cm->exceptions->show(state, level);
indent(level); std::cout << "file: "; cm->file->show(state, level);
indent(level); std::cout << "iseq: "; cm->iseq->show(state, level);
View
6 vm/builtin/contexts.cpp
@@ -237,19 +237,19 @@ namespace rubinius {
void MethodContext::Info::show(STATE, OBJECT self, int level) {
MethodContext* ctx = as<MethodContext>(self);
- class_header(self);
+ class_header(state, self);
indent(++level); std::cout << "name: "; ctx->name->show(state, level);
indent(level); std::cout << "sender: ";
if(ctx->sender == Qnil) {
std::cout << "nil\n";
} else {
- class_info(ctx->sender, true);
+ class_info(state, ctx->sender, true);
}
indent(level); std::cout << "home: ";
if(ctx->home == Qnil) {
std::cout << "nil\n";
} else {
- class_info(ctx->home, true);
+ class_info(state, ctx->home, true);
}
indent(level); std::cout << "self: "; ctx->self->show(state, level);
indent(level); std::cout << "cm: "; ctx->cm->show(state, level);
View
2  vm/builtin/lookuptable.cpp
@@ -298,7 +298,7 @@ namespace rubinius {
size_t size = tbl->entries->to_native();
Array* keys = tbl->all_keys(state);
- class_info(self);
+ class_info(state, self);
std::cout << ": " << size << "\n";
indent(level+1);
for(size_t i = 0; i < size; i++) {
View
2  vm/builtin/methodvisibility.cpp
@@ -16,7 +16,7 @@ namespace rubinius {
void MethodVisibility::Info::show(STATE, OBJECT self, int level) {
MethodVisibility* mv = as<MethodVisibility>(self);
- class_header(self);
+ class_header(state, self);
indent(++level); std::cout << "visibility: "; mv->visibility->show(state, level);
indent(level); std::cout << "method: "; mv->method->show(state, level);
indent(--level); std::cout << ">\n";
View
5 vm/builtin/object.cpp
@@ -545,6 +545,11 @@ namespace rubinius {
return Qnil;
}
+ OBJECT Object::show_simple(STATE) {
+ type_info(state)->class_info(state, this, true);
+ return Qnil;
+ }
+
/* VM level primitives. This is a silly place, I know. */
OBJECT Object::vm_get_config_item(STATE, String* var) {
ConfigParser::Entry* ent = state->user_config->find(var->c_str());
View
1  vm/builtin/object.hpp
@@ -33,6 +33,7 @@ namespace rubinius {
// Ruby.primitive :object_show
OBJECT show(STATE);
OBJECT show(STATE, int indent);
+ OBJECT show_simple(STATE);
bool fixnum_p();
bool symbol_p();
View
4 vm/builtin/tuple.cpp
@@ -133,14 +133,14 @@ namespace rubinius {
size_t size = tup->field_count;
size_t stop = size < 5 ? size : 5;
- class_info(self);
+ class_info(state, self);
std::cout << ": " << size << "\n";
++level;
for(size_t i = 0; i < stop; i++) {
indent(level);
OBJECT obj = tup->at(i);
if(obj == tup) {
- class_info(self, true);
+ class_info(state, self, true);
} else {
obj->show(state, level);
}
View
25 vm/type_info.cpp
@@ -66,9 +66,15 @@ namespace rubinius {
*
* #<SomeClass:0x346882
*/
- void TypeInfo::class_info(OBJECT self, bool newline) {
- std::cout << "#<" << self->class_object(state)->name->c_str(state) <<
- ":" << (void*) self;
+ void TypeInfo::class_info(STATE, OBJECT self, bool newline) {
+ if(Module* mod = try_as<Module>(self)) {
+ const char *name = mod->name == Qnil ? "<anonymous>" : mod->name->c_str(state);
+ std::cout << "#<" << name << "(" <<
+ self->class_object(state)->name->c_str(state) << ")";
+ } else {
+ std::cout << "#<" << self->class_object(state)->name->c_str(state);
+ }
+ std::cout << ":" << (void*)self;
if(newline) std::cout << ">\n";
}
@@ -78,9 +84,9 @@ namespace rubinius {
*
* #<SomeClass:0x3287648\n
*/
- void TypeInfo::class_header(OBJECT self) {
- std::cout << "#<" << self->class_object(state)->name->c_str(state) <<
- ":" << (void*) self << "\n";
+ void TypeInfo::class_header(STATE, OBJECT self) {
+ class_info(state, self);
+ std::cout << "\n";
}
/**
@@ -101,7 +107,7 @@ namespace rubinius {
* and address.
*/
void TypeInfo::show(STATE, OBJECT self, int level) {
- class_info(self, true);
+ class_info(state, self, true);
}
#include "gen/typechecks.gen.cpp"
@@ -111,5 +117,10 @@ namespace rubinius {
void __show__(OBJECT obj) {
obj->show(VM::current_state());
}
+
+ /* Similar to __show__ but only outputs #<SomeClass:0x2428999> */
+ void __show_simple__(OBJECT obj) {
+ obj->show_simple(VM::current_state());
+ }
}
}
View
4 vm/type_info.hpp
@@ -38,8 +38,8 @@ namespace rubinius {
virtual OBJECT get_field(STATE, OBJECT target, size_t index);
virtual void show(STATE, OBJECT self, int level);
virtual void indent(int level);
- virtual void class_info(OBJECT self, bool newline = false);
- virtual void class_header(OBJECT self);
+ virtual void class_info(STATE, OBJECT self, bool newline = false);
+ virtual void class_header(STATE, OBJECT self);
};
#define BASIC_TYPEINFO(super) \
Please sign in to comment.
Something went wrong with that request. Please try again.