diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2020-06-04 15:38:26 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2020-07-22 18:02:17 +0100 |
commit | 8e795b46f58d9cd80b8831ea24f56f1433b8f50b (patch) | |
tree | b57b95ca12bc54c3de0ac90d58e3bdf3f7fa772a /libctf | |
parent | b255b35feb80ecf096825395e01bccd34ee02b2b (diff) | |
download | gdb-8e795b46f58d9cd80b8831ea24f56f1433b8f50b.zip gdb-8e795b46f58d9cd80b8831ea24f56f1433b8f50b.tar.gz gdb-8e795b46f58d9cd80b8831ea24f56f1433b8f50b.tar.bz2 |
libctf, dump: migrate towards dumping errors rather than truncation
If we get an error emitting a single type, variable, or label, right now
we emit the error into the ctf_dprintf stream and propagate the error
all the way up the stack, causing the entire output to be silently
truncated (unless libctf debugging is on).
Instead, emit an error and keep going. (This makes sense for this use
case: if you're dumping types and a type is corrupted, you want to
know!)
Not all instances of this are fixed in this commit, only ones associated
with type formatting: more fixes will come.
libctf/
* ctf-dump.c (ctf_dump_format_type): Emit a warning.
(ctf_dump_label): Swallow errors from ctf_dump_format_type.
(ctf_dump_objts): Likewise.
(ctf_dump_var): Likewise.
(ctf_dump_type): Do not emit a duplicate message. Move to
ctf_err_warning, and swallow all errors.
Diffstat (limited to 'libctf')
-rw-r--r-- | libctf/ChangeLog | 9 | ||||
-rw-r--r-- | libctf/ctf-dump.c | 20 |
2 files changed, 19 insertions, 10 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog index d840bc4..b13c51c 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,5 +1,14 @@ 2020-07-22 Nick Alcock <nick.alcock@oracle.com> + * ctf-dump.c (ctf_dump_format_type): Emit a warning. + (ctf_dump_label): Swallow errors from ctf_dump_format_type. + (ctf_dump_objts): Likewise. + (ctf_dump_var): Likewise. + (ctf_dump_type): Do not emit a duplicate message. Move to + ctf_err_warning, and swallow all errors. + +2020-07-22 Nick Alcock <nick.alcock@oracle.com> + * ctf-decl.c (ctf_decl_fini): Free the cd_buf. (ctf_decl_buf): Once it escapes, don't try to free it later. diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c index 08d79f3..55aa496 100644 --- a/libctf/ctf-dump.c +++ b/libctf/ctf-dump.c @@ -169,6 +169,8 @@ ctf_dump_format_type (ctf_file_t *fp, ctf_id_t id, int flag) oom: ctf_set_errno (fp, errno); err: + ctf_err_warn (fp, 1, "Cannot format name dumping type 0x%lx: %s", id, + ctf_errmsg (ctf_errno (fp))); free (buf); free (str); free (bit); @@ -318,7 +320,7 @@ ctf_dump_label (const char *name, const ctf_lblinfo_t *info, CTF_ADD_ROOT)) == NULL) { free (str); - return -1; /* errno is set for us. */ + return 0; /* Swallow the error. */ } str = str_append (str, typestr); @@ -375,7 +377,7 @@ ctf_dump_objts (ctf_file_t *fp, ctf_dump_state_t *state) CTF_ADD_ROOT)) == NULL) { free (str); - return -1; /* errno is set for us. */ + return 0; /* Swallow the error. */ } str = str_append (str, typestr); @@ -495,7 +497,7 @@ ctf_dump_var (const char *name, ctf_id_t type, void *arg) CTF_ADD_ROOT)) == NULL) { free (str); - return -1; /* errno is set for us. */ + return 0; /* Swallow the error. */ } str = str_append (str, typestr); @@ -579,10 +581,7 @@ ctf_dump_type (ctf_id_t id, int flag, void *arg) size_t len; if ((str = ctf_dump_format_type (state->cds_fp, id, flag)) == NULL) - { - err = "format type"; - goto err; - } + goto err_nomsg; /* Error already logged for us. */ str = str_append (str, "\n"); if ((ctf_type_visit (state->cds_fp, id, ctf_dump_member, &membstate)) < 0) @@ -605,10 +604,11 @@ ctf_dump_type (ctf_id_t id, int flag, void *arg) return 0; err: - ctf_dprintf ("Cannot %s dumping type 0x%lx: %s\n", err, id, - ctf_errmsg (ctf_errno (state->cds_fp))); + ctf_err_warn (state->cds_fp, 1, "Cannot %s dumping type 0x%lx: %s", + err, id, ctf_errmsg (ctf_errno (state->cds_fp))); + err_nomsg: free (str); - return -1; /* errno is set for us. */ + return 0; /* Swallow the error. */ } /* Dump the string table into the cds_items. */ |