pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:63:    string_builder_append_disassembly_data(data->debug_buf, \    data->debug_pos, \    (((char *)data->buf.end) - \    data->buf.length) + \    data->debug_pos, \    data->buf.dst, \    NULL); \    data->debug_pos = end_pos; \    } \    } while(0) +  + #define DECODE_WERR_COMMENT(COMMENT, X...) do { \ +  string_builder_sprintf_disassembly(data->debug_buf, \ +  data->debug_ptr, \ +  data->data + data->debug_ptr, \ +  data->data + data->ptr, \ +  COMMENT, X); \ +  data->debug_ptr = data->ptr; \ +  } while(0) + #define DECODE_WERR(X...) DECODE_WERR_COMMENT(NULL, X) + #define DECODE_FLUSH() do { \ +  if (data->debug_ptr < data->ptr) { \ +  string_builder_append_disassembly_data(data->debug_buf, \ +  data->debug_ptr, \ +  data->data + \ +  data->debug_ptr, \ +  data->data + data->ptr, \ +  NULL); \ +  data->debug_ptr = data->ptr; \ +  } \ +  } while(0)   #ifndef PIKE_DEBUG   #error ENCODE_DEBUG requires PIKE_DEBUG   #endif   #else   #define EDB(N,X) do { debug_malloc_touch(data); } while (0)   #endif      #ifdef _AIX   #include <net/nh.h>   #endif
pike.git/src/encode.c:2441:    int pass;    int delay_counter;    struct pike_string *raw;    struct decode_data *next;   #ifdef PIKE_THREADS    struct thread_state *thread_state;    struct object *thread_obj;   #endif   #ifdef ENCODE_DEBUG    int debug, depth; +  ptrdiff_t debug_ptr; +  struct string_builder *debug_buf;   #endif   };      static struct object *decoder_codec (struct decode_data *data)   {    struct pike_string *decoder_str;    if (data->codec) return data->codec;    MAKE_CONST_STRING (decoder_str, "Decoder");    return data->codec = lookup_codec (decoder_str);   }
pike.git/src/encode.c:4509:   {    int delay;    debug_malloc_touch (data);    delay = 0;    free_decode_data (data, delay, 1);   }      static INT32 my_decode(struct pike_string *tmp,    struct object *codec   #ifdef ENCODE_DEBUG -  , int debug +  , int debug, struct string_builder *debug_buf   #endif    )   {    struct decode_data *data;    ONERROR err; -  + #ifdef ENCODE_DEBUG +  struct string_builder buf; + #endif    -  +  /* FIXME: Why not use CYCLIC? */    /* Attempt to avoid infinite recursion on circular structures. */    for (data = current_decode; data; data=data->next) {    if (data->raw == tmp &&    (codec ? data->codec == codec : !data->explicit_codec)   #ifdef PIKE_THREADS    && data->thread_state == Pike_interpreter.thread_state   #endif    ) {    struct svalue *res;    struct svalue val = SVALUE_INIT_INT (COUNTER_START);
pike.git/src/encode.c:4557:    data->unfinished_placeholders = NULL;    data->delay_counter = 0;    data->raw = tmp;    data->next = current_decode;   #ifdef PIKE_THREADS    data->thread_state = Pike_interpreter.thread_state;    data->thread_obj = Pike_interpreter.thread_state->thread_obj;   #endif   #ifdef ENCODE_DEBUG    data->debug = debug; +  data->debug_buf = debug_buf; +  data->debug_ptr = 0; +  if (data->debug && !debug_buf) { +  debug_buf = &buf; +  init_string_builder(debug_buf, 0); +  }    data->depth = -2;   #endif       if (tmp->size_shift ||    data->len < 5 ||    GETC() != 182 ||    GETC() != 'k' ||    GETC() != 'e' ||    GETC() != '0')    {
pike.git/src/encode.c:4584: Inside #if defined(PIKE_THREADS)
   if (data->codec) add_ref (data->codec);   #ifdef PIKE_THREADS    add_ref (data->thread_obj);   #endif    SET_ONERROR(err, error_free_decode_data, data);       low_do_decode (data);       UNSET_ONERROR(err);    +  EDB(1, { +  DECODE_FLUSH(); +  }); +  + #ifdef ENCODE_DEBUG +  if (debug_buf == &buf) { +  write_and_reset_string_builder(2, debug_buf); +  free_string_builder(debug_buf); +  } + #endif +     {    int delay;    delay = 0;    free_decode_data (data, delay, 0);    }       return 1;   }      /*! @class MasterObject
pike.git/src/encode.c:4901:    *! @seealso    *! @[encode_value()], @[encode_value_canonic()]    */   void f_decode_value(INT32 args)   {    struct pike_string *s;    struct object *codec;      #ifdef ENCODE_DEBUG    int debug = 0; +  struct string_builder *debug_buf = NULL;   #endif /* ENCODE_DEBUG */       check_all_args(NULL, args,    BIT_STRING,    BIT_VOID | BIT_OBJECT | BIT_ZERO,   #ifdef ENCODE_DEBUG    /* This argument is only an internal debug helper.    * It's intentionally not part of the function    * prototype, to keep the argument position free for    * other uses in the future. */ -  BIT_VOID | BIT_INT, +  BIT_VOID | BIT_INT | BIT_OBJECT,   #endif    0);       s = Pike_sp[-args].u.string;       switch (args) {    default:   #ifdef ENCODE_DEBUG -  +  if (TYPEOF(Pike_sp[2-args]) == PIKE_T_OBJECT) { +  struct object *sb = Pike_sp[2-args].u.object; +  if ((debug_buf = string_builder_from_string_buffer(sb))) { +  debug = 1; +  } +  } else {    debug = Pike_sp[2-args].u.integer; -  +  }    /* Fall through. */    case 2:   #endif    if (TYPEOF(Pike_sp[1-args]) == T_OBJECT) {    if (SUBTYPEOF(Pike_sp[1-args])) {    struct decode_data data;    memset (&data, 0, sizeof (data));    data.data_str = s; /* Not refcounted. */    decode_error(&data, NULL,    "The codec may not be a subtyped object yet.\n");
pike.git/src/encode.c:4949:    push_object (clone_object (MasterCodec_program, 0));    args++;    codec = Pike_sp[-1].u.object;    }    else    codec = NULL;    }       if(!my_decode(s, codec   #ifdef ENCODE_DEBUG -  , debug +  , debug, debug_buf   #endif    ))    {    char *v=s->str;    ptrdiff_t l=s->len;    struct decode_data data;    ONERROR uwp;    memset (&data, 0, sizeof (data));    data.data_str = s; /* Not refcounted. */    SET_ONERROR (uwp, restore_current_decode, current_decode);    current_decode = &data;    rec_restore_value(&v, &l);    CALL_AND_UNSET_ONERROR (uwp);    }    assign_svalue(Pike_sp-args-1, Pike_sp-1);    pop_n_elems(args);   }