add constraint debug
diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c
index 96c9394..40d1381 100644
--- a/libasn1compiler/asn1c_C.c
+++ b/libasn1compiler/asn1c_C.c
@@ -2151,7 +2151,8 @@
INDENT(+1);
- range = asn1constraint_compute_OER_range(etype, expr->combined_constraints,
+ range = asn1constraint_compute_OER_range(expr->Identifier, etype,
+ expr->combined_constraints,
ACT_EL_RANGE, 0, 0, 0);
if(emit_single_member_OER_constraint(arg, range, 0)) {
return -1;
@@ -2160,7 +2161,8 @@
OUT(",\n");
- range = asn1constraint_compute_OER_range(etype, expr->combined_constraints,
+ range = asn1constraint_compute_OER_range(expr->Identifier, etype,
+ expr->combined_constraints,
ACT_CT_SIZE, 0, 0, 0);
if(emit_single_member_OER_constraint(arg, range, "SIZE")) {
return -1;
@@ -2233,7 +2235,7 @@
if(emit_single_member_PER_constraint(arg, &tmprng, 0, 0))
return -1;
} else if(etype & ASN_STRING_KM_MASK) {
- range = asn1constraint_compute_PER_range(etype,
+ range = asn1constraint_compute_PER_range(expr->Identifier, etype,
expr->combined_constraints, ACT_CT_FROM,
0, 0, 0);
DEBUG("Emitting FROM constraint for %s", expr->Identifier);
@@ -2263,7 +2265,7 @@
avoid:
asn1constraint_range_free(range);
} else {
- range = asn1constraint_compute_PER_range(etype,
+ range = asn1constraint_compute_PER_range(expr->Identifier, etype,
expr->combined_constraints, ACT_EL_RANGE,
0, 0, 0);
if(emit_single_member_PER_constraint(arg, range, 0, 0))
@@ -2272,7 +2274,7 @@
}
OUT(",\n");
- range = asn1constraint_compute_PER_range(etype,
+ range = asn1constraint_compute_PER_range(expr->Identifier, etype,
expr->combined_constraints, ACT_CT_SIZE, 0, 0, 0);
if(emit_single_member_PER_constraint(arg, range, 0, "SIZE"))
return -1;
diff --git a/libasn1compiler/asn1c_constraint.c b/libasn1compiler/asn1c_constraint.c
index df9ca68..bf42268 100644
--- a/libasn1compiler/asn1c_constraint.c
+++ b/libasn1compiler/asn1c_constraint.c
@@ -43,8 +43,8 @@
etype = _find_terminal_type(arg);
- r_value=asn1constraint_compute_PER_range(etype, ct, ACT_EL_RANGE,0,0,0);
- r_size =asn1constraint_compute_PER_range(etype, ct, ACT_CT_SIZE, 0,0,0);
+ r_value=asn1constraint_compute_constraint_range(expr->Identifier, etype, ct, ACT_EL_RANGE,0,0,0);
+ r_size =asn1constraint_compute_constraint_range(expr->Identifier, etype, ct, ACT_CT_SIZE, 0,0,0);
if(r_value) {
if(r_value->incompatible
|| r_value->empty_constraint
@@ -251,7 +251,7 @@
etype = _find_terminal_type(arg);
- range = asn1constraint_compute_PER_range(etype, ct, ACT_CT_FROM, 0,0,0);
+ range = asn1constraint_compute_constraint_range(arg->expr->Identifier, etype, ct, ACT_CT_FROM, 0,0,0);
if(!range) return 0;
if(range->incompatible
diff --git a/libasn1compiler/asn1c_misc.c b/libasn1compiler/asn1c_misc.c
index 40be51b..2bcc699 100644
--- a/libasn1compiler/asn1c_misc.c
+++ b/libasn1compiler/asn1c_misc.c
@@ -359,7 +359,8 @@
* applied (non-standard! but we can deal with this) to the type.
* Check the range.
*/
- range = asn1constraint_compute_PER_range(expr->expr_type,
+ range = asn1constraint_compute_constraint_range(expr->Identifier,
+ expr->expr_type,
expr->combined_constraints, ACT_CT_SIZE, 0, 0,
CPR_simulate_fbless_SIZE);
if(range) {
@@ -375,7 +376,7 @@
/*
* Third, pull up the PER visible range of the INTEGER.
*/
- range = asn1constraint_compute_PER_range(expr->expr_type,
+ range = asn1constraint_compute_PER_range(expr->Identifier, expr->expr_type,
expr->combined_constraints, ACT_EL_RANGE, 0, 0, 0);
if(!range
diff --git a/libasn1fix/asn1fix.c b/libasn1fix/asn1fix.c
index e6af2f2..124576f 100644
--- a/libasn1fix/asn1fix.c
+++ b/libasn1fix/asn1fix.c
@@ -448,7 +448,8 @@
RET2RVAL(ret, rvalue);
for(i = 0; i < sizeof(test_types)/sizeof(test_types[0]); i++) {
- range = asn1constraint_compute_PER_range(
+ range = asn1constraint_compute_constraint_range(
+ arg->expr->Identifier,
etype,
arg->expr->combined_constraints,
test_types[i], 0, 0,
diff --git a/libasn1fix/asn1fix_crange.c b/libasn1fix/asn1fix_crange.c
index 907ffd6..b38befe 100644
--- a/libasn1fix/asn1fix_crange.c
+++ b/libasn1fix/asn1fix_crange.c
@@ -699,17 +699,21 @@
}
asn1cnst_range_t *
-asn1constraint_compute_OER_range(asn1p_expr_type_e expr_type, const asn1p_constraint_t *ct, enum asn1p_constraint_type_e type, const asn1cnst_range_t *minmax, int *exmet, enum cpr_flags cpr_flags) {
- return asn1constraint_compute_constraint_range(expr_type, ct, type, minmax, exmet, cpr_flags);
+asn1constraint_compute_OER_range(const char *dbg_name, asn1p_expr_type_e expr_type, const asn1p_constraint_t *ct, enum asn1p_constraint_type_e requested_ct_type
+, const asn1cnst_range_t *minmax, int *exmet, enum cpr_flags cpr_flags) {
+ return asn1constraint_compute_constraint_range(dbg_name, expr_type, ct, requested_ct_type, minmax, exmet, cpr_flags | CPR_strict_OER_visibility);
}
asn1cnst_range_t *
-asn1constraint_compute_PER_range(asn1p_expr_type_e expr_type, const asn1p_constraint_t *ct, enum asn1p_constraint_type_e type, const asn1cnst_range_t *minmax, int *exmet, enum cpr_flags cpr_flags) {
- return asn1constraint_compute_constraint_range(expr_type, ct, type, minmax, exmet, cpr_flags);
+asn1constraint_compute_PER_range(const char *dbg_name, asn1p_expr_type_e expr_type, const asn1p_constraint_t *ct, enum asn1p_constraint_type_e requested_ct_type
+, const asn1cnst_range_t *minmax, int *exmet, enum cpr_flags cpr_flags) {
+ if(0) return asn1constraint_compute_constraint_range(dbg_name, expr_type, ct, requested_ct_type, minmax, exmet, cpr_flags | CPR_strict_PER_visibility);
+ /* Due to pecularities of PER constraint handling, we don't enable strict PER visibility upfront here. */
+ return asn1constraint_compute_constraint_range(dbg_name, expr_type, ct, requested_ct_type, minmax, exmet, cpr_flags);
}
asn1cnst_range_t *
-asn1constraint_compute_constraint_range(asn1p_expr_type_e expr_type, const asn1p_constraint_t *ct, enum asn1p_constraint_type_e type, const asn1cnst_range_t *minmax, int *exmet, enum cpr_flags cpr_flags) {
+asn1constraint_compute_constraint_range(const char *dbg_name, asn1p_expr_type_e expr_type, const asn1p_constraint_t *ct, enum asn1p_constraint_type_e type, const asn1cnst_range_t *minmax, int *exmet, enum cpr_flags cpr_flags) {
asn1cnst_range_t *range;
asn1cnst_range_t *tmp;
asn1p_value_t *vmin;
@@ -824,7 +828,7 @@
return range;
}
assert(ct->el_count == 1);
- tmp = asn1constraint_compute_constraint_range(expr_type,
+ tmp = asn1constraint_compute_constraint_range(dbg_name, expr_type,
ct->elements[0], type, minmax, exmet, cpr_flags);
if(tmp) {
_range_free(range);
@@ -843,7 +847,7 @@
/* AND constraints, one after another. */
for(i = 0; i < ct->el_count; i++) {
- tmp = asn1constraint_compute_constraint_range(expr_type,
+ tmp = asn1constraint_compute_constraint_range(dbg_name, expr_type,
ct->elements[i], type,
ct->type==ACT_CA_SET?range:minmax, exmet,
cpr_flags);
@@ -913,7 +917,7 @@
*/
tmp = 0;
for(i = 0; i < ct->el_count; i++) {
- tmp = asn1constraint_compute_constraint_range(expr_type,
+ tmp = asn1constraint_compute_constraint_range(dbg_name, expr_type,
ct->elements[i], type, minmax, exmet,
cpr_flags);
if(!tmp) {
@@ -946,7 +950,7 @@
* Canonicalizator will do the union magic.
*/
for(; i < ct->el_count; i++) {
- tmp = asn1constraint_compute_constraint_range(expr_type,
+ tmp = asn1constraint_compute_constraint_range(dbg_name, expr_type,
ct->elements[i], type, minmax, exmet,
cpr_flags);
if(!tmp) {
@@ -1021,7 +1025,7 @@
*/
assert(ct->el_count >= 1);
_range_free(range);
- range = asn1constraint_compute_constraint_range(expr_type,
+ range = asn1constraint_compute_constraint_range(dbg_name, expr_type,
ct->elements[0], type, minmax, exmet, cpr_flags);
return range;
default:
diff --git a/libasn1fix/asn1fix_crange.h b/libasn1fix/asn1fix_crange.h
index 5c2fad0..a539508 100644
--- a/libasn1fix/asn1fix_crange.h
+++ b/libasn1fix/asn1fix_crange.h
@@ -45,20 +45,23 @@
CPR_strict_PER_visibility = 0x02,
CPR_simulate_fbless_SIZE = 0x04,
};
-asn1cnst_range_t *asn1constraint_compute_OER_range(asn1p_expr_type_e expr_type,
+asn1cnst_range_t *asn1constraint_compute_OER_range(const char *dbg_name,
+ asn1p_expr_type_e expr_type,
const asn1p_constraint_t *ct,
enum asn1p_constraint_type_e required_type,
const asn1cnst_range_t *minmax,
int *expectation_met,
enum cpr_flags);
-asn1cnst_range_t *asn1constraint_compute_PER_range(asn1p_expr_type_e expr_type,
+asn1cnst_range_t *asn1constraint_compute_PER_range(const char *dbg_name,
+ asn1p_expr_type_e expr_type,
const asn1p_constraint_t *ct,
enum asn1p_constraint_type_e required_type,
const asn1cnst_range_t *minmax,
int *expectation_met,
enum cpr_flags);
/* Base implementation */
-asn1cnst_range_t *asn1constraint_compute_constraint_range(asn1p_expr_type_e expr_type,
+asn1cnst_range_t *asn1constraint_compute_constraint_range(const char *dbg_name,
+ asn1p_expr_type_e expr_type,
const asn1p_constraint_t *ct,
enum asn1p_constraint_type_e required_type,
const asn1cnst_range_t *minmax,
diff --git a/libasn1print/asn1print.c b/libasn1print/asn1print.c
index f24545c..9d0004f 100644
--- a/libasn1print/asn1print.c
+++ b/libasn1print/asn1print.c
@@ -483,12 +483,12 @@
}
static int
-asn1print_constraint_explain_type(asn1p_expr_type_e expr_type, asn1p_constraint_t *ct, enum asn1p_constraint_type_e type, enum cpr_flags cpr) {
+asn1print_constraint_explain_type(const char *dbg_name, asn1p_expr_type_e expr_type, asn1p_constraint_t *ct, enum asn1p_constraint_type_e type, enum cpr_flags cpr) {
asn1cnst_range_t *range;
int as_char = (type==ACT_CT_FROM);
int i;
- range = asn1constraint_compute_constraint_range(expr_type, ct, type, 0, 0, cpr);
+ range = asn1constraint_compute_constraint_range(dbg_name, expr_type, ct, type, 0, 0, cpr);
if(!range) return -1;
if(range->incompatible) return 0;
@@ -538,14 +538,14 @@
}
static int
-asn1print_constraint_explain(asn1p_expr_type_e expr_type,
+asn1print_constraint_explain(const char *dbg_name, asn1p_expr_type_e expr_type,
asn1p_constraint_t *ct, enum cpr_flags cpr) {
- asn1print_constraint_explain_type(expr_type, ct, ACT_EL_RANGE, cpr);
+ asn1print_constraint_explain_type(dbg_name, expr_type, ct, ACT_EL_RANGE, cpr);
safe_printf(" ");
- asn1print_constraint_explain_type(expr_type, ct, ACT_CT_SIZE, cpr);
+ asn1print_constraint_explain_type(dbg_name, expr_type, ct, ACT_CT_SIZE, cpr);
safe_printf(" ");
- asn1print_constraint_explain_type(expr_type, ct, ACT_CT_FROM, cpr);
+ asn1print_constraint_explain_type(dbg_name, expr_type, ct, ACT_CT_FROM, cpr);
return 0;
}
@@ -758,15 +758,18 @@
if(top_parent) {
safe_printf("\n-- Practical constraints (%s): ",
top_parent->Identifier);
- asn1print_constraint_explain(top_parent->expr_type,
+ asn1print_constraint_explain(top_parent->Identifier,
+ top_parent->expr_type,
tc->combined_constraints, 0);
safe_printf("\n-- OER-visible constraints (%s): ",
top_parent->Identifier);
- asn1print_constraint_explain(top_parent->expr_type,
+ asn1print_constraint_explain(top_parent->Identifier,
+ top_parent->expr_type,
tc->combined_constraints, CPR_strict_OER_visibility);
safe_printf("\n-- PER-visible constraints (%s): ",
top_parent->Identifier);
- asn1print_constraint_explain(top_parent->expr_type,
+ asn1print_constraint_explain(top_parent->Identifier,
+ top_parent->expr_type,
tc->combined_constraints, CPR_strict_PER_visibility);
}
safe_printf("\n");