pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:60:   #define SET_GMTOFF(TM, VAL) (((TM)->tm_gmtoff) = (VAL))   #define SET_ZONE(this, VAL) ((this)->t.tm_zone = (VAL))   #else    struct tm_extra { const char *tm_zone; };   #define GET_GMTOFF(TM) 0   #define GET_ZONE(this) ((this)->extra.tm_zone)   #define SET_GMTOFF(TM, VAL) (VAL)   #define SET_ZONE(this, VAL) ((this)->extra.tm_zone = (VAL))   #endif    + void low_low_backtrace(struct Pike_interpreter_struct *i, int keep_pc); +    DECLARATIONS      /*! @module System    */      /*! @class TM    *! A wrapper for the system struct tm time keeping structure.    *! This can be used as a (very) lightweight alternative to Calendar.    */   PIKECLASS TM
pike.git/src/builtin.cmod:506:   PIKEFUN int set_debugger(int i)    optflags OPT_SIDE_EFFECT;   efun;    {    int tmp = enable_debugger;    enable_debugger = i;    pop_stack();    push_int(tmp);   }    - PMOD_EXPORT - PIKEFUN int debugger_set_local(int pc, int i, mixed value) -  optflags OPT_SIDE_EFFECT; - efun; - { -  struct pike_frame * fp = (struct pike_frame *)pc; -  printf("Pike_fp: %p\n", fp); -  assign_svalue(fp->locals+(ptrdiff_t)i, value); -  pop_n_elems(3); -  push_int(0); - } +     -  +    PMOD_EXPORT   PIKEFUN int add_breakpoint(program p, string fname, int line_number)    optflags OPT_SIDE_EFFECT;   efun;   {    ptrdiff_t pc_offset;       // TODO: we need to develop the line search further: a file can be included multiple times within a program, and so    // in theory, a breakpoint for a line within a file could actually be multiple breakpoints. we stop at the first one.    pc_offset = low_get_offset_for_line(p, fname, line_number);
pike.git/src/builtin.cmod:2462:      PIKECLASS backtrace_frame   {    PIKEVAR mixed _fun flags ID_PROTECTED|ID_PRIVATE;   #ifdef PIKE_DEBUG    PIKEVAR program oprog flags ID_PROTECTED|ID_PRIVATE;   #endif    PIKEVAR array args;       /* These are cleared when filename and lineno have been initialized -  * from them. */ +  * from them, unless keep_pc is set. */    PIKEVAR program prog flags ID_PROTECTED|ID_PRIVATE;    CVAR PIKE_OPCODE_T *pc; -  +  CVAR struct pike_frame * fp;       /* These two are considered to be uninitialized from prog, pc and    * fun as long as lineno == 0. */    CVAR struct pike_string *filename;    CVAR INT_TYPE lineno;      #ifdef PIKE_NULL_IS_SPECIAL    INIT    {    THIS->pc = NULL; -  +  THIS->fp = NULL;    THIS->lineno = 0;    THIS->filename = NULL;    }   #endif       EXIT    gc_trivial;    {    if (THIS->filename) {    free_string(THIS->filename);    THIS->filename = NULL;    } -  +     THIS->pc = NULL; -  +  +  if(THIS->fp) { +  free_pike_frame(THIS->fp); +  } +  THIS->fp = NULL; +  +  if((THIS->prog) != NULL) +  free_program(THIS->prog); +  THIS->prog = NULL; +     THIS->lineno = 0;    }    -  +  PIKEFUN mixed locals() { +  int num_locals = 0; +  int fp_num_locals; +  if(!(THIS->fp)) +  Pike_error("locals are only available within a debugging environment!\n"); +  fp_num_locals = THIS->fp->num_locals; +  struct svalue * current_local = THIS->fp->locals; +  while(num_locals < fp_num_locals) { +  push_svalue(current_local); +  add_ref_svalue(Pike_sp - 1); +  current_local++; +  num_locals++; +  } +  +  f_aggregate(num_locals); +  } +  +  PIKEFUN int set_local(int i, mixed value) +  optflags OPT_SIDE_EFFECT; +  { +  if(!(THIS->fp)) +  Pike_error("locals are only available within a debugging environment!\n"); +  struct pike_frame * fp = THIS->fp; +  assign_svalue(fp->locals+(ptrdiff_t)i, value); +  pop_n_elems(2); +  push_int(0); +  } +     /* NOTE: Use old-style getter/setter syntax for compatibility with    * old Parser.Pike.split() used by precompile.pike.    */       PIKEFUN mixed `->fun()    {    push_svalue(&THIS->_fun);    }       PIKEFUN void `->fun=(mixed val)
pike.git/src/builtin.cmod:2529:    RETURN (t == literal_array_string);    }       static void fill_in_file_and_line()    {    struct pike_string *file = NULL;    assert (THIS->lineno == 0);       if (THIS->pc && THIS->prog) {    file = low_get_line(THIS->pc, THIS->prog, &THIS->lineno); -  THIS->pc = NULL; +  if((THIS->fp) == NULL) THIS->pc = NULL;    }    else if (TYPEOF(THIS->_fun) == PIKE_T_FUNCTION) {   #ifdef PIKE_DEBUG    if (THIS->_fun.u.object->prog &&    THIS->_fun.u.object->prog != THIS->oprog) {    struct identifier *id = ID_FROM_INT(THIS->oprog, SUBTYPEOF(THIS->_fun));    /* FIXME: Dump dmalloc info for the object? */    Pike_fatal("Lost track of function pointer! Function name was %s.\n",    id->name?id->name->str:"<no name>");    }
pike.git/src/builtin.cmod:2553:    }    else if (THIS->prog) {    file = low_get_program_line (THIS->prog, &THIS->lineno);    }       if (file) {    if (!THIS->filename) THIS->filename = file;    else free_string (file);    }    -  if (THIS->prog) { +  if (THIS->prog && ((THIS->fp) == NULL)) {    free_program(THIS->prog);    THIS->prog = NULL;    }    }       /*! @decl string _sprintf(int c, mapping|void opts)    */    PIKEFUN string _sprintf(int c, mapping|void opts)    flags ID_PROTECTED;    {
pike.git/src/builtin.cmod:2831:    push_static_text("auto_bignum");    push_int(1);    f_aggregate_mapping(7*2);   }      /*! @endmodule    */      void low_backtrace(struct Pike_interpreter_struct *i)   { +  low_low_backtrace(i, 0); + } +  + void low_low_backtrace(struct Pike_interpreter_struct *i, int keep_pc) + {    struct svalue *stack_top = i->stack_pointer;    struct pike_frame *f, *of = 0;    int size = 0;    struct array *res = NULL;       for (f = i->frame_pointer; f; f = f->next) {    size++;    }       res = allocate_array_no_init(size, 0);
pike.git/src/builtin.cmod:2854:    struct object *o = fast_clone_object(backtrace_frame_program);    struct backtrace_frame_struct *bf;    struct identifier *function = NULL;       size--;       SET_SVAL(res->item[size], PIKE_T_OBJECT, 0, object, o);       bf = OBJ2_BACKTRACE_FRAME(o);    +  if(keep_pc) { +  add_ref(f); +  bf->fp = f; +  } +     SET_SVAL(bf->_fun, PIKE_T_INT, NUMBER_DESTRUCTED, integer, 0);       if (!f->context) {    if (f->pc == (void *)do_gc) {    SET_SVAL(bf->_fun, PIKE_T_STRING, 0, string, make_shared_string("gc"));    }    continue;    }       if ((bf->prog = f->context->prog)) {
pike.git/src/builtin.cmod:2977:    *! @[catch()], @[throw()]    */   PMOD_EXPORT   PIKEFUN array(mixed) backtrace()    efun;    optflags OPT_EXTERNAL_DEPEND;   {    low_backtrace(& Pike_interpreter);   }    + PMOD_EXPORT + PIKEFUN array(mixed) debug_backtrace() +  efun; +  optflags OPT_EXTERNAL_DEPEND; + { +  low_low_backtrace(& Pike_interpreter, 1); + } +    /*! @class Replace    *!    *! This is a "compiled" version of the @[replace] function applied on    *! a string, with more than one replace string. The replace strings    *! are given to the create method as a @i{from@} and @i{to@} array    *! and are then analyzed. The @expr{`()@} is then called with a    *! string and the replace rules in the Replace object will be    *! applied. The Replace object is used internally by the Pike    *! optimizer and need not be used manually.    */