Commit 15d38f45 authored by Lev Walkin's avatar Lev Walkin

limit debug output log

parent 58ecc7b4
...@@ -45,6 +45,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { ...@@ -45,6 +45,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
memcpy(buf + buf_offset, buffer, size); memcpy(buf + buf_offset, buffer, size);
b = buf + buf_offset; b = buf + buf_offset;
bend = b + size; bend = b + size;
#ifdef EMIT_ASN_DEBUG
fprintf(stderr, "=> ["); fprintf(stderr, "=> [");
for(; b < bend; b++) { for(; b < bend; b++) {
if(*b >= 32 && *b < 127 && *b != '%') if(*b >= 32 && *b < 127 && *b != '%')
...@@ -53,6 +54,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { ...@@ -53,6 +54,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
fprintf(stderr, "%%%02x", *b); fprintf(stderr, "%%%02x", *b);
} }
fprintf(stderr, "]:%zd\n", size); fprintf(stderr, "]:%zd\n", size);
#endif
buf_offset += size; buf_offset += size;
return 0; return 0;
} }
...@@ -131,16 +133,18 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char ...@@ -131,16 +133,18 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char
st = 0; st = 0;
do { do {
fprintf(stderr, "Decoding bytes %d..%d (left %d)\n", ASN_DEBUG("Decoding bytes %d..%d (left %d)",
fbuf_offset, fbuf_offset,
fbuf_chunk < fbuf_left fbuf_chunk < fbuf_left
? fbuf_chunk : fbuf_left, ? fbuf_chunk : fbuf_left,
fbuf_left); fbuf_left);
#ifdef EMIT_ASN_DEBUG
if(st) { if(st) {
fprintf(stderr, "=== currently ===\n"); fprintf(stderr, "=== currently ===\n");
asn_fprint(stderr, &asn_DEF_PDU, st); asn_fprint(stderr, &asn_DEF_PDU, st);
fprintf(stderr, "=== end ===\n"); fprintf(stderr, "=== end ===\n");
} }
#endif
switch(how) { switch(how) {
case AS_XER: case AS_XER:
rval = xer_decode(0, &asn_DEF_PDU, (void **)&st, rval = xer_decode(0, &asn_DEF_PDU, (void **)&st,
...@@ -157,9 +161,9 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char ...@@ -157,9 +161,9 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char
rval.consumed = 0; /* Not restartable */ rval.consumed = 0; /* Not restartable */
ASN_STRUCT_FREE(asn_DEF_PDU, st); ASN_STRUCT_FREE(asn_DEF_PDU, st);
st = 0; st = 0;
fprintf(stderr, "-> PER wants more\n"); ASN_DEBUG("-> PER wants more");
} else { } else {
fprintf(stderr, "-> PER ret %d/%ld\n", ASN_DEBUG("-> PER ret %d/%ld",
rval.code, rval.consumed); rval.code, rval.consumed);
/* uper_decode() returns _bits_ */ /* uper_decode() returns _bits_ */
rval.consumed += 7; rval.consumed += 7;
......
...@@ -45,6 +45,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { ...@@ -45,6 +45,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
memcpy(buf + buf_offset, buffer, size); memcpy(buf + buf_offset, buffer, size);
b = buf + buf_offset; b = buf + buf_offset;
bend = b + size; bend = b + size;
#ifdef EMIT_ASN_DEBUG
fprintf(stderr, "=> ["); fprintf(stderr, "=> [");
for(; b < bend; b++) { for(; b < bend; b++) {
if(*b >= 32 && *b < 127 && *b != '%') if(*b >= 32 && *b < 127 && *b != '%')
...@@ -53,6 +54,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { ...@@ -53,6 +54,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
fprintf(stderr, "%%%02x", *b); fprintf(stderr, "%%%02x", *b);
} }
fprintf(stderr, "]:%zd\n", size); fprintf(stderr, "]:%zd\n", size);
#endif
buf_offset += size; buf_offset += size;
return 0; return 0;
} }
...@@ -131,16 +133,18 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char ...@@ -131,16 +133,18 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char
st = 0; st = 0;
do { do {
fprintf(stderr, "Decoding bytes %d..%d (left %d)\n", ASN_DEBUG("Decoding bytes %d..%d (left %d)",
fbuf_offset, fbuf_offset,
fbuf_chunk < fbuf_left fbuf_chunk < fbuf_left
? fbuf_chunk : fbuf_left, ? fbuf_chunk : fbuf_left,
fbuf_left); fbuf_left);
#ifdef EMIT_ASN_DEBUG
if(st) { if(st) {
fprintf(stderr, "=== currently ===\n"); fprintf(stderr, "=== currently ===\n");
asn_fprint(stderr, &asn_DEF_PDU, st); asn_fprint(stderr, &asn_DEF_PDU, st);
fprintf(stderr, "=== end ===\n"); fprintf(stderr, "=== end ===\n");
} }
#endif
switch(how) { switch(how) {
case AS_XER: case AS_XER:
rval = xer_decode(0, &asn_DEF_PDU, (void **)&st, rval = xer_decode(0, &asn_DEF_PDU, (void **)&st,
...@@ -157,9 +161,9 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char ...@@ -157,9 +161,9 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char
rval.consumed = 0; /* Not restartable */ rval.consumed = 0; /* Not restartable */
ASN_STRUCT_FREE(asn_DEF_PDU, st); ASN_STRUCT_FREE(asn_DEF_PDU, st);
st = 0; st = 0;
fprintf(stderr, "-> PER wants more\n"); ASN_DEBUG("-> PER wants more");
} else { } else {
fprintf(stderr, "-> PER ret %d/%zd\n", ASN_DEBUG("-> PER ret %d/%zd",
rval.code, rval.consumed); rval.code, rval.consumed);
/* uper_decode() returns _bits_ */ /* uper_decode() returns _bits_ */
rval.consumed += 7; rval.consumed += 7;
......
...@@ -35,6 +35,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { ...@@ -35,6 +35,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
memcpy(buf + buf_offset, buffer, size); memcpy(buf + buf_offset, buffer, size);
b = buf + buf_offset; b = buf + buf_offset;
bend = b + size; bend = b + size;
#ifdef EMIT_ASN_DEBUG
fprintf(stderr, "=> ["); fprintf(stderr, "=> [");
for(; b < bend; b++) { for(; b < bend; b++) {
if(*b >= 32 && *b < 127 && *b != '%') if(*b >= 32 && *b < 127 && *b != '%')
...@@ -43,6 +44,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { ...@@ -43,6 +44,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
fprintf(stderr, "%%%02x", *b); fprintf(stderr, "%%%02x", *b);
} }
fprintf(stderr, "]:%zd\n", size); fprintf(stderr, "]:%zd\n", size);
#endif
buf_offset += size; buf_offset += size;
return 0; return 0;
} }
...@@ -152,10 +154,10 @@ load_object_from(const char *fname, unsigned char *fbuf, size_t size, enum encty ...@@ -152,10 +154,10 @@ load_object_from(const char *fname, unsigned char *fbuf, size_t size, enum encty
rval.consumed = 0; /* Not restartable */ rval.consumed = 0; /* Not restartable */
ASN_STRUCT_FREE(asn_DEF_PDU, st); ASN_STRUCT_FREE(asn_DEF_PDU, st);
st = 0; st = 0;
fprintf(stderr, "-> PER wants more\n"); ASN_DEBUG("-> PER wants more");
} }
} else { } else {
fprintf(stderr, "-> PER ret %d/%zd mf=%d\n", ASN_DEBUG("-> PER ret %d/%zd mf=%d",
rval.code, rval.consumed, mustfail); rval.code, rval.consumed, mustfail);
/* uper_decode() returns _bits_ */ /* uper_decode() returns _bits_ */
rval.consumed += 7; rval.consumed += 7;
......
...@@ -125,16 +125,18 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size, ...@@ -125,16 +125,18 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size,
st = 0; st = 0;
do { do {
fprintf(stderr, "Decoding bytes %d..%d (left %d)\n", ASN_DEBUG("Decoding bytes %d..%d (left %d)",
fbuf_offset, fbuf_offset,
fbuf_chunk < fbuf_left fbuf_chunk < fbuf_left
? fbuf_chunk : fbuf_left, ? fbuf_chunk : fbuf_left,
fbuf_left); fbuf_left);
#ifdef EMIT_ASN_DEBUG
if(st) { if(st) {
fprintf(stderr, "=== currently ===\n"); fprintf(stderr, "=== currently ===\n");
asn_fprint(stderr, &asn_DEF_PDU, st); asn_fprint(stderr, &asn_DEF_PDU, st);
fprintf(stderr, "=== end ===\n"); fprintf(stderr, "=== end ===\n");
} }
#endif
rval = zer_decode(0, &asn_DEF_PDU, (void **)&st, rval = zer_decode(0, &asn_DEF_PDU, (void **)&st,
fbuf + fbuf_offset, fbuf + fbuf_offset,
fbuf_chunk < fbuf_left fbuf_chunk < fbuf_left
......
...@@ -114,16 +114,18 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size, ...@@ -114,16 +114,18 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size,
st = 0; st = 0;
do { do {
fprintf(stderr, "Decoding bytes %d..%d (left %d)\n", ASN_DEBUG("Decoding bytes %d..%d (left %d)",
fbuf_offset, fbuf_offset,
fbuf_chunk < fbuf_left fbuf_chunk < fbuf_left
? fbuf_chunk : fbuf_left, ? fbuf_chunk : fbuf_left,
fbuf_left); fbuf_left);
#ifdef EMIT_ASN_DEBUG
if(st) { if(st) {
fprintf(stderr, "=== currently ===\n"); fprintf(stderr, "=== currently ===\n");
asn_fprint(stderr, &asn_DEF_PDU, st); asn_fprint(stderr, &asn_DEF_PDU, st);
fprintf(stderr, "=== end ===\n"); fprintf(stderr, "=== end ===\n");
} }
#endif
rval = zer_decode(0, &asn_DEF_PDU, (void **)&st, rval = zer_decode(0, &asn_DEF_PDU, (void **)&st,
fbuf + fbuf_offset, fbuf + fbuf_offset,
fbuf_chunk < fbuf_left fbuf_chunk < fbuf_left
......
AM_CPPFLAGS = -I$(top_srcdir)/skeletons
check_PROGRAMS = \ check_PROGRAMS = \
check-ber_tlv_tag \ check-ber_tlv_tag \
check-length \ check-length \
...@@ -14,6 +12,7 @@ check_PROGRAMS = \ ...@@ -14,6 +12,7 @@ check_PROGRAMS = \
check-PER \ check-PER \
check-PER-INTEGER check-PER-INTEGER
AM_CPPFLAGS = -I$(top_srcdir)/skeletons $(TESTSUITE_CFLAGS)
AM_LDFLAGS = $(top_builddir)/skeletons/libasn1cskeletons.la AM_LDFLAGS = $(top_builddir)/skeletons/libasn1cskeletons.la
LDADD = -lm LDADD = -lm
......
...@@ -248,7 +248,7 @@ target_alias = @target_alias@ ...@@ -248,7 +248,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir)/skeletons AM_CPPFLAGS = -I$(top_srcdir)/skeletons $(TESTSUITE_CFLAGS)
AM_LDFLAGS = $(top_builddir)/skeletons/libasn1cskeletons.la AM_LDFLAGS = $(top_builddir)/skeletons/libasn1cskeletons.la
LDADD = -lm LDADD = -lm
TESTS = $(check_PROGRAMS) TESTS = $(check_PROGRAMS)
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>
#define EMIT_ASN_DEBUG 1
#include <OCTET_STRING.h> #include <OCTET_STRING.h>
#include <BIT_STRING.h> #include <BIT_STRING.h>
......
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#define EMIT_ASN_DEBUG 1
#include <INTEGER.h> #include <INTEGER.h>
#include <INTEGER.c> #include <INTEGER.c>
#include <per_support.c> #include <per_support.c>
......
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#define EMIT_ASN_DEBUG 1
#include <per_support.c> #include <per_support.c>
#include <per_support.h> #include <per_support.h>
...@@ -290,14 +289,14 @@ check_per_encoding_auto() { ...@@ -290,14 +289,14 @@ check_per_encoding_auto() {
ret = per_put_few_bits(&po, -1, prior); ret = per_put_few_bits(&po, -1, prior);
assert(ret == 0); assert(ret == 0);
fprintf(stderr, " (out{nboff=%d,nbits=%d,buf_offset=%d})\n", (int)po.nboff, (int)po.nbits, (int)(po.buffer - po.tmpspace)); ASN_DEBUG(" (out{nboff=%d,nbits=%d,buf_offset=%d})", (int)po.nboff, (int)po.nbits, (int)(po.buffer - po.tmpspace));
ret = per_put_few_bits(&po, -1, next); ret = per_put_few_bits(&po, -1, next);
assert(ret == 0); assert(ret == 0);
fprintf(stderr, " (out{nboff=%d,nbits=%d,buf_offset=%d})\n", (int)po.nboff, (int)po.nbits, (int)(po.buffer - po.tmpspace)); ASN_DEBUG(" (out{nboff=%d,nbits=%d,buf_offset=%d})", (int)po.nboff, (int)po.nbits, (int)(po.buffer - po.tmpspace));
fprintf(stderr, "Putting %d + %d bits (%d/%d), got %d bytes and %d bits\n", ASN_DEBUG("Putting %d + %d bits (%d/%d), got %d bytes and %d bits",
prior, next, (prior + next) / 8, (prior + next) % 8, prior, next, (prior + next) / 8, (prior + next) % 8,
(int)(po.buffer - po.tmpspace), (int)po.nboff); (int)(po.buffer - po.tmpspace), (int)po.nboff);
assert((po.buffer - po.tmpspace) * 8 + po.nboff == prior + next); assert((po.buffer - po.tmpspace) * 8 + po.nboff == prior + next);
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#define EMIT_ASN_DEBUG 1
#include <REAL.h> #include <REAL.h>
static char reconstructed[2][512]; static char reconstructed[2][512];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment