summaryrefslogtreecommitdiff
path: root/vm_dump.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-01 22:36:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-01 22:36:15 +0000
commita7b5c603b4747704d8ed7ce22c342649e88f6993 (patch)
tree9ec74b2215a215f0364e0ec3adec42bdb18405dc /vm_dump.c
parent1c4e92c1851d1027f22b64cdd6e4d40d212609b6 (diff)
* vm.c (vm_backtrace_each): now takes an iterator function.
* vm_core.h (rb_make_backtrace, rb_backtrace_each): added prototypes. * vm_dump.c (rb_vm_bugreport), vm_eval.c (rb_backtrace): gets rid of allocating objects. * vm_eval.c (rb_backtrace_each): new function which iterates over each backtrace info. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_dump.c')
-rw-r--r--vm_dump.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/vm_dump.c b/vm_dump.c
index 5bfd382..0a56d81 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -564,28 +564,27 @@ rb_vmdebug_thread_dump_state(VALUE self)
return Qnil;
}
-VALUE rb_make_backtrace(void);
+static int
+bugreport_backtrace(void *arg, const char *file, int line, const char *method)
+{
+ if (!*(int *)arg) {
+ fprintf(stderr, "-- Ruby level backtrace information"
+ "-----------------------------------------\n");
+ *(int *)arg = 1;
+ }
+ fprintf(stderr, "%s:%d:in `%s'\n", file, line, method);
+ return 0;
+}
void
rb_vm_bugreport(void)
{
- VALUE bt;
-
if (GET_THREAD()->vm) {
int i;
SDR();
- bt = rb_make_backtrace();
-
- if (bt) {
- fprintf(stderr, "-- Ruby level backtrace information"
- "-----------------------------------------\n");
-
- for (i = 0; i < RARRAY_LEN(bt); i++) {
- VALUE str = RARRAY_PTR(bt)[i];
- fprintf(stderr, "%s\n", RSTRING_PTR(str));
- }
- fprintf(stderr, "\n");
+ if (rb_backtrace_each(bugreport_backtrace, &i)) {
+ fputs("\n", stderr);
}
}