aboutsummaryrefslogtreecommitdiff
path: root/libctf
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2021-10-25 11:17:02 +0100
committerNick Alcock <nick.alcock@oracle.com>2021-10-25 11:17:04 +0100
commita0cc569d599f92c3a9168fcd23a0b18f7ff42f1d (patch)
treecc5607eb8257ee863fb87845c4286027f420e98b /libctf
parent10909ea819417549886daf2fea983cc42cd6c734 (diff)
downloadgdb-a0cc569d599f92c3a9168fcd23a0b18f7ff42f1d.zip
gdb-a0cc569d599f92c3a9168fcd23a0b18f7ff42f1d.tar.gz
gdb-a0cc569d599f92c3a9168fcd23a0b18f7ff42f1d.tar.bz2
libctf: dump: do not stop dumping types on error
If dumping of a single type fails, we obviously can't dump it; but just as obviously this doesn't make the other types in the types section invalid or undumpable. So we should not propagate errors seen when type-dumping, but rather ignore them and carry on, so we dump as many types as we can (leaving out the ones we can't grok). libctf/ChangeLog 2021-10-25 Nick Alcock <nick.alcock@oracle.com> * ctf-dump.c (ctf_dump_type): Do not abort on error.
Diffstat (limited to 'libctf')
-rw-r--r--libctf/ChangeLog4
-rw-r--r--libctf/ctf-dump.c14
2 files changed, 14 insertions, 4 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index 5907e2f..879e128 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,3 +1,7 @@
+2021-10-25 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-dump.c (ctf_dump_type): Do not abort on error.
+
2021-09-27 Nick Alcock <nick.alcock@oracle.com>
* ctf-lookup.c (ctf_lookup_by_name_internal): Fix pptrtab bounds.
diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index bd9b50d..b6af0df 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -564,7 +564,6 @@ ctf_dump_type (ctf_id_t id, int flag, void *arg)
{
char *str;
char *indent;
- int err = 0;
ctf_dump_state_t *state = arg;
ctf_dump_membstate_t membstate = { &str, state->cds_fp, NULL };
@@ -619,9 +618,8 @@ ctf_dump_type (ctf_id_t id, int flag, void *arg)
if (asprintf (&bit, "%s: %i\n", enumerand, value) < 0)
{
- err = ENOMEM;
ctf_next_destroy (it);
- goto err;
+ goto oom;
}
str = str_append (str, bit);
free (bit);
@@ -648,7 +646,15 @@ ctf_dump_type (ctf_id_t id, int flag, void *arg)
err:
free (indent);
free (str);
- return ctf_set_errno (state->cds_fp, err);
+
+ /* Swallow the error: don't cause an error in one type to abort all
+ type dumping. */
+ return 0;
+
+ oom:
+ free (indent);
+ free (str);
+ return ctf_set_errno (state->cds_fp, ENOMEM);
}
/* Dump the string table into the cds_items. */