limit debug output log

This commit is contained in:
Lev Walkin 2014-09-17 01:19:31 -07:00
parent 58ecc7b4e3
commit 15d38f45df
11 changed files with 29 additions and 20 deletions

View File

@ -45,6 +45,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
memcpy(buf + buf_offset, buffer, size);
b = buf + buf_offset;
bend = b + size;
#ifdef EMIT_ASN_DEBUG
fprintf(stderr, "=> [");
for(; b < bend; b++) {
if(*b >= 32 && *b < 127 && *b != '%')
@ -53,6 +54,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
fprintf(stderr, "%%%02x", *b);
}
fprintf(stderr, "]:%zd\n", size);
#endif
buf_offset += size;
return 0;
}
@ -131,16 +133,18 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char
st = 0;
do {
fprintf(stderr, "Decoding bytes %d..%d (left %d)\n",
ASN_DEBUG("Decoding bytes %d..%d (left %d)",
fbuf_offset,
fbuf_chunk < fbuf_left
? fbuf_chunk : fbuf_left,
fbuf_left);
#ifdef EMIT_ASN_DEBUG
if(st) {
fprintf(stderr, "=== currently ===\n");
asn_fprint(stderr, &asn_DEF_PDU, st);
fprintf(stderr, "=== end ===\n");
}
#endif
switch(how) {
case AS_XER:
rval = xer_decode(0, &asn_DEF_PDU, (void **)&st,
@ -157,9 +161,9 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char
rval.consumed = 0; /* Not restartable */
ASN_STRUCT_FREE(asn_DEF_PDU, st);
st = 0;
fprintf(stderr, "-> PER wants more\n");
ASN_DEBUG("-> PER wants more");
} else {
fprintf(stderr, "-> PER ret %d/%ld\n",
ASN_DEBUG("-> PER ret %d/%ld",
rval.code, rval.consumed);
/* uper_decode() returns _bits_ */
rval.consumed += 7;

View File

@ -45,6 +45,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
memcpy(buf + buf_offset, buffer, size);
b = buf + buf_offset;
bend = b + size;
#ifdef EMIT_ASN_DEBUG
fprintf(stderr, "=> [");
for(; b < bend; b++) {
if(*b >= 32 && *b < 127 && *b != '%')
@ -53,6 +54,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
fprintf(stderr, "%%%02x", *b);
}
fprintf(stderr, "]:%zd\n", size);
#endif
buf_offset += size;
return 0;
}
@ -131,16 +133,18 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char
st = 0;
do {
fprintf(stderr, "Decoding bytes %d..%d (left %d)\n",
ASN_DEBUG("Decoding bytes %d..%d (left %d)",
fbuf_offset,
fbuf_chunk < fbuf_left
? fbuf_chunk : fbuf_left,
fbuf_left);
#ifdef EMIT_ASN_DEBUG
if(st) {
fprintf(stderr, "=== currently ===\n");
asn_fprint(stderr, &asn_DEF_PDU, st);
fprintf(stderr, "=== end ===\n");
}
#endif
switch(how) {
case AS_XER:
rval = xer_decode(0, &asn_DEF_PDU, (void **)&st,
@ -157,9 +161,9 @@ load_object_from(const char *fname, enum expectation expectation, unsigned char
rval.consumed = 0; /* Not restartable */
ASN_STRUCT_FREE(asn_DEF_PDU, st);
st = 0;
fprintf(stderr, "-> PER wants more\n");
ASN_DEBUG("-> PER wants more");
} else {
fprintf(stderr, "-> PER ret %d/%zd\n",
ASN_DEBUG("-> PER ret %d/%zd",
rval.code, rval.consumed);
/* uper_decode() returns _bits_ */
rval.consumed += 7;

View File

@ -35,6 +35,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
memcpy(buf + buf_offset, buffer, size);
b = buf + buf_offset;
bend = b + size;
#ifdef EMIT_ASN_DEBUG
fprintf(stderr, "=> [");
for(; b < bend; b++) {
if(*b >= 32 && *b < 127 && *b != '%')
@ -43,6 +44,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
fprintf(stderr, "%%%02x", *b);
}
fprintf(stderr, "]:%zd\n", size);
#endif
buf_offset += size;
return 0;
}
@ -152,10 +154,10 @@ load_object_from(const char *fname, unsigned char *fbuf, size_t size, enum encty
rval.consumed = 0; /* Not restartable */
ASN_STRUCT_FREE(asn_DEF_PDU, st);
st = 0;
fprintf(stderr, "-> PER wants more\n");
ASN_DEBUG("-> PER wants more");
}
} else {
fprintf(stderr, "-> PER ret %d/%zd mf=%d\n",
ASN_DEBUG("-> PER ret %d/%zd mf=%d",
rval.code, rval.consumed, mustfail);
/* uper_decode() returns _bits_ */
rval.consumed += 7;

View File

@ -125,16 +125,18 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size,
st = 0;
do {
fprintf(stderr, "Decoding bytes %d..%d (left %d)\n",
ASN_DEBUG("Decoding bytes %d..%d (left %d)",
fbuf_offset,
fbuf_chunk < fbuf_left
? fbuf_chunk : fbuf_left,
fbuf_left);
#ifdef EMIT_ASN_DEBUG
if(st) {
fprintf(stderr, "=== currently ===\n");
asn_fprint(stderr, &asn_DEF_PDU, st);
fprintf(stderr, "=== end ===\n");
}
#endif
rval = zer_decode(0, &asn_DEF_PDU, (void **)&st,
fbuf + fbuf_offset,
fbuf_chunk < fbuf_left

View File

@ -114,16 +114,18 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size,
st = 0;
do {
fprintf(stderr, "Decoding bytes %d..%d (left %d)\n",
ASN_DEBUG("Decoding bytes %d..%d (left %d)",
fbuf_offset,
fbuf_chunk < fbuf_left
? fbuf_chunk : fbuf_left,
fbuf_left);
#ifdef EMIT_ASN_DEBUG
if(st) {
fprintf(stderr, "=== currently ===\n");
asn_fprint(stderr, &asn_DEF_PDU, st);
fprintf(stderr, "=== end ===\n");
}
#endif
rval = zer_decode(0, &asn_DEF_PDU, (void **)&st,
fbuf + fbuf_offset,
fbuf_chunk < fbuf_left

View File

@ -1,5 +1,3 @@
AM_CPPFLAGS = -I$(top_srcdir)/skeletons
check_PROGRAMS = \
check-ber_tlv_tag \
check-length \
@ -14,6 +12,7 @@ check_PROGRAMS = \
check-PER \
check-PER-INTEGER
AM_CPPFLAGS = -I$(top_srcdir)/skeletons $(TESTSUITE_CFLAGS)
AM_LDFLAGS = $(top_builddir)/skeletons/libasn1cskeletons.la
LDADD = -lm

View File

@ -248,7 +248,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
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
LDADD = -lm
TESTS = $(check_PROGRAMS)

View File

@ -3,7 +3,6 @@
#include <time.h>
#include <sys/time.h>
#define EMIT_ASN_DEBUG 1
#include <OCTET_STRING.h>
#include <BIT_STRING.h>

View File

@ -1,7 +1,6 @@
#include <stdio.h>
#include <assert.h>
#define EMIT_ASN_DEBUG 1
#include <INTEGER.h>
#include <INTEGER.c>
#include <per_support.c>

View File

@ -1,7 +1,6 @@
#include <stdio.h>
#include <assert.h>
#define EMIT_ASN_DEBUG 1
#include <per_support.c>
#include <per_support.h>
@ -290,14 +289,14 @@ check_per_encoding_auto() {
ret = per_put_few_bits(&po, -1, prior);
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);
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,
(int)(po.buffer - po.tmpspace), (int)po.nboff);
assert((po.buffer - po.tmpspace) * 8 + po.nboff == prior + next);

View File

@ -2,7 +2,6 @@
#include <assert.h>
#include <math.h>
#define EMIT_ASN_DEBUG 1
#include <REAL.h>
static char reconstructed[2][512];