better debugging
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@812 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/libasn1fix/asn1fix_retrieve.c b/libasn1fix/asn1fix_retrieve.c
index cbf6bae..f9e593b 100644
--- a/libasn1fix/asn1fix_retrieve.c
+++ b/libasn1fix/asn1fix_retrieve.c
@@ -48,6 +48,13 @@
*/
mod = asn1f_lookup_module(arg, xp->from, xp->from_oid);
if(mod == NULL) {
+ /* Conditional debug */
+ if(!(arg->expr->_mark & TM_BROKEN)) {
+ arg->expr->_mark |= TM_BROKEN;
+ FATAL("Cannot find module %s "
+ "mentioned for %s at line %d",
+ xp->from, name, arg->expr->_lineno);
+ }
/* ENOENT/ETOOMANYREFS */
return NULL;
}
@@ -220,6 +227,7 @@
*/
if(imports_from) {
asn1p_ref_t tmpref = *ref;
+ asn1p_expr_t *expr;
if(modulename) {
/*
* The modulename is specified inside this reference.
@@ -230,7 +238,26 @@
tmpref.comp_count--;
assert(tmpref.comp_count > 0);
}
- return asn1f_lookup_symbol(arg, imports_from, &tmpref);
+
+ expr = asn1f_lookup_symbol(arg, imports_from, &tmpref);
+ if(!expr && !(arg->expr->_mark & TM_BROKEN)) {
+ arg->expr->_mark |= TM_BROKEN;
+ if(modulename) {
+ FATAL("Module %s referred by %s in module %s "
+ "does not contain the requested symbol",
+ imports_from->Identifier,
+ asn1f_printable_reference(ref),
+ mod->Identifier);
+ } else {
+ FATAL("Module %s referred in IMPORTS section "
+ "for %s of module %s does not contain "
+ "the requested symbol",
+ imports_from->Identifier,
+ asn1f_printable_reference(ref),
+ mod->Identifier);
+ }
+ }
+ return expr;
}
/*
@@ -316,7 +343,7 @@
}
/*
- * Lookup inside the default module.
+ * Lookup inside the default module and its IMPORTS section.
*/
tc = asn1f_lookup_symbol(arg, expr->module, ref);
if(tc == NULL) {
@@ -367,8 +394,14 @@
return 0;
}
- DEBUG("Symbol \"%s\" contradicts with EXPORTS of module %s",
- name, mod->Identifier);
+ /* Conditional debug */
+ if(!(arg->expr->_mark & TM_BROKEN)) {
+ arg->expr->_mark |= TM_BROKEN;
+ FATAL("EXPORTS section of module %s in %s "
+ "does not mention %s at line %d",
+ mod->Identifier, mod->source_file_name, name,
+ arg->expr->_lineno);
+ }
errno = ESRCH;
return -1;