pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: interpret.c,v 1.250 2001/10/05 01:30:12 hubbe Exp $"); + RCSID("$Id: interpret.c,v 1.251 2001/10/22 19:09:48 mast Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"   #include "svalue.h"   #include "array.h"   #include "mapping.h"   #include "pike_error.h"   #include "language.h"   #include "stralloc.h"   #include "constants.h"
pike.git/src/interpret.c:1751: Inside #if defined(PIKE_DEBUG)
   if(f->locals < Pike_interpreter.evaluator_stack ||    f->locals > &(Pike_interpreter.evaluator_stack[Pike_stack_size]))    fatal("Local variable pointer points to FinspĂ„ng.\n");       if(f->args < 0 || f->args > Pike_stack_size)    fatal("FEL FEL FEL! HELP!! (corrupted pike_frame)\n");    }    }   }    + static const char *safe_idname_from_int(struct program *prog, int func) + { +  /* ID_FROM_INT with a thick layer of checks. */ +  struct reference *ref; +  struct inherit *inher; +  struct identifier *id; +  if (!prog) +  return "<null program *>"; +  if (func < 0 || func >= prog->num_identifier_references) +  return "<offset outside prog->identifier_references>"; +  if (!prog->identifier_references) +  return "<null prog->identifier_references>"; +  ref = prog->identifier_references + func; +  if (ref->inherit_offset >= prog->num_inherits) +  return "<offset outside prog->inherits>"; +  if (!prog->inherits) +  return "<null prog->inherits>"; +  inher = prog->inherits + ref->inherit_offset; +  prog = inher->prog; +  if (!prog) +  return "<null inherited prog>"; +  if (ref->identifier_offset >= prog->num_identifiers) +  return "<offset outside inherited prog->identifiers>"; +  if (!prog->identifiers) +  return "<null inherited prog->identifiers>"; +  id = prog->identifiers + ref->identifier_offset; +  if (!id->name) +  return "<null identifier->name>"; +  if (!id->name->str) +  return "<null identifier->name->str>"; +  /* FIXME: Wide string identifiers. */ +  return id->name->str; + } +    /*: Prints the Pike backtrace for the interpreter context in the given    *: thread to stderr, without messing in the internals (doesn't even    *: use dynamic_buffer).    *:    *: This function is intended only for convenient use inside a    *: debugger session; it can't be used from inside the code.    */   void gdb_backtrace (   #ifdef PIKE_THREADS    THREAD_T thread_id
pike.git/src/interpret.c:1801:    file = get_program_line (f->context.prog, &line);    }    if (file) {    fprintf (stderr, "%s:%d: ", file->str, line);    free_string(file);    } else    fputs ("unknown program: ", stderr);       if (f->current_object && f->current_object->prog) {    /* FIXME: Wide string identifiers. */ -  fputs (ID_FROM_INT (f->current_object->prog, f->fun)->name->str, stderr); +  fputs (safe_idname_from_int(f->current_object->prog, f->fun), stderr);    fputc ('(', stderr);    }    else    fputs ("unknown function(", stderr);       if(!f->locals)    {    args=0;    }else{    args=f->num_args;
pike.git/src/interpret.c:1905:    if (i < arg->u.string->len)    fprintf (stderr, "+[%ld]", (long) (arg->u.string->len - i));    break;    }       case T_FUNCTION:    /* FIXME: Wide string identifiers. */    if(arg->subtype == FUNCTION_BUILTIN)    fputs (arg->u.efun->name->str, stderr);    else if(arg->u.object->prog) -  fputs (ID_FROM_INT(arg->u.object->prog,arg->subtype)->name->str, stderr); +  fputs (safe_idname_from_int(arg->u.object->prog,arg->subtype), stderr);    else    fputc ('0', stderr);    break;       case T_OBJECT: {    struct program *p = arg->u.object->prog;    if (p && p->num_linenumbers) {    file = get_program_line (p, &line);    fprintf (stderr, "object(%s:%d)", file->str, line);    free_string(file);