pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: program.c,v 1.487 2003/03/14 17:45:05 grubba Exp $ + || $Id: program.c,v 1.488 2003/03/19 18:32:01 mast Exp $   */      #include "global.h" - RCSID("$Id: program.c,v 1.487 2003/03/14 17:45:05 grubba Exp $"); + RCSID("$Id: program.c,v 1.488 2003/03/19 18:32:01 mast Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"   #include "pike_types.h"   #include "stralloc.h"   #include "las.h"   #include "language.h"   #include "lex.h"   #include "pike_macros.h"   #include "fsort.h"
pike.git/src/program.c:882:   struct object *error_handler=0;   struct object *compat_handler=0;      struct program *gc_internal_program = 0;   static struct program *gc_mark_program_pos = 0;      int compilation_depth=-1;   dynamic_buffer used_modules;   static struct mapping *resolve_cache=0;    + #ifdef PIKE_DEBUG + #define CHECK_FILE_ENTRY(PROG, POS, LEN, SHIFT) \ +  do { \ +  if (SHIFT < 0 || SHIFT > 2 || \ +  POS + (LEN << SHIFT) > PROG->linenumbers + PROG->num_linenumbers) \ +  Pike_fatal ("Invalid file entry in linenumber info.\n"); \ +  } while (0) + #else + #define CHECK_FILE_ENTRY(PROG, POS, LEN, SHIFT) do {} while (0) + #endif +    int get_small_number(char **q);      /* So what if we don't have templates? / Hubbe */      #ifdef PIKE_DEBUG   #define CHECK_FOO(NUMTYPE,TYPE,NAME) \    if(Pike_compiler->malloc_size_program-> PIKE_CONCAT(num_,NAME) < Pike_compiler->new_program-> PIKE_CONCAT(num_,NAME)) \    Pike_fatal("Pike_compiler->new_program->num_" #NAME " is out of order\n"); \    if(Pike_compiler->new_program->flags & PROGRAM_OPTIMIZED) \    Pike_fatal("Tried to reallocate fixed program.\n")
pike.git/src/program.c:1920:       while(cnt < Pike_compiler->new_program->linenumbers +    Pike_compiler->new_program->num_linenumbers)    {    if(*cnt == 127)    {    cnt++;    len = get_small_number(&cnt);    shift = *cnt;    file = ++cnt; +  CHECK_FILE_ENTRY (Pike_compiler->new_program, cnt, len, shift);    cnt += len<<shift;    }    off+=get_small_number(&cnt);    line+=get_small_number(&cnt);    }    Pike_compiler->last_line=line;    Pike_compiler->last_pc=off;    if(file)    {    struct pike_string *str = begin_wide_shared_string(len, shift);
pike.git/src/program.c:2339: Inside #if defined(PIKE_DEBUG)
   char *cnt = p->linenumbers;       while (cnt < p->linenumbers + p->num_linenumbers) {    if (*cnt == 127) {    int len, shift;    char *file;    cnt++;    len = get_small_number(&cnt);    shift = *cnt;    file = ++cnt; +  CHECK_FILE_ENTRY (p, cnt, len, shift);    cnt += len << shift;    if (!shift) {    fprintf(stderr, "%*s Filename: \"%s\"\n", indent, "", file);    } else {    fprintf(stderr, "%*s Filename: len:%d, shift:%d\n", indent, "", len, shift);    }    }    off += get_small_number(&cnt);    line += get_small_number(&cnt);    fprintf(stderr, "%*s %8d:%8d\n", indent, "", off, line);
pike.git/src/program.c:5010: Inside #if defined(PIKE_DEBUG)
   while(cnt < Pike_compiler->new_program->linenumbers +    Pike_compiler->new_program->num_linenumbers)    {    char *start = cnt;    if(*cnt == 127)    {    cnt++;    len = get_small_number(&cnt);    shift = *cnt;    file = ++cnt; +  CHECK_FILE_ENTRY (Pike_compiler->new_program, cnt, len, shift);    cnt += len<<shift;    if (a_flag > 100) {    fprintf(stderr, "Filename entry:\n"    " len: %d, shift: %d\n",    len, shift);    }    }    off+=get_small_number(&cnt);    line+=get_small_number(&cnt);    if (a_flag > 100) {
pike.git/src/program.c:5093:    INT32 shift = 0;    char *file = NULL;       cnt = prog->linenumbers;    if (cnt < prog->linenumbers + prog->num_linenumbers) {    if (*cnt == 127) {    cnt++;    len = get_small_number(&cnt);    shift = *cnt;    file = ++cnt; +  CHECK_FILE_ENTRY (prog, cnt, len, shift);    cnt += len<<shift;    }    get_small_number(&cnt); /* Ignore the offset */    *linep = get_small_number(&cnt);    }       if (file) {    struct pike_string *str = begin_wide_shared_string(len, shift);    memcpy(str->str, file, len<<shift);    return end_shared_string(str);
pike.git/src/program.c:5150: Inside #if defined(PIKE_DEBUG)
   if (!prog->linenumbers)    return "stub";       cnt = prog->linenumbers;    if (cnt < prog->linenumbers + prog->num_linenumbers) {    if (*cnt == 127) {    cnt++;    len = get_small_number(&cnt);    shift = *cnt;    file = ++cnt; +  CHECK_FILE_ENTRY (prog, cnt, len, shift);    cnt += len<<shift;    }    get_small_number(&cnt); /* Ignore the offset */    *linep = get_small_number(&cnt);    }       if (file) {    if(shift)    {    PCHARP from=MKPCHARP(file, shift);
pike.git/src/program.c:5201:      PMOD_EXPORT struct pike_string *low_get_line (PIKE_OPCODE_T *pc,    struct program *prog, INT32 *linep)   {    linep[0] = 0;       if (prog->program && prog->linenumbers) {    ptrdiff_t offset = pc - prog->program;    if ((offset < (ptrdiff_t)prog->num_program) && (offset >= 0)) {    static char *file = NULL; -  static char *cnt; +  static char *base, *cnt;    static INT32 off,line,pid;    static size_t len;    static INT32 shift;    -  if(prog->id != pid || offset < off) +  if(prog->linenumbers != base || prog->id != pid || offset < off)    { -  cnt=prog->linenumbers; +  base = cnt = prog->linenumbers;    off=line=0;    pid=prog->id;    file = 0;    }else{    if (cnt < prog->linenumbers + prog->num_linenumbers)    goto fromold;    }       while(cnt < prog->linenumbers + prog->num_linenumbers)    {    if(*cnt == 127)    {    cnt++;    len = get_small_number(&cnt);    shift = *cnt;    file = ++cnt; -  +  CHECK_FILE_ENTRY (prog, cnt, len, shift);    cnt += len<<shift;    }    off+=get_small_number(&cnt);    fromold:    if(off > offset) break;    line+=get_small_number(&cnt);    }    linep[0]=line;    if (file) {    struct pike_string *res = begin_wide_shared_string(len, shift);