Branch: Tag:

2011-05-18

2011-05-18 23:31:17 by 0

Implement --with-dtrace to enable source-level tracing of Pike programs using
e.g. Apple Instruments. (It's not yet balancing entry/exit properly.)

53:   #endif   #endif    + #ifdef USE_DTRACE + #include "dtrace_probes.h" + #else + #include "dtrace/dtrace_probes_disabled.h" + #endif +    /*    * Define the default evaluator stack size, used for just about everything.    */
2015:    my_strcat (s->u.efun->name->str);    do_trace_call(args, &save_buf);    } +  if (PIKE_FN_START_ENABLED()) { +  /* DTrace enter probe +  arg0: function name +  arg1: object +  */ +  PIKE_FN_START(s->u.efun->name->size_shift == 0 ? +  s->u.efun->name->str : "[widestring fn name]", +  ""); +  }    FAST_CHECK_THREADS_ON_CALL();    (*(s->u.efun->function))(args); -  +  if (PIKE_FN_DONE_ENABLED()) { +  /* DTrace leave probe +  arg0: function name +  */ +  PIKE_FN_DONE(s->u.efun->name->size_shift == 0 ? +  s->u.efun->name->str : "[widestring fn name]"); +  }      #ifdef PIKE_DEBUG    s->u.efun->runs++;
2062:    safe_describe_svalue(s,0,0);    do_trace_call(args, &save_buf);    } +  if (PIKE_FN_START_ENABLED()) { +  /* DTrace enter probe +  arg0: function name +  arg1: object +  */ +  PIKE_FN_START("[array]", ""); +  }    apply_array(s->u.array, args, (type == APPLY_STACK));    break;   
2081:    safe_describe_svalue(s,0,0);    do_trace_call(args, &save_buf);    } +  if (PIKE_FN_START_ENABLED()) { +  /* DTrace enter probe +  arg0: function name +  arg1: object +  */ +  dynamic_buffer save_buf; +  dynbuf_string prog_name; +  init_buf(&save_buf); +  safe_describe_svalue(s,0,0); +  prog_name = complex_free_buf(&save_buf); +  PIKE_FN_START("[program]", prog_name.str); +  }    push_object(clone_object(s->u.program,args));    break;   
2160:    if(Pike_interpreter.trace_level>1)    do_trace_func_return (1, o, fun);    } +  +  if (PIKE_FN_DONE_ENABLED()) { +  /* DTrace leave probe +  arg0: function name +  */ +  char *fn = "(unknown)"; +  if (o && o->prog) { +  struct identifier *id = ID_FROM_INT(o->prog, fun); +  fn = id->name->size_shift == 0 ? id->name->str : "[widestring fn name]"; +  } +  PIKE_FN_DONE(fn); +  } +     return 0;   }   
2190:    fun = Pike_fp->fun;    }    +  if (PIKE_FN_DONE_ENABLED()) { +  /* DTrace leave probe +  arg0: function name +  */ +  char *fn = "(unknown)"; +  o = Pike_fp->current_object; +  fun = Pike_fp->fun; +  if (o && o->prog) { +  struct identifier *id = ID_FROM_INT(o->prog, fun); +  fn = id->name->size_shift == 0 ? id->name->str : "[widestring fn name]"; +  } +  PIKE_FN_DONE(fn); +  } +    #if defined (PIKE_USE_MACHINE_CODE) && defined (OPCODE_RETURN_JUMPADDR)    /* If the function that returns is the only ref to the current    * object and its program then the program would be freed in
2233:    add_ref (o);   #endif    +  if (PIKE_FN_DONE_ENABLED()) { +  /* DTrace leave probe +  arg0: function name +  */ +  char *fn = "(unknown)"; +  struct object *o = Pike_fp->current_object; +  int fun = Pike_fp->fun; +  if (o && o->prog) { +  struct identifier *id = ID_FROM_INT(o->prog, fun); +  fn = id->name->size_shift == 0 ? id->name->str : "[widestring fn name]"; +  } +  PIKE_FN_DONE(fn); +  } +     basic_low_return (save_sp);       if(save_sp < Pike_sp)