From: Stephen Kellett Date: 2004-11-30T23:02:52+09:00 Subject: Re: How to implement set_trace_func callback in C/C++? In message <1101771510.124768.9696.nullmailer@x31.priv.netlab.jp>, Yukihiro Matsumoto writes >Try: > > VALUE my_trace_function(int argc, VALUE *argv); Thanks that works just fine. I've managed to decode 5 of the 6 parameters that can potentially be passed in. I know that sometimes I don't get all 6 parameters. I'm having a problem decoding the "binding" parameter. How do I do this? I'd like to be able to determine which thread and what the local variables are and what the parameters are. I thought the binding value (argv[4]) was really a struct BLOCK *, where BLOCK is taken from eval.c struct BLOCK { NODE *var; NODE *body; VALUE self; struct FRAME frame; struct SCOPE *scope; VALUE klass; NODE *cref; int iter; int vmode; int flags; struct RVarmap *dyna_vars; VALUE orig_thread; VALUE wrapper; VALUE block_obj; struct BLOCK *outer; struct BLOCK *prev; }; However if I process argv[4] as a struct BLOCK * I find that the "orig_thread" value varies wildly, and other values don't seem to make much sense. Here is my code, where v is the VALUE from argv[4] if (v != Qnil) { struct BLOCK *blk; blk = (struct BLOCK *)v; printf(" binding:%d\n", v); printf("\tthread:%d\n", blk->orig_thread); printf("\tself:%d\n", blk->self); printf("\tframe:%d\n", blk->frame.self); printf("\tscope:%d\n", blk->scope); } else { printf(" binding:NIL"); } How should I be interpreting the binding parameter? I want to avoid calling eval() and deal with values directly. Hoping you can help. Stephen -- Stephen Kellett Object Media Limited http://www.objmedia.demon.co.uk RSI Information: http://www.objmedia.demon.co.uk/rsi.html