summaryrefslogtreecommitdiff
path: root/libctf/ctf-dedup.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-07-27 16:45:15 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-08-27 13:15:43 +0100
commit926c9e7665707d2f2eeb705b410e485f6930ab38 (patch)
tree8a0a3a001ca33b62ea9b8edd7b91cbfa12953233 /libctf/ctf-dedup.c
parent987cf30ad80c7c13f713aa8e4ca3e1dbf08e9d63 (diff)
downloadbinutils-gdb-926c9e7665707d2f2eeb705b410e485f6930ab38.tar.gz
libctf, binutils, include, ld: gettextize and improve error handling
This commit follows on from the earlier commit "libctf, ld, binutils: add textual error/warning reporting for libctf" and converts every error in libctf that was reported using ctf_dprintf to use ctf_err_warn instead, gettextizing them in the process, using N_() where necessary to avoid doing gettext calls unless an error message is actually generated, and rephrasing some error messages for ease of translation. This requires a slight change in the ctf_errwarning_next API: this API is public but has not been in a release yet, so can still change freely. The problem is that many errors are emitted at open time (whether opening of a CTF dict, or opening of a CTF archive): the former of these throws away its incompletely-initialized ctf_file_t rather than return it, and the latter has no ctf_file_t at all. So errors and warnings emitted at open time cannot be stored in the ctf_file_t, and have to go elsewhere. We put them in a static local in ctf-subr.c (which is not very thread-safe: a later commit will improve things here): ctf_err_warn with a NULL fp adds to this list, and the public interface ctf_errwarning_next with a NULL fp retrieves from it. We need a slight exception from the usual iterator rules in this case: with a NULL fp, there is nowhere to store the ECTF_NEXT_END "error" which signifies the end of iteration, so we add a new err parameter to ctf_errwarning_next which is used to report such iteration-related errors. (If an fp is provided -- i.e., if not reporting open errors -- this is optional, but even if it's optional it's still an API change. This is actually useful from a usability POV as well, since ctf_errwarning_next is usually called when there's been an error, so overwriting the error code with ECTF_NEXT_END is not very helpful! So, unusually, ctf_errwarning_next now uses the passed fp for its error code *only* if no errp pointer is passed in, and leaves it untouched otherwise.) ld, objdump and readelf are adapted to call ctf_errwarning_next with a NULL fp to report open errors where appropriate. The ctf_err_warn API also has to change, gaining a new error-number parameter which is used to add the error message corresponding to that error number into the debug stream when LIBCTF_DEBUG is enabled: changing this API is easy at this point since we are already touching all existing calls to gettextize them. We need this because the debug stream should contain the errno's message, but the error reported in the error/warning stream should *not*, because the caller will probably report it themselves at failure time regardless, and reporting it in every error message that leads up to it leads to a ridiculous chattering on failure, which is likely to end up as ridiculous chattering on stderr (trimmed a bit): CTF error: `ld/testsuite/ld-ctf/A.c (0): lookup failure for type 3: flags 1: The parent CTF dictionary is unavailable' CTF error: `ld/testsuite/ld-ctf/A.c (0): struct/union member type hashing error during type hashing for type 80000001, kind 6: The parent CTF dictionary is unavailable' CTF error: `deduplicating link variable emission failed for ld/testsuite/ld-ctf/A.c: The parent CTF dictionary is unavailable' ld/.libs/lt-ld-new: warning: CTF linking failed; output will have no CTF section: `The parent CTF dictionary is unavailable' We only need to be told that the parent CTF dictionary is unavailable *once*, not over and over again! errmsgs are still emitted on warning generation, because warnings do not usually lead to a failure propagated up to the caller and reported there. Debug-stream messages are not translated. If translation is turned on, there will be a mixture of English and translated messages in the debug stream, but rather that than burden the translators with debug-only output. binutils/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * objdump.c (dump_ctf_archive_member): Move error- reporting... (dump_ctf_errs): ... into this separate function. (dump_ctf): Call it on open errors. * readelf.c (dump_ctf_archive_member): Move error- reporting... (dump_ctf_errs): ... into this separate function. Support calls with NULL fp. Adjust for new err parameter to ctf_errwarning_next. (dump_section_as_ctf): Call it on open errors. include/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * ctf-api.h (ctf_errwarning_next): New err parameter. ld/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * ldlang.c (lang_ctf_errs_warnings): Support calls with NULL fp. Adjust for new err parameter to ctf_errwarning_next. Only check for assertion failures when fp is non-NULL. (ldlang_open_ctf): Call it on open errors. * testsuite/ld-ctf/ctf.exp: Always use the C locale to avoid breaking the diags tests. libctf/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * ctf-subr.c (open_errors): New list. (ctf_err_warn): Calls with NULL fp append to open_errors. Add err parameter, and use it to decorate the debug stream with errmsgs. (ctf_err_warn_to_open): Splice errors from a CTF dict into the open_errors. (ctf_errwarning_next): Calls with NULL fp report from open_errors. New err param to report iteration errors (including end-of-iteration) when fp is NULL. (ctf_assert_fail_internal): Adjust ctf_err_warn call for new err parameter: gettextize. * ctf-impl.h (ctfo_get_vbytes): Add ctf_file_t parameter. (LCTF_VBYTES): Adjust. (ctf_err_warn_to_open): New. (ctf_err_warn): Adjust. (ctf_bundle): Used in only one place: move... * ctf-create.c: ... here. (enumcmp): Use ctf_err_warn, not ctf_dprintf, passing the err number down as needed. Don't emit the errmsg. Gettextize. (membcmp): Likewise. (ctf_add_type_internal): Likewise. (ctf_write_mem): Likewise. (ctf_compress_write): Likewise. Report errors writing the header or body. (ctf_write): Likewise. * ctf-archive.c (ctf_arc_write_fd): Use ctf_err_warn, not ctf_dprintf, and gettextize, as above. (ctf_arc_write): Likewise. (ctf_arc_bufopen): Likewise. (ctf_arc_open_internal): Likewise. * ctf-labels.c (ctf_label_iter): Likewise. * ctf-open-bfd.c (ctf_bfdclose): Likewise. (ctf_bfdopen): Likewise. (ctf_bfdopen_ctfsect): Likewise. (ctf_fdopen): Likewise. * ctf-string.c (ctf_str_write_strtab): Likewise. * ctf-types.c (ctf_type_resolve): Likewise. * ctf-open.c (get_vbytes_common): Likewise. Pass down the ctf dict. (get_vbytes_v1): Pass down the ctf dict. (get_vbytes_v2): Likewise. (flip_ctf): Likewise. (flip_types): Likewise. Use ctf_err_warn, not ctf_dprintf, and gettextize, as above. (upgrade_types_v1): Adjust calls. (init_types): Use ctf_err_warn, not ctf_dprintf, as above. (ctf_bufopen_internal): Likewise. Adjust calls. Transplant errors emitted into individual dicts into the open errors if this turns out to be a failed open in the end. * ctf-dump.c (ctf_dump_format_type): Adjust ctf_err_warn for new err argument. Gettextize. Don't emit the errmsg. (ctf_dump_funcs): Likewise. Collapse err label into its only case. (ctf_dump_type): Likewise. * ctf-link.c (ctf_create_per_cu): Adjust ctf_err_warn for new err argument. Gettextize. Don't emit the errmsg. (ctf_link_one_type): Likewise. (ctf_link_lazy_open): Likewise. (ctf_link_one_input_archive): Likewise. (ctf_link_deduplicating_count_inputs): Likewise. (ctf_link_deduplicating_open_inputs): Likewise. (ctf_link_deduplicating_close_inputs): Likewise. (ctf_link_deduplicating): Likewise. (ctf_link): Likewise. (ctf_link_deduplicating_per_cu): Likewise. Add some missed ctf_set_errnos to obscure error cases. * ctf-dedup.c (ctf_dedup_rhash_type): Adjust ctf_err_warn for new err argument. Gettextize. Don't emit the errmsg. (ctf_dedup_populate_mappings): Likewise. (ctf_dedup_detect_name_ambiguity): Likewise. (ctf_dedup_init): Likewise. (ctf_dedup_multiple_input_dicts): Likewise. (ctf_dedup_conflictify_unshared): Likewise. (ctf_dedup): Likewise. (ctf_dedup_rwalk_one_output_mapping): Likewise. (ctf_dedup_id_to_target): Likewise. (ctf_dedup_emit_type): Likewise. (ctf_dedup_emit_struct_members): Likewise. (ctf_dedup_populate_type_mapping): Likewise. (ctf_dedup_populate_type_mappings): Likewise. (ctf_dedup_emit): Likewise. (ctf_dedup_hash_type): Likewise. Fix a bit of messed-up error status setting. (ctf_dedup_rwalk_one_output_mapping): Likewise. Don't hide unknown-type-kind messages (which signify file corruption).
Diffstat (limited to 'libctf/ctf-dedup.c')
-rw-r--r--libctf/ctf-dedup.c290
1 files changed, 144 insertions, 146 deletions
diff --git a/libctf/ctf-dedup.c b/libctf/ctf-dedup.c
index 77b34f4539d..b58b815b84d 100644
--- a/libctf/ctf-dedup.c
+++ b/libctf/ctf-dedup.c
@@ -581,7 +581,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
#define ADD_CITER(citers, hval) \
do \
{ \
- whaterr = "updating citers"; \
+ whaterr = N_("error updating citers"); \
if (!citers) \
if ((citers = ctf_dynset_create (htab_hash_string, \
ctf_dynset_eq_string, \
@@ -610,14 +610,13 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
if ((hval = intern (fp, strdup (hashbuf))) == NULL)
{
- ctf_err_warn (fp, 0, "%s (%i): out of memory during forwarding-stub "
- "hashing for type with GID %p; errno: %s",
- ctf_link_input_name (input), input_num, type_id,
- strerror (errno));
+ ctf_err_warn (fp, 0, 0, _("%s (%i): out of memory during forwarding-"
+ "stub hashing for type with GID %p"),
+ ctf_link_input_name (input), input_num, type_id);
return NULL; /* errno is set for us. */
}
- /* In share--duplicated link mode, make sure the origin of this type is
+ /* In share-duplicated link mode, make sure the origin of this type is
recorded, even if this is a type in a parent dict which will not be
directly traversed. */
if (d->cd_link_flags & CTF_LINK_SHARE_DUPLICATED
@@ -680,7 +679,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
depth);
if (ctf_type_encoding (input, type, &ep) < 0)
{
- whaterr = "encoding";
+ whaterr = N_("error getting encoding");
goto err;
}
ctf_dedup_sha1_add (&hash, &ep, sizeof (ctf_encoding_t), "encoding",
@@ -699,7 +698,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
child_type, flags, depth,
populate_fun)) == NULL)
{
- whaterr = "referenced type hashing";
+ whaterr = N_("error doing referenced type hashing");
goto err;
}
ctf_dedup_sha1_add (&hash, hval, strlen (hval) + 1, "referenced type",
@@ -728,7 +727,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
child_type, flags, depth,
populate_fun)) == NULL)
{
- whaterr = "slice-referenced type hashing";
+ whaterr = N_("error doing slice-referenced type hashing");
goto err;
}
ctf_dedup_sha1_add (&hash, hval, strlen (hval) + 1, "sliced type",
@@ -753,7 +752,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
if (ctf_array_info (input, type, &ar) < 0)
{
- whaterr = "array info";
+ whaterr = N_("error getting array info");
goto err;
}
@@ -761,7 +760,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
ar.ctr_contents, flags, depth,
populate_fun)) == NULL)
{
- whaterr = "array contents type hashing";
+ whaterr = N_("error doing array contents type hashing");
goto err;
}
ctf_dedup_sha1_add (&hash, hval, strlen (hval) + 1, "array contents",
@@ -772,7 +771,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
ar.ctr_index, flags, depth,
populate_fun)) == NULL)
{
- whaterr = "array index type hashing";
+ whaterr = N_("error doing array index type hashing");
goto err;
}
ctf_dedup_sha1_add (&hash, hval, strlen (hval) + 1, "array index",
@@ -791,7 +790,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
if (ctf_func_type_info (input, type, &fi) < 0)
{
- whaterr = "func type info";
+ whaterr = N_("error getting func type info");
goto err;
}
@@ -799,7 +798,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
fi.ctc_return, flags, depth,
populate_fun)) == NULL)
{
- whaterr = "func return type";
+ whaterr = N_("error getting func return type");
goto err;
}
ctf_dedup_sha1_add (&hash, hval, strlen (hval) + 1, "func return",
@@ -812,14 +811,14 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
if ((args = calloc (fi.ctc_argc, sizeof (ctf_id_t))) == NULL)
{
- whaterr = "memory allocation";
+ whaterr = N_("error doing memory allocation");
goto err;
}
if (ctf_func_type_args (input, type, fi.ctc_argc, args) < 0)
{
free (args);
- whaterr = "func arg type";
+ whaterr = N_("error getting func arg type");
goto err;
}
for (j = 0; j < fi.ctc_argc; j++)
@@ -829,7 +828,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
populate_fun)) == NULL)
{
free (args);
- whaterr = "func arg type hashing";
+ whaterr = N_("error doing func arg type hashing");
goto err;
}
ctf_dedup_sha1_add (&hash, hval, strlen (hval) + 1, "func arg type",
@@ -854,7 +853,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
}
if (ctf_errno (input) != ECTF_NEXT_END)
{
- whaterr = "enum member iteration";
+ whaterr = N_("error doing enum member iteration");
goto err;
}
break;
@@ -887,7 +886,7 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
input_num, membtype, flags, depth,
populate_fun)) == NULL)
{
- whaterr = "struct/union member type hashing";
+ whaterr = N_("error doing struct/union member type hashing");
goto iterr;
}
@@ -899,26 +898,26 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
}
if (ctf_errno (input) != ECTF_NEXT_END)
{
- whaterr = "struct/union member iteration";
+ whaterr = N_("error doing struct/union member iteration");
goto err;
}
break;
}
default:
- whaterr = "unknown type kind";
+ whaterr = N_("error: unknown type kind");
goto err;
}
ctf_sha1_fini (&hash, hashbuf);
if ((hval = intern (fp, strdup (hashbuf))) == NULL)
{
- whaterr = "hash internment";
+ whaterr = N_("cannot intern hash");
goto oom;
}
/* Populate the citers for this type's subtypes, now the hash for the type
itself is known. */
- whaterr = "citer tracking";
+ whaterr = N_("error tracking citers");
if (citer)
{
@@ -957,17 +956,15 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
ctf_next_destroy (i);
err:
ctf_sha1_fini (&hash, NULL);
- ctf_err_warn (fp, 0, "%s (%i): %s error during type hashing for "
- "type %lx, kind %i: CTF error: %s; errno: %s",
- ctf_link_input_name (input), input_num, whaterr, type,
- kind, ctf_errmsg (ctf_errno (fp)), strerror (errno));
+ ctf_err_warn (fp, 0, 0, _("%s (%i): %s: during type hashing for type %lx, "
+ "kind %i"), ctf_link_input_name (input),
+ input_num, gettext (whaterr), type, kind);
return NULL;
oom:
ctf_set_errno (fp, errno);
- ctf_err_warn (fp, 0, "%s (%i): %s error during type hashing for "
- "type %lx, kind %i: CTF error: %s; errno: %s",
- ctf_link_input_name (input), input_num, whaterr, type,
- kind, ctf_errmsg (ctf_errno (fp)), strerror (errno));
+ ctf_err_warn (fp, 0, 0, _("%s (%i): %s: during type hashing for type %lx, "
+ "kind %i"), ctf_link_input_name (input),
+ input_num, gettext (whaterr), type, kind);
return NULL;
}
@@ -1034,8 +1031,10 @@ ctf_dedup_hash_type (ctf_file_t *fp, ctf_file_t *input,
if ((tp = ctf_lookup_by_id (&input, type)) == NULL)
{
- ctf_err_warn (fp, 0, "%s (%i): lookup failure for type %lx: flags %x",
- ctf_link_input_name (input), input_num, type, flags);
+ ctf_set_errno (fp, ctf_errno (input));
+ ctf_err_warn (fp, 0, 0, _("%s (%i): lookup failure for type %lx: "
+ "flags %x"), ctf_link_input_name (input),
+ input_num, type, flags);
return NULL; /* errno is set for us. */
}
@@ -1106,14 +1105,14 @@ ctf_dedup_hash_type (ctf_file_t *fp, ctf_file_t *input,
if (ctf_dynhash_cinsert (d->cd_type_hashes, type_id, hval) < 0)
{
- whaterr = "hash caching";
+ whaterr = N_("error hash caching");
goto oom;
}
if (populate_fun (fp, input, inputs, input_num, type, type_id,
decorated, hval) < 0)
{
- whaterr = "population function";
+ whaterr = N_("error calling population function");
goto err; /* errno is set for us. */
}
}
@@ -1127,11 +1126,10 @@ ctf_dedup_hash_type (ctf_file_t *fp, ctf_file_t *input,
oom:
ctf_set_errno (fp, errno);
err:
- ctf_err_warn (fp, 0, "%s (%i): %s error during type hashing, type %lx, "
- "kind %i: CTF errno: %s; errno: %s",
- ctf_link_input_name (input), input_num, whaterr, type,
- kind, ctf_errmsg (ctf_errno (fp)),
- strerror (errno));
+ ctf_err_warn (fp, 0, 0, _("%s (%i): %s: during type hashing, "
+ "type %lx, kind %i"),
+ ctf_link_input_name (input), input_num,
+ gettext (whaterr), type, kind);
return NULL;
}
@@ -1218,7 +1216,7 @@ ctf_dedup_populate_mappings (ctf_file_t *fp, ctf_file_t *input _libctf_unused_,
ctf_id_t bar = CTF_DEDUP_GID_TO_TYPE (one_id);
if (ctf_type_kind_unsliced (foo, bar) != orig_kind)
{
- ctf_err_warn (fp, 1, "added wrong kind to output mapping "
+ ctf_err_warn (fp, 1, 0, "added wrong kind to output mapping "
"for hash %s named %s: %p/%lx from %s is "
"kind %i, but newly-added %p/%lx from %s is "
"kind %i", hval,
@@ -1410,7 +1408,7 @@ ctf_dedup_detect_name_ambiguity (ctf_file_t *fp, ctf_file_t **inputs)
void *k;
void *v;
int err;
- const char *erm;
+ const char *whaterr;
/* Go through cd_name_counts for all CTF namespaces in turn. */
@@ -1474,7 +1472,7 @@ ctf_dedup_detect_name_ambiguity (ctf_file_t *fp, ctf_file_t **inputs)
}
if (err != ECTF_NEXT_END)
{
- erm = "marking conflicting structs/unions";
+ whaterr = N_("error marking conflicting structs/unions");
goto iterr;
}
}
@@ -1511,7 +1509,7 @@ ctf_dedup_detect_name_ambiguity (ctf_file_t *fp, ctf_file_t **inputs)
}
if (err != ECTF_NEXT_END)
{
- erm = "finding commonest conflicting type";
+ whaterr = N_("error finding commonest conflicting type");
goto iterr;
}
@@ -1526,20 +1524,20 @@ ctf_dedup_detect_name_ambiguity (ctf_file_t *fp, ctf_file_t **inputs)
hval, (const char *) k);
if (ctf_dedup_mark_conflicting_hash (fp, hval) < 0)
{
- erm = "marking hashes as conflicting";
+ whaterr = N_("error marking hashes as conflicting");
goto err;
}
}
if (err != ECTF_NEXT_END)
{
- erm = "marking uncommon conflicting types";
+ whaterr = N_("marking uncommon conflicting types");
goto iterr;
}
}
}
if (err != ECTF_NEXT_END)
{
- erm = "scanning for ambiguous names";
+ whaterr = N_("scanning for ambiguous names");
goto iterr;
}
@@ -1547,11 +1545,11 @@ ctf_dedup_detect_name_ambiguity (ctf_file_t *fp, ctf_file_t **inputs)
err:
ctf_next_destroy (i);
- ctf_err_warn (fp, 0, "%s: %s", erm, ctf_errmsg (ctf_errno (fp)));
- return -1;
+ ctf_err_warn (fp, 0, 0, "%s", gettext (whaterr));
+ return -1; /* errno is set for us. */
iterr:
- ctf_err_warn (fp, 0, "iteration failed %s: %s", erm, ctf_errmsg (err));
+ ctf_err_warn (fp, 0, err, _("iteration failed: %s"), gettext (whaterr));
return ctf_set_errno (fp, err);
assert_err:
@@ -1642,8 +1640,8 @@ ctf_dedup_init (ctf_file_t *fp)
return 0;
oom:
- ctf_err_warn (fp, 0, "ctf_dedup_init: cannot initialize: "
- "out of memory.");
+ ctf_err_warn (fp, 0, ENOMEM, _("ctf_dedup_init: cannot initialize: "
+ "out of memory"));
return ctf_set_errno (fp, ENOMEM);
}
@@ -1740,10 +1738,9 @@ ctf_dedup_multiple_input_dicts (ctf_file_t *output, ctf_file_t **inputs,
}
if ((err != ECTF_NEXT_END) && (err != 0))
{
- ctf_err_warn (output, 0, "propagating conflictedness: %s",
- ctf_errmsg (err));
- ctf_set_errno (output, err);
- return -1;
+ ctf_err_warn (output, 0, err, _("iteration error "
+ "propagating conflictedness"));
+ return ctf_set_errno (output, err);
}
if (multiple)
@@ -1836,11 +1833,9 @@ ctf_dedup_conflictify_unshared (ctf_file_t *output, ctf_file_t **inputs)
err = ctf_errno (output);
ctf_next_destroy (i);
iterr:
- ctf_set_errno (output, err);
ctf_dynset_destroy (to_mark);
- ctf_err_warn (output, 0, "conflictifying unshared types: %s",
- ctf_errmsg (ctf_errno (output)));
- return -1;
+ ctf_err_warn (output, 0, err, _("conflictifying unshared types"));
+ return ctf_set_errno (output, err);
}
/* The core deduplicator. Populate cd_output_mapping in the output ctf_dedup
@@ -1899,9 +1894,10 @@ ctf_dedup (ctf_file_t *output, ctf_file_t **inputs, uint32_t ninputs,
}
if (ctf_errno (inputs[i]) != ECTF_NEXT_END)
{
- ctf_err_warn (output, 0, "iteration failure computing type "
- "hashes: %s", ctf_errmsg (ctf_errno (inputs[i])));
- return ctf_set_errno (output, ctf_errno (inputs[i]));
+ ctf_set_errno (output, ctf_errno (inputs[i]));
+ ctf_err_warn (output, 0, 0, _("iteration failure "
+ "computing type hashes"));
+ return -1;
}
}
@@ -2013,7 +2009,7 @@ ctf_dedup_rwalk_one_output_mapping (ctf_file_t *output,
hashval = ctf_dynhash_lookup (d->cd_type_hashes, type_id); \
if (!ctf_assert (output, hashval)) \
{ \
- whaterr = "looking up ID in type hashes"; \
+ whaterr = N_("error looking up ID in type hashes"); \
goto errlabel; \
} \
ctf_dprintf ("ID %i/%lx has hash %s\n", cited_type_input_num, type, \
@@ -2048,7 +2044,7 @@ ctf_dedup_rwalk_one_output_mapping (ctf_file_t *output,
case CTF_K_POINTER:
case CTF_K_SLICE:
CTF_TYPE_WALK (ctf_type_reference (fp, type), err,
- "Referenced type walk");
+ N_("error during referenced type walk"));
break;
case CTF_K_ARRAY:
@@ -2057,12 +2053,14 @@ ctf_dedup_rwalk_one_output_mapping (ctf_file_t *output,
if (ctf_array_info (fp, type, &ar) < 0)
{
- whaterr = "array info lookup";
+ whaterr = N_("error during array info lookup");
goto err_msg;
}
- CTF_TYPE_WALK (ar.ctr_contents, err, "Array contents type walk");
- CTF_TYPE_WALK (ar.ctr_index, err, "Array index type walk");
+ CTF_TYPE_WALK (ar.ctr_contents, err,
+ N_("error during array contents type walk"));
+ CTF_TYPE_WALK (ar.ctr_index, err,
+ N_("error during array index type walk"));
break;
}
@@ -2074,27 +2072,29 @@ ctf_dedup_rwalk_one_output_mapping (ctf_file_t *output,
if (ctf_func_type_info (fp, type, &fi) < 0)
{
- whaterr = "func type info lookup";
+ whaterr = N_("error during func type info lookup");
goto err_msg;
}
- CTF_TYPE_WALK (fi.ctc_return, err, "Func return type walk");
+ CTF_TYPE_WALK (fi.ctc_return, err,
+ N_("error during func return type walk"));
if ((args = calloc (fi.ctc_argc, sizeof (ctf_id_t))) == NULL)
{
- whaterr = "memory allocation";
+ whaterr = N_("error doing memory allocation");
goto err_msg;
}
if (ctf_func_type_args (fp, type, fi.ctc_argc, args) < 0)
{
- whaterr = "func arg type lookup";
+ whaterr = N_("error doing func arg type lookup");
free (args);
goto err_msg;
}
for (j = 0; j < fi.ctc_argc; j++)
- CTF_TYPE_WALK (args[j], err_free_args, "Func arg type walk");
+ CTF_TYPE_WALK (args[j], err_free_args,
+ N_("error during Func arg type walk"));
free (args);
break;
@@ -2108,8 +2108,8 @@ ctf_dedup_rwalk_one_output_mapping (ctf_file_t *output,
emitted later, in a separate pass. */
break;
default:
- whaterr = "unknown type kind";
- goto err;
+ whaterr = N_("CTF dict corruption: unknown type kind");
+ goto err_msg;
}
return visit_fun (hval, output, inputs, ninputs, parents, visited, fp, type,
@@ -2117,8 +2117,8 @@ ctf_dedup_rwalk_one_output_mapping (ctf_file_t *output,
err_msg:
ctf_set_errno (output, ctf_errno (fp));
- ctf_err_warn (fp, 0, "%s during type walking in %s at ID %lx: %s", whaterr,
- ctf_link_input_name (fp), type, ctf_errmsg (ctf_errno (fp)));
+ ctf_err_warn (output, 0, 0, _("%s in input file %s at type ID %lx"),
+ gettext (whaterr), ctf_link_input_name (fp), type);
err:
return -1;
}
@@ -2157,8 +2157,8 @@ ctf_dedup_rwalk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
type_ids = ctf_dynhash_lookup (d->cd_output_mapping, hval);
if (!type_ids)
{
- ctf_err_warn (output, 0, "looked up type kind by nonexistent "
- "hash %s.", hval);
+ ctf_err_warn (output, 0, ECTF_INTERNAL,
+ _("looked up type kind by nonexistent hash %s"), hval);
return ctf_set_errno (output, ECTF_INTERNAL);
}
@@ -2175,8 +2175,8 @@ ctf_dedup_rwalk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
visited = 0;
if (ctf_dynset_cinsert (already_visited, hval) < 0)
{
- ctf_err_warn (output, 0, "out of memory tracking already-visited "
- "types.");
+ ctf_err_warn (output, 0, ENOMEM,
+ _("out of memory tracking already-visited types"));
return ctf_set_errno (output, ENOMEM);
}
}
@@ -2213,8 +2213,7 @@ ctf_dedup_rwalk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
}
if (err != ECTF_NEXT_END)
{
- ctf_err_warn (output, 0, "walking many types with one hash: %s",
- ctf_errmsg (err));
+ ctf_err_warn (output, 0, err, _("cannot walk conflicted type"));
return ctf_set_errno (output, err);
}
@@ -2336,8 +2335,7 @@ ctf_dedup_walk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
}
if (err != ECTF_NEXT_END)
{
- ctf_err_warn (output, 0, "recursing over output mapping: %s",
- ctf_errmsg (err));
+ ctf_err_warn (output, 0, err, _("cannot recurse over output mapping"));
ctf_set_errno (output, err);
goto err;
}
@@ -2490,8 +2488,8 @@ ctf_dedup_id_to_target (ctf_file_t *output, ctf_file_t *target,
break;
case -1:
ctf_set_errno (err_fp, ctf_errno (output));
- ctf_err_warn (err_fp, 0, "adding synthetic forward for type %i/%lx: "
- "%s", input_num, id, ctf_errmsg (ctf_errno (err_fp)));
+ ctf_err_warn (err_fp, 0, 0, _("cannot add synthetic forward for type "
+ "%i/%lx"), input_num, id);
return -1;
default:
return emitted_forward;
@@ -2518,10 +2516,10 @@ ctf_dedup_id_to_target (ctf_file_t *output, ctf_file_t *target,
case 0: /* No forward needed. */
break;
case -1:
- ctf_set_errno (err_fp, ctf_errno (output));
- ctf_err_warn (err_fp, 0, "adding synthetic forward for type %i/%lx: "
- "%s", input_num, id, ctf_errmsg (ctf_errno (err_fp)));
- return -1;
+ ctf_err_warn (err_fp, 0, ctf_errno (output),
+ _("cannot add synthetic forward for type %i/%lx"),
+ input_num, id);
+ return ctf_set_errno (err_fp, ctf_errno (output));
default:
return emitted_forward;
}
@@ -2570,7 +2568,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
ctf_id_t ref;
ctf_id_t maybe_dup = 0;
ctf_encoding_t ep;
- const char *erm;
+ const char *errtype;
int emission_hashed = 0;
/* We don't want to re-emit something we've already emitted. */
@@ -2600,10 +2598,10 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
if ((target = ctf_create (&err)) == NULL)
{
- ctf_err_warn (output, 0, "cannot create per-CU CTF archive "
- "for CU %s: %s", ctf_link_input_name (input),
- ctf_errmsg (err)); ctf_set_errno (output, err);
- return -1;
+ ctf_err_warn (output, 0, err,
+ _("cannot create per-CU CTF archive for CU %s"),
+ ctf_link_input_name (input));
+ return ctf_set_errno (output, err);
}
ctf_import_unref (target, output);
@@ -2621,11 +2619,10 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
real_input = input;
if ((tp = ctf_lookup_by_id (&real_input, type)) == NULL)
{
- ctf_err_warn (output, 0, "%s: lookup failure for type %lx: %s",
- ctf_link_input_name (real_input), type,
- ctf_errmsg (ctf_errno (input)));
- ctf_set_errno (output, ctf_errno (input));
- return -1; /* errno is set for us. */
+ ctf_err_warn (output, 0, ctf_errno (input),
+ _("%s: lookup failure for type %lx"),
+ ctf_link_input_name (real_input), type);
+ return ctf_set_errno (output, ctf_errno (input));
}
name = ctf_strraw (real_input, tp->ctt_name);
@@ -2667,7 +2664,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
/* This will do nothing if the type to which this forwards already exists,
and will be replaced with such a type if it appears later. */
- erm = "forward";
+ errtype = _("forward");
if ((new_type = ctf_add_forward (target, isroot, name,
ctf_type_kind_forwarded (input, type)))
== CTF_ERR)
@@ -2676,7 +2673,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
case CTF_K_FLOAT:
case CTF_K_INTEGER:
- erm = "float/int";
+ errtype = _("float/int");
if (ctf_type_encoding (input, type, &ep) < 0)
goto err_input; /* errno is set for us. */
if ((new_type = ctf_add_encoded (target, isroot, name, &ep, kind))
@@ -2687,7 +2684,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
case CTF_K_ENUM:
{
int val;
- erm = "enum";
+ errtype = _("enum");
if ((new_type = ctf_add_enum (target, isroot, name)) == CTF_ERR)
goto err_input; /* errno is set for us. */
@@ -2695,10 +2692,11 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
{
if (ctf_add_enumerator (target, new_type, name, val) < 0)
{
- ctf_err_warn (target, 0, "%s (%i): cannot add enumeration "
- "value %s from input type %lx: %s",
+ ctf_err_warn (target, 0, ctf_errno (target),
+ _("%s (%i): cannot add enumeration value %s "
+ "from input type %lx"),
ctf_link_input_name (input), input_num, name,
- type, ctf_errmsg (ctf_errno (target)));
+ type);
ctf_next_destroy (i);
return ctf_set_errno (output, ctf_errno (target));
}
@@ -2709,7 +2707,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
}
case CTF_K_TYPEDEF:
- erm = "typedef";
+ errtype = _("typedef");
ref = ctf_type_reference (input, type);
if ((ref = ctf_dedup_id_to_target (output, target, inputs, ninputs,
@@ -2725,7 +2723,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
case CTF_K_CONST:
case CTF_K_RESTRICT:
case CTF_K_POINTER:
- erm = "pointer or cvr-qual";
+ errtype = _("pointer or cvr-qual");
ref = ctf_type_reference (input, type);
if ((ref = ctf_dedup_id_to_target (output, target, inputs, ninputs,
@@ -2738,7 +2736,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
break;
case CTF_K_SLICE:
- erm = "slice";
+ errtype = _("slice");
if (ctf_type_encoding (input, type, &ep) < 0)
goto err_input; /* errno is set for us. */
@@ -2757,7 +2755,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
{
ctf_arinfo_t ar;
- erm = "array info";
+ errtype = _("array info");
if (ctf_array_info (input, type, &ar) < 0)
goto err_input;
@@ -2783,7 +2781,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
ctf_id_t *args;
uint32_t j;
- erm = "function";
+ errtype = _("function");
if (ctf_func_type_info (input, type, &fi) < 0)
goto err_input;
@@ -2799,7 +2797,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
goto err_input;
}
- erm = "function args";
+ errtype = _("function args");
if (ctf_func_type_args (input, type, fi.ctc_argc, args) < 0)
{
free (args);
@@ -2832,7 +2830,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
void *out_id;
/* Insert the structure itself, so other types can refer to it. */
- erm = "structure/union";
+ errtype = _("structure/union");
if (kind == CTF_K_STRUCT)
new_type = ctf_add_struct_sized (target, isroot, name, size);
else
@@ -2850,9 +2848,10 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
break;
}
default:
- ctf_err_warn (output, 0, "%s: unknown type kind for input type %lx",
+ ctf_err_warn (output, 0, ECTF_CORRUPT, _("%s: unknown type kind for "
+ "input type %lx"),
ctf_link_input_name (input), type);
- return -1;
+ return ctf_set_errno (output, ECTF_CORRUPT);
}
if (!emission_hashed
@@ -2860,8 +2859,8 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
&& ctf_dynhash_cinsert (target->ctf_dedup.cd_output_emission_hashes,
hval, (void *) (uintptr_t) new_type) < 0)
{
- ctf_err_warn (output, 0, "out of memory tracking deduplicated "
- "global type IDs");
+ ctf_err_warn (output, 0, ENOMEM, _("out of memory tracking deduplicated "
+ "global type IDs"));
return ctf_set_errno (output, ENOMEM);
}
@@ -2873,22 +2872,23 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
return 0;
oom_hash:
- ctf_err_warn (output, 0, "out of memory creating emission-tracking hashes");
+ ctf_err_warn (output, 0, ENOMEM, _("out of memory creating emission-tracking "
+ "hashes"));
return ctf_set_errno (output, ENOMEM);
err_input:
- ctf_err_warn (output, 0, "%s (%i): while emitting deduplicated %s, error "
- "getting input type %lx: %s", ctf_link_input_name (input),
- input_num,erm, type, ctf_errmsg (ctf_errno (input)));
- ctf_set_errno (output, ctf_errno (input));
- return -1;
+ ctf_err_warn (output, 0, ctf_errno (input),
+ _("%s (%i): while emitting deduplicated %s, error getting "
+ "input type %lx"), ctf_link_input_name (input),
+ input_num, errtype, type);
+ return ctf_set_errno (output, ctf_errno (input));
err_target:
- ctf_err_warn (output, 0, "%s (%i): while emitting deduplicated %s, error "
- "emitting target type from input type %lx: %s",
- ctf_link_input_name (input), input_num, erm, type,
- ctf_errmsg (ctf_errno (target)));
- ctf_set_errno (output, ctf_errno (target));
- return -1;
+ ctf_err_warn (output, 0, ctf_errno (target),
+ _("%s (%i): while emitting deduplicated %s, error emitting "
+ "target type from input type %lx"),
+ ctf_link_input_name (input), input_num,
+ errtype, type);
+ return ctf_set_errno (output, ctf_errno (target));
}
/* Traverse the cd_emission_struct_members and emit the members of all
@@ -2978,16 +2978,14 @@ ctf_dedup_emit_struct_members (ctf_file_t *output, ctf_file_t **inputs,
return 0;
err_target:
ctf_next_destroy (i);
- ctf_err_warn (output, 0, "%s (%i): error emitting members for structure "
- "type %lx: %s", ctf_link_input_name (input_fp), input_num,
- err_type, ctf_errmsg (ctf_errno (err_fp)));
- ctf_set_errno (output, ctf_errno (err_fp));
- return -1;
+ ctf_err_warn (output, 0, ctf_errno (err_fp),
+ _("%s (%i): error emitting members for structure type %lx"),
+ ctf_link_input_name (input_fp), input_num, err_type);
+ return ctf_set_errno (output, ctf_errno (err_fp));
iterr:
- ctf_err_warn (output, 0, "iteration failure emitting structure members: %s",
- ctf_errmsg (err));
- ctf_set_errno (output, err);
- return -1;
+ ctf_err_warn (output, 0, err, _("iteration failure emitting "
+ "structure members"));
+ return ctf_set_errno (output, err);
}
/* Populate the type mapping used by the types in one FP (which must be an input
@@ -3052,8 +3050,7 @@ ctf_dedup_populate_type_mapping (ctf_file_t *shared, ctf_file_t *fp,
return 0;
err:
- ctf_err_warn (shared, 0, "iteration error populating the type mapping: %s",
- ctf_errmsg (err));
+ ctf_err_warn (shared, 0, err, _("iteration error populating the type mapping"));
return ctf_set_errno (shared, err);
}
@@ -3067,8 +3064,8 @@ ctf_dedup_populate_type_mappings (ctf_file_t *output, ctf_file_t **inputs,
if (ctf_dedup_populate_type_mapping (output, output, inputs) < 0)
{
- ctf_err_warn (output, 0, "cannot populate type mappings for shared "
- "CTF dict: %s", ctf_errmsg (ctf_errno (output)));
+ ctf_err_warn (output, 0, 0, _("cannot populate type mappings for shared "
+ "CTF dict"));
return -1; /* errno is set for us. */
}
@@ -3076,8 +3073,8 @@ ctf_dedup_populate_type_mappings (ctf_file_t *output, ctf_file_t **inputs,
{
if (ctf_dedup_populate_type_mapping (output, inputs[i], inputs) < 0)
{
- ctf_err_warn (output, 0, "cannot populate type mappings for per-CU "
- "CTF dict: %s", ctf_errmsg (ctf_errno (inputs[i])));
+ ctf_err_warn (output, 0, ctf_errno (inputs[i]),
+ _("cannot populate type mappings for per-CU CTF dict"));
return ctf_set_errno (output, ctf_errno (inputs[i]));
}
}
@@ -3129,7 +3126,8 @@ ctf_dedup_emit (ctf_file_t *output, ctf_file_t **inputs, uint32_t ninputs,
if ((outputs = calloc (num_outputs, sizeof (ctf_file_t *))) == NULL)
{
- ctf_err_warn (output, 0, "out of memory allocating link outputs array");
+ ctf_err_warn (output, 0, ENOMEM,
+ _("out of memory allocating link outputs array"));
ctf_set_errno (output, ENOMEM);
return NULL;
}