2006-12-31 10:02:22 -05:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
vm_dump.c -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 17:13:04 -05:00
|
|
|
Copyright (C) 2004-2007 Koichi Sasada
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#include "ruby/ruby.h"
|
|
|
|
#include "ruby/node.h"
|
2006-12-31 10:02:22 -05:00
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 00:25:46 -04:00
|
|
|
#include "vm_core.h"
|
2006-12-31 10:02:22 -05:00
|
|
|
#include "vm.h"
|
|
|
|
|
|
|
|
#define MAX_POSBUF 128
|
|
|
|
|
|
|
|
static void
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
int pc = -1, bp = -1, line = 0;
|
2008-05-31 23:23:50 -04:00
|
|
|
ptrdiff_t lfp = cfp->lfp - th->stack;
|
|
|
|
ptrdiff_t dfp = cfp->dfp - th->stack;
|
2006-12-31 10:02:22 -05:00
|
|
|
char lfp_in_heap = ' ', dfp_in_heap = ' ';
|
|
|
|
char posbuf[MAX_POSBUF+1];
|
|
|
|
|
|
|
|
const char *magic, *iseq_name = "-", *selfstr = "-", *biseq_name = "-";
|
|
|
|
VALUE tmp;
|
|
|
|
|
|
|
|
if (cfp->block_iseq != 0 && BUILTIN_TYPE(cfp->block_iseq) != T_NODE) {
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
biseq_name = ""; /* RSTRING(cfp->block_iseq->name)->ptr; */
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lfp < 0 || lfp > th->stack_size) {
|
2008-05-31 23:23:50 -04:00
|
|
|
lfp = (ptrdiff_t)cfp->lfp;
|
2006-12-31 10:02:22 -05:00
|
|
|
lfp_in_heap = 'p';
|
|
|
|
}
|
|
|
|
if (dfp < 0 || dfp > th->stack_size) {
|
2008-05-31 23:23:50 -04:00
|
|
|
dfp = (ptrdiff_t)cfp->dfp;
|
2006-12-31 10:02:22 -05:00
|
|
|
dfp_in_heap = 'p';
|
|
|
|
}
|
|
|
|
if (cfp->bp) {
|
|
|
|
bp = cfp->bp - th->stack;
|
|
|
|
}
|
|
|
|
|
2007-07-05 06:49:45 -04:00
|
|
|
switch (VM_FRAME_TYPE(cfp)) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case FRAME_MAGIC_TOP:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "TOP";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case FRAME_MAGIC_METHOD:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "METHOD";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case FRAME_MAGIC_CLASS:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "CLASS";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case FRAME_MAGIC_BLOCK:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "BLOCK";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case FRAME_MAGIC_FINISH:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "FINISH";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case FRAME_MAGIC_CFUNC:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "CFUNC";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case FRAME_MAGIC_PROC:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "PROC";
|
|
|
|
break;
|
|
|
|
case FRAME_MAGIC_LAMBDA:
|
|
|
|
magic = "LAMBDA";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case FRAME_MAGIC_IFUNC:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "IFUNC";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case FRAME_MAGIC_EVAL:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "EVAL";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
case 0:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "------";
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 00:25:10 -04:00
|
|
|
default:
|
2006-12-31 10:02:22 -05:00
|
|
|
magic = "(none)";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0) {
|
|
|
|
tmp = rb_inspect(cfp->self);
|
|
|
|
selfstr = StringValueCStr(tmp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
selfstr = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cfp->iseq != 0) {
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
if (RUBY_VM_IFUNC_P(cfp->iseq)) {
|
2006-12-31 10:02:22 -05:00
|
|
|
iseq_name = "<ifunc>";
|
|
|
|
}
|
|
|
|
else {
|
* eval_method.c: renamed from vm_method.c. "vm_method.c" is included
by "vm.c".
* vm_eval.c: added. Some codes are moved from "eval.c"
* common.mk: fix for above changes.
* compile.c: make a vm_eval(0)
* eval.c, eval_error.c, eval_intern.h, eval_jump.c, proc.c, vm.c,
id.c, id.h, vm_core.h, vm_dump.c, vm_evalbody.c, vm_insnhelper.c,
blockinlining.c: fix for above changes. and do some refactoring.
this changes improve rb_yield() performance.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 13:50:17 -04:00
|
|
|
int vm_get_sourceline(rb_control_frame_t *);
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
pc = cfp->pc - cfp->iseq->iseq_encoded;
|
|
|
|
iseq_name = RSTRING_PTR(cfp->iseq->name);
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 11:42:41 -04:00
|
|
|
line = vm_get_sourceline(cfp);
|
2006-12-31 10:02:22 -05:00
|
|
|
if (line) {
|
|
|
|
char fn[MAX_POSBUF+1];
|
2007-02-24 20:34:33 -05:00
|
|
|
snprintf(fn, MAX_POSBUF, "%s", RSTRING_PTR(cfp->iseq->filename));
|
2006-12-31 10:02:22 -05:00
|
|
|
snprintf(posbuf, MAX_POSBUF, "%s:%d", fn, line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (cfp->method_id) {
|
|
|
|
iseq_name = rb_id2name(cfp->method_id);
|
|
|
|
snprintf(posbuf, MAX_POSBUF, ":%s", rb_id2name(cfp->method_id));
|
|
|
|
line = -1;
|
|
|
|
}
|
|
|
|
|
2008-05-31 23:23:50 -04:00
|
|
|
fprintf(stderr, "c:%04td ",
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
(rb_control_frame_t *)(th->stack + th->stack_size) - cfp);
|
2006-12-31 10:02:22 -05:00
|
|
|
if (pc == -1) {
|
|
|
|
fprintf(stderr, "p:---- ");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "p:%04d ", pc);
|
|
|
|
}
|
2008-05-31 23:23:50 -04:00
|
|
|
fprintf(stderr, "s:%04td b:%04d ", cfp->sp - th->stack, bp);
|
|
|
|
fprintf(stderr, lfp_in_heap == ' ' ? "l:%06td " : "l:%06tx ", lfp % 10000);
|
|
|
|
fprintf(stderr, dfp_in_heap == ' ' ? "d:%06td " : "d:%06tx ", dfp % 10000);
|
2006-12-31 10:02:22 -05:00
|
|
|
fprintf(stderr, "%-6s ", magic);
|
|
|
|
if (line) {
|
|
|
|
fprintf(stderr, "%s", posbuf);
|
|
|
|
}
|
|
|
|
if (0) {
|
|
|
|
fprintf(stderr, " \t");
|
|
|
|
fprintf(stderr, "iseq: %-24s ", iseq_name);
|
|
|
|
fprintf(stderr, "self: %-24s ", selfstr);
|
|
|
|
fprintf(stderr, "%-1s ", biseq_name);
|
|
|
|
}
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
vm_stack_dump_raw(rb_thread_t *th, rb_control_frame_t *cfp)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-18 23:08:50 -04:00
|
|
|
#if 1
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE *sp = cfp->sp, *bp = cfp->bp;
|
|
|
|
VALUE *lfp = cfp->lfp;
|
|
|
|
VALUE *dfp = cfp->dfp;
|
|
|
|
VALUE *p, *st, *t;
|
|
|
|
|
|
|
|
fprintf(stderr, "-- stack frame ------------\n");
|
|
|
|
for (p = st = th->stack; p < sp; p++) {
|
2008-05-22 23:25:30 -04:00
|
|
|
fprintf(stderr, "%04ld (%p): %08"PRIxVALUE, (long)(p - st), p, *p);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
t = (VALUE *)*p;
|
|
|
|
if (th->stack <= t && t < sp) {
|
2008-05-22 23:25:30 -04:00
|
|
|
fprintf(stderr, " (= %ld)", (long)((VALUE *)GC_GUARDED_PTR_REF(t) - th->stack));
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (p == lfp)
|
|
|
|
fprintf(stderr, " <- lfp");
|
|
|
|
if (p == dfp)
|
|
|
|
fprintf(stderr, " <- dfp");
|
|
|
|
if (p == bp)
|
|
|
|
fprintf(stderr, " <- bp"); /* should not be */
|
|
|
|
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
2007-06-17 13:47:35 -04:00
|
|
|
#endif
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 11:42:41 -04:00
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
fprintf(stderr, "-- control frame ----------\n");
|
|
|
|
while ((void *)cfp < (void *)(th->stack + th->stack_size)) {
|
|
|
|
control_frame_dump(th, cfp);
|
|
|
|
cfp++;
|
|
|
|
}
|
|
|
|
fprintf(stderr, "---------------------------\n");
|
|
|
|
}
|
|
|
|
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-18 23:08:50 -04:00
|
|
|
void
|
|
|
|
vm_stack_dump_raw_current(void)
|
|
|
|
{
|
|
|
|
rb_thread_t *th = GET_THREAD();
|
|
|
|
vm_stack_dump_raw(th, th->cfp);
|
|
|
|
}
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
void
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
env_dump_raw(rb_env_t *env, VALUE *lfp, VALUE *dfp)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
fprintf(stderr, "-- env --------------------\n");
|
|
|
|
|
|
|
|
while (env) {
|
|
|
|
fprintf(stderr, "--\n");
|
|
|
|
for (i = 0; i < env->env_size; i++) {
|
|
|
|
fprintf(stderr, "%04d: %08lx (%p)", -env->local_size + i, env->env[i],
|
|
|
|
&env->env[i]);
|
|
|
|
if (&env->env[i] == lfp)
|
|
|
|
fprintf(stderr, " <- lfp");
|
|
|
|
if (&env->env[i] == dfp)
|
|
|
|
fprintf(stderr, " <- dfp");
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (env->prev_envval != 0) {
|
|
|
|
GetEnvPtr(env->prev_envval, env);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
env = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf(stderr, "---------------------------\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
proc_dump_raw(rb_proc_t *proc)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
rb_env_t *env;
|
2006-12-31 10:02:22 -05:00
|
|
|
char *selfstr;
|
|
|
|
VALUE val = rb_inspect(proc->block.self);
|
|
|
|
selfstr = StringValueCStr(val);
|
|
|
|
|
|
|
|
fprintf(stderr, "-- proc -------------------\n");
|
|
|
|
fprintf(stderr, "self: %s\n", selfstr);
|
|
|
|
GetEnvPtr(proc->envval, env);
|
|
|
|
env_dump_raw(env, proc->block.lfp, proc->block.dfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
stack_dump_th(VALUE thval)
|
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
rb_thread_t *th;
|
2006-12-31 10:02:22 -05:00
|
|
|
GetThreadPtr(thval, th);
|
|
|
|
vm_stack_dump_raw(th, th->cfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
VALUE rstr;
|
|
|
|
VALUE *sp = cfp->sp;
|
|
|
|
VALUE *lfp = cfp->lfp;
|
|
|
|
VALUE *dfp = cfp->dfp;
|
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 00:25:46 -04:00
|
|
|
int argc = 0, local_size;
|
2006-12-31 10:02:22 -05:00
|
|
|
const char *name;
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
rb_iseq_t *iseq = cfp->iseq;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
if (iseq == 0) {
|
2007-05-01 00:35:58 -04:00
|
|
|
if (RUBYVM_CFUNC_FRAME_P(cfp)) {
|
2006-12-31 10:02:22 -05:00
|
|
|
argc = 0;
|
|
|
|
local_size = 0;
|
|
|
|
name = rb_id2name(cfp->method_id);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = "?";
|
|
|
|
local_size = 0;
|
|
|
|
}
|
|
|
|
}
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
else if (RUBY_VM_IFUNC_P(iseq)) {
|
2006-12-31 10:02:22 -05:00
|
|
|
argc = 0;
|
|
|
|
local_size = 0;
|
|
|
|
name = "<ifunc>";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
argc = iseq->argc;
|
|
|
|
local_size = iseq->local_size;
|
|
|
|
name = RSTRING_PTR(iseq->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* stack trace header */
|
|
|
|
|
2007-07-05 06:49:45 -04:00
|
|
|
if (VM_FRAME_TYPE(cfp) == FRAME_MAGIC_METHOD ||
|
|
|
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_TOP ||
|
|
|
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_BLOCK ||
|
|
|
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_CLASS ||
|
|
|
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_PROC ||
|
|
|
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_LAMBDA ||
|
|
|
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_CFUNC ||
|
|
|
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_IFUNC ||
|
|
|
|
VM_FRAME_TYPE(cfp) == FRAME_MAGIC_EVAL) {
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
VALUE *ptr = dfp - local_size;
|
|
|
|
|
|
|
|
stack_dump_each(th, cfp + 1);
|
|
|
|
control_frame_dump(th, cfp);
|
|
|
|
|
|
|
|
if (lfp != dfp) {
|
|
|
|
local_size++;
|
|
|
|
}
|
|
|
|
for (i = 0; i < argc; i++) {
|
|
|
|
rstr = rb_inspect(*ptr);
|
|
|
|
fprintf(stderr, " arg %2d: %8s (%p)\n", i, StringValueCStr(rstr),
|
|
|
|
ptr++);
|
|
|
|
}
|
|
|
|
for (; i < local_size - 1; i++) {
|
|
|
|
rstr = rb_inspect(*ptr);
|
|
|
|
fprintf(stderr, " local %2d: %8s (%p)\n", i, StringValueCStr(rstr),
|
|
|
|
ptr++);
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = cfp->bp;
|
|
|
|
for (; ptr < sp; ptr++, i++) {
|
|
|
|
if (*ptr == Qundef) {
|
|
|
|
rstr = rb_str_new2("undef");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rstr = rb_inspect(*ptr);
|
|
|
|
}
|
2008-05-31 23:23:50 -04:00
|
|
|
fprintf(stderr, " stack %2d: %8s (%td)\n", i, StringValueCStr(rstr),
|
2006-12-31 10:02:22 -05:00
|
|
|
ptr - th->stack);
|
|
|
|
}
|
|
|
|
}
|
2007-07-05 06:49:45 -04:00
|
|
|
else if (VM_FRAME_TYPE(cfp) == FRAME_MAGIC_FINISH) {
|
2006-12-31 10:02:22 -05:00
|
|
|
if ((th)->stack + (th)->stack_size > (VALUE *)(cfp + 2)) {
|
|
|
|
stack_dump_each(th, cfp + 1);
|
|
|
|
}
|
|
|
|
else {
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
/* SDR(); */
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2007-07-05 06:49:45 -04:00
|
|
|
rb_bug("unsupport frame type: %08lx", VM_FRAME_TYPE(cfp));
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
debug_print_register(rb_thread_t *th)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
rb_control_frame_t *cfp = th->cfp;
|
2006-12-31 10:02:22 -05:00
|
|
|
int pc = -1;
|
|
|
|
int lfp = cfp->lfp - th->stack;
|
|
|
|
int dfp = cfp->dfp - th->stack;
|
|
|
|
int cfpi;
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
|
2006-12-31 10:02:22 -05:00
|
|
|
pc = cfp->pc - cfp->iseq->iseq_encoded;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lfp < 0 || lfp > th->stack_size)
|
|
|
|
lfp = -1;
|
|
|
|
if (dfp < 0 || dfp > th->stack_size)
|
|
|
|
dfp = -1;
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
cfpi = ((rb_control_frame_t *)(th->stack + th->stack_size)) - cfp;
|
2008-05-31 23:23:50 -04:00
|
|
|
fprintf(stderr, " [PC] %04d, [SP] %04td, [LFP] %04d, [DFP] %04d, [CFP] %04d\n",
|
2006-12-31 10:02:22 -05:00
|
|
|
pc, cfp->sp - th->stack, lfp, dfp, cfpi);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
thread_dump_regs(VALUE thval)
|
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
rb_thread_t *th;
|
2006-12-31 10:02:22 -05:00
|
|
|
GetThreadPtr(thval, th);
|
|
|
|
debug_print_register(th);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
debug_print_pre(rb_thread_t *th, rb_control_frame_t *cfp)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
rb_iseq_t *iseq = cfp->iseq;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
2007-07-05 06:49:45 -04:00
|
|
|
if (iseq != 0 && VM_FRAME_TYPE(cfp) != FRAME_MAGIC_FINISH) {
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE *seq = iseq->iseq;
|
|
|
|
int pc = cfp->pc - iseq->iseq_encoded;
|
|
|
|
|
2008-05-31 23:23:50 -04:00
|
|
|
printf("%3td ", VM_CFP_CNT(th, cfp));
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
ruby_iseq_disasm_insn(0, seq, pc, iseq, 0);
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#if VMDEBUG > 3
|
|
|
|
fprintf(stderr, " (1)");
|
|
|
|
debug_print_register(th);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
debug_print_post(rb_thread_t *th, rb_control_frame_t *cfp
|
2006-12-31 10:02:22 -05:00
|
|
|
#if OPT_STACK_CACHING
|
|
|
|
, VALUE reg_a, VALUE reg_b
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
{
|
|
|
|
#if VMDEBUG > 9
|
|
|
|
SDR2(cfp);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if VMDEBUG > 3
|
|
|
|
fprintf(stderr, " (2)");
|
|
|
|
debug_print_register(th);
|
|
|
|
#endif
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
/* stack_dump_raw(th, cfp); */
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
#if VMDEBUG > 2
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
/* stack_dump_thobj(th); */
|
2006-12-31 10:02:22 -05:00
|
|
|
stack_dump_each(th, th->cfp);
|
|
|
|
#if OPT_STACK_CACHING
|
|
|
|
{
|
|
|
|
VALUE rstr;
|
|
|
|
rstr = rb_inspect(reg_a);
|
|
|
|
fprintf(stderr, " sc reg A: %s\n", StringValueCStr(rstr));
|
|
|
|
rstr = rb_inspect(reg_b);
|
|
|
|
fprintf(stderr, " sc reg B: %s\n", StringValueCStr(rstr));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
printf
|
|
|
|
("--------------------------------------------------------------\n");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef COLLECT_USAGE_ANALYSIS
|
|
|
|
/* uh = {
|
|
|
|
* insn(Fixnum) => ihash(Hash)
|
|
|
|
* }
|
|
|
|
* ihash = {
|
|
|
|
* -1(Fixnum) => count, # insn usage
|
|
|
|
* 0(Fixnum) => ophash, # operand usage
|
|
|
|
* }
|
|
|
|
* ophash = {
|
|
|
|
* val(interned string) => count(Fixnum)
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
vm_analysis_insn(int insn)
|
|
|
|
{
|
2008-06-09 05:25:32 -04:00
|
|
|
ID usage_hash;
|
|
|
|
ID bigram_hash;
|
2006-12-31 10:02:22 -05:00
|
|
|
static int prev_insn = -1;
|
|
|
|
|
|
|
|
VALUE uh;
|
|
|
|
VALUE ihash;
|
|
|
|
VALUE cv;
|
|
|
|
|
2008-06-09 05:25:32 -04:00
|
|
|
CONST_ID(usage_hash, "USAGE_ANALYSIS_INSN");
|
|
|
|
CONST_ID(bigram_hash, "USAGE_ANALYSIS_INSN_BIGRAM");
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 00:25:46 -04:00
|
|
|
uh = rb_const_get(rb_cVM, usage_hash);
|
2006-12-31 10:02:22 -05:00
|
|
|
if ((ihash = rb_hash_aref(uh, INT2FIX(insn))) == Qnil) {
|
|
|
|
ihash = rb_hash_new();
|
|
|
|
rb_hash_aset(uh, INT2FIX(insn), ihash);
|
|
|
|
}
|
|
|
|
if ((cv = rb_hash_aref(ihash, INT2FIX(-1))) == Qnil) {
|
|
|
|
cv = INT2FIX(0);
|
|
|
|
}
|
|
|
|
rb_hash_aset(ihash, INT2FIX(-1), INT2FIX(FIX2INT(cv) + 1));
|
|
|
|
|
|
|
|
/* calc bigram */
|
|
|
|
if (prev_insn != -1) {
|
|
|
|
VALUE bi;
|
|
|
|
VALUE ary[2];
|
|
|
|
VALUE cv;
|
|
|
|
|
|
|
|
ary[0] = INT2FIX(prev_insn);
|
|
|
|
ary[1] = INT2FIX(insn);
|
|
|
|
bi = rb_ary_new4(2, &ary[0]);
|
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 00:25:46 -04:00
|
|
|
uh = rb_const_get(rb_cVM, bigram_hash);
|
2006-12-31 10:02:22 -05:00
|
|
|
if ((cv = rb_hash_aref(uh, bi)) == Qnil) {
|
|
|
|
cv = INT2FIX(0);
|
|
|
|
}
|
|
|
|
rb_hash_aset(uh, bi, INT2FIX(FIX2INT(cv) + 1));
|
|
|
|
}
|
|
|
|
prev_insn = insn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* from disasm.c */
|
|
|
|
extern VALUE insn_operand_intern(int insn, int op_no, VALUE op,
|
|
|
|
int len, int pos, VALUE child);
|
|
|
|
|
|
|
|
void
|
|
|
|
vm_analysis_operand(int insn, int n, VALUE op)
|
|
|
|
{
|
2008-06-09 05:25:32 -04:00
|
|
|
ID usage_hash;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
VALUE uh;
|
|
|
|
VALUE ihash;
|
|
|
|
VALUE ophash;
|
|
|
|
VALUE valstr;
|
|
|
|
VALUE cv;
|
|
|
|
|
2008-06-09 05:25:32 -04:00
|
|
|
CONST_ID(usage_hash, "USAGE_ANALYSIS_INSN");
|
2006-12-31 10:02:22 -05:00
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 00:25:46 -04:00
|
|
|
uh = rb_const_get(rb_cVM, usage_hash);
|
2006-12-31 10:02:22 -05:00
|
|
|
if ((ihash = rb_hash_aref(uh, INT2FIX(insn))) == Qnil) {
|
|
|
|
ihash = rb_hash_new();
|
|
|
|
rb_hash_aset(uh, INT2FIX(insn), ihash);
|
|
|
|
}
|
|
|
|
if ((ophash = rb_hash_aref(ihash, INT2FIX(n))) == Qnil) {
|
|
|
|
ophash = rb_hash_new();
|
|
|
|
rb_hash_aset(ihash, INT2FIX(n), ophash);
|
|
|
|
}
|
|
|
|
/* intern */
|
|
|
|
valstr = insn_operand_intern(insn, n, op, 0, 0, 0);
|
|
|
|
|
|
|
|
/* set count */
|
|
|
|
if ((cv = rb_hash_aref(ophash, valstr)) == Qnil) {
|
|
|
|
cv = INT2FIX(0);
|
|
|
|
}
|
|
|
|
rb_hash_aset(ophash, valstr, INT2FIX(FIX2INT(cv) + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vm_analysis_register(int reg, int isset)
|
|
|
|
{
|
2008-06-09 05:25:32 -04:00
|
|
|
ID usage_hash;
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE uh;
|
|
|
|
VALUE rhash;
|
|
|
|
VALUE valstr;
|
2008-06-09 05:25:32 -04:00
|
|
|
static const char regstrs[][5] = {
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
"pc", /* 0 */
|
|
|
|
"sp", /* 1 */
|
|
|
|
"cfp", /* 2 */
|
|
|
|
"lfp", /* 3 */
|
|
|
|
"dfp", /* 4 */
|
|
|
|
"self", /* 5 */
|
|
|
|
"iseq", /* 6 */
|
2006-12-31 10:02:22 -05:00
|
|
|
};
|
2008-06-09 05:25:32 -04:00
|
|
|
static const char getsetstr[][4] = {
|
2006-12-31 10:02:22 -05:00
|
|
|
"get",
|
|
|
|
"set",
|
|
|
|
};
|
|
|
|
static VALUE syms[sizeof(regstrs) / sizeof(regstrs[0])][2];
|
|
|
|
|
|
|
|
VALUE cv;
|
|
|
|
|
2008-06-09 05:25:32 -04:00
|
|
|
CONST_ID(usage_hash, "USAGE_ANALYSIS_REGS");
|
|
|
|
if (syms[0] == 0) {
|
2006-12-31 10:02:22 -05:00
|
|
|
char buff[0x10];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(regstrs) / sizeof(regstrs[0]); i++) {
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < 2; j++) {
|
|
|
|
snfprintf(stderr, buff, 0x10, "%d %s %-4s", i, getsetstr[j],
|
|
|
|
regstrs[i]);
|
|
|
|
syms[i][j] = ID2SYM(rb_intern(buff));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
valstr = syms[reg][isset];
|
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 00:25:46 -04:00
|
|
|
uh = rb_const_get(rb_cVM, usage_hash);
|
2006-12-31 10:02:22 -05:00
|
|
|
if ((cv = rb_hash_aref(uh, valstr)) == Qnil) {
|
|
|
|
cv = INT2FIX(0);
|
|
|
|
}
|
|
|
|
rb_hash_aset(uh, valstr, INT2FIX(FIX2INT(cv) + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
VALUE
|
|
|
|
thread_dump_state(VALUE self)
|
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
rb_thread_t *th;
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
rb_control_frame_t *cfp;
|
2006-12-31 10:02:22 -05:00
|
|
|
GetThreadPtr(self, th);
|
|
|
|
cfp = th->cfp;
|
|
|
|
|
|
|
|
fprintf(stderr, "Thread state dump:\n");
|
|
|
|
fprintf(stderr, "pc : %p, sp : %p\n", cfp->pc, cfp->sp);
|
|
|
|
fprintf(stderr, "cfp: %p, lfp: %p, dfp: %p\n", cfp, cfp->lfp, cfp->dfp);
|
|
|
|
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2008-05-25 18:16:04 -04:00
|
|
|
VALUE rb_make_backtrace(void);
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
void
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 00:25:46 -04:00
|
|
|
rb_vm_bugreport(void)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
VALUE bt;
|
|
|
|
|
|
|
|
if (GET_THREAD()->vm) {
|
|
|
|
int i;
|
|
|
|
SDR();
|
2007-06-05 00:49:54 -04:00
|
|
|
|
2008-05-25 18:16:04 -04:00
|
|
|
bt = rb_make_backtrace();
|
2006-12-31 10:02:22 -05:00
|
|
|
if (TYPE(bt) == T_ARRAY)
|
|
|
|
for (i = 0; i < RARRAY_LEN(bt); i++) {
|
|
|
|
dp(RARRAY_PTR(bt)[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if HAVE_BACKTRACE
|
|
|
|
#include <execinfo.h>
|
|
|
|
#define MAX_NATIVE_TRACE 1024
|
|
|
|
{
|
|
|
|
static void *trace[MAX_NATIVE_TRACE];
|
|
|
|
int n = backtrace(trace, MAX_NATIVE_TRACE);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
fprintf(stderr, "-- backtrace of native function call (Use addr2line) --\n");
|
|
|
|
for (i=0; i<n; i++) {
|
|
|
|
fprintf(stderr, "%p\n", trace[i]);
|
|
|
|
}
|
|
|
|
fprintf(stderr, "-------------------------------------------------------\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|