pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:1437:    */      /*! @decl void lfun::_m_clear()    *!    *! Called by @[m_clear()].    *!    *! @seealso    *! @[lfun::_m_delete()], @[lfun::_m_add()]    */    - /*! @decl void lfun::_m_add()] + /*! @decl void lfun::_m_add()    *!    *! Called by @[m_add()].    *!    *! @seealso    *! @[lfun::_m_delete()], @[lfun::_m_clear()]    */      /**** END FAKE LFUNS ****/   /**** BEGIN MAGIC LFUNS ****/   
pike.git/src/program.c:8173:   /*    * Line number support routines, now also tells what file we are in.    */      /* program.linenumbers format:    *    * Filename entry:    * 1. char 127 (marker).    * 2. small number Filename entry number in string table.    * +  * Frame variable: +  * 1. char 127 (marker). +  * 2. small number ~(frame stack offset). +  * 3. char 0: name, 1: type, 2:end +  * 4. small number name: strings_offset, type: constants_offset, end: - +  *    * Line number entry:    * 1. small number Index in program.program (pc).    * Stored as the difference from the pc in the    * closest previous line number entry. The first    * stored entry is absolute.    * 2. small number Line number. Stored in the same way as the pc.    *    * Small number:    * If -127 < n < 127:    * 1. char The number.
pike.git/src/program.c:8444:    insert_small_number(store_prog_string(current_file));    copy_shared_string(Pike_compiler->last_file, current_file);    }    insert_small_number((INT32)(PIKE_PC-Pike_compiler->last_pc));    insert_small_number(current_line-Pike_compiler->last_line);    Pike_compiler->last_line = current_line;    Pike_compiler->last_pc = (INT32)PIKE_PC;    }   }    + void store_linenumber_frame_name(int frame_offset, int string_num) + { +  add_to_linenumbers(127); +  insert_small_number(~frame_offset); +  add_to_linenumbers(0); +  insert_small_number(string_num); + } +  + void store_linenumber_frame_type(int frame_offset, int constant_num) + { +  add_to_linenumbers(127); +  insert_small_number(~frame_offset); +  add_to_linenumbers(1); +  insert_small_number(constant_num); + } +  + void store_linenumber_frame_end(int frame_offset) + { +  add_to_linenumbers(127); +  insert_small_number(~frame_offset); +  add_to_linenumbers(2); + } +    #define FIND_PROGRAM_LINE(prog, file, line) do { \    char *pos = prog->linenumbers; \    file = NULL; \    \    if (pos < prog->linenumbers + prog->num_linenumbers) { \    if (*pos == 127) { \    int strno; \    pos++; \    strno = get_small_number(&pos); \    CHECK_FILE_ENTRY (prog, strno); \
pike.git/src/program.c:8655:    fprintf(stderr, "No program of linenumbers program:%p linenumbers:%p\n",    prog->program, prog->linenumbers);    }       if(gotoff) return gotoff;    return 0;   }      PMOD_EXPORT struct pike_string *low_get_line (PIKE_OPCODE_T *pc,    struct program *prog, -  INT_TYPE *linep) +  INT_TYPE *linep, +  struct local_variable_info *vars)   {    linep[0] = 0;       if (prog->program && prog->linenumbers) {    ptrdiff_t offset = pc - prog->program;    if ((offset < (ptrdiff_t)prog->num_program) && (offset >= 0)) {    static struct pike_string *file = NULL;    static struct pike_string *next_file = NULL;    static char *base, *cnt;    static ptrdiff_t off;    static INT32 pid;    static INT_TYPE line; -  +  static struct local_variable_info frame;       if(prog->linenumbers == base && prog->id == pid && offset > off &&    cnt < prog->linenumbers + prog->num_linenumbers)    goto fromold;       base = cnt = prog->linenumbers;    off=line=0;    pid=prog->id;    file = 0; -  +  frame.num_local = 0;       while(cnt < prog->linenumbers + prog->num_linenumbers)    {    if(*cnt == 127)    {    int strno;    cnt++;    strno = get_small_number(&cnt); -  +  if (strno >= 0) {    CHECK_FILE_ENTRY (prog, strno);    next_file = prog->strings[strno]; -  +  } else { +  int frame_offset = ~strno; +  int kind = *cnt++; +  if (kind == 2) { +  /* end of frame */ +  frame.num_local = frame_offset;    continue;    } -  +  strno = get_small_number(&cnt); +  frame.num_local = frame_offset+1; +  if (frame_offset < MAX_LOCAL) { +  switch(kind) { +  case 0: /* name */ +  frame.names[frame_offset] = strno; +  break; +  case 1: /* type */ +  frame.types[frame_offset] = strno; +  break; + #ifdef PIKE_DEBUG +  default: +  Pike_fatal("Unknown linenumber entry: %d\n", kind); +  break; + #endif +  } + #ifdef PIKE_DEBUG +  } else { +  Pike_fatal("Frame offset out of range: %d\n", frame_offset); + #endif +  } +  } +  continue; +  }    off+=get_small_number(&cnt);    fromold:    if(off > offset) break;    line+=get_small_number(&cnt);    file = next_file;    }    if (cnt >= prog->linenumbers + prog->num_linenumbers) {    /* We reached the end of the table. Make sure    * we get in sync again next time we're called.    */    base = NULL;    }    linep[0]=line; -  +  if (vars) *vars = frame;    if (file) {    add_ref(file);    return file;    }    } else {    fprintf(stderr, "Bad offset: pc:%p program:%p (%p)\n",    pc, prog->program, (void *)prog->num_program);    }    } else {    fprintf(stderr, "No program of linenumbers program:%p linenumbers:%p\n",
pike.git/src/program.c:8798:   {    struct pike_string *res;       if (prog == 0) {    struct pike_string *unknown_program;    REF_MAKE_CONST_STRING(unknown_program, "Unknown program");    linep[0] = 0;    return unknown_program;    }    -  res = low_get_line(pc, prog, linep); +  res = low_get_line(pc, prog, linep, NULL);    if (!res) {    struct pike_string *not_found;    REF_MAKE_CONST_STRING(not_found, "Line not found");    return not_found;    }    return res;   }      PMOD_EXPORT struct pike_string *low_get_function_line (struct object *o,    int fun,
pike.git/src/program.c:8830:    if (!IDENTIFIER_IS_ALIAS(id->identifier_flags)) break;    loc.o = o;    loc.inherit = INHERIT_FROM_INT(o->prog, fun);    loc.parent_identifier = fun;    find_external_context(&loc, id->func.ext_ref.depth);    fun = id->func.ext_ref.id + loc.inherit->identifier_level;    o = loc.o;    }    if (IDENTIFIER_IS_PIKE_FUNCTION(id->identifier_flags) &&    (id->func.offset != -1)) -  return low_get_line (p->program + id->func.offset, p, linep); +  return low_get_line (p->program + id->func.offset, p, linep, NULL);    if ((ret = get_identifier_line(o->prog, fun, linep))) {    add_ref(ret);    return ret;    }    return low_get_program_line(o->prog, linep);    }    *linep = 0;    return NULL;   }