/* Textual dumping of CTF data.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2024 Free Software Foundation, Inc.
This file is part of libctf.
ctf_encoding_t ep;
ctf_arinfo_t ar;
int kind, unsliced_kind;
+ ssize_t size, align;
const char *nonroot_leader = "";
const char *nonroot_trailer = "";
const char *idstr = "";
unsliced_kind = ctf_type_kind_unsliced (fp, id);
kind = ctf_type_kind (fp, id);
- if (ctf_type_encoding (fp, id, &ep) == 0)
+ /* Report encodings of everything with an encoding other than enums:
+ base-type enums cannot have a nonzero cte_offset or cte_bits value.
+ (Slices of them can, but they are of kind CTF_K_SLICE.) */
+ if (unsliced_kind != CTF_K_ENUM && ctf_type_encoding (fp, id, &ep) == 0)
{
if ((ssize_t) ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT
&& flag & CTF_FT_BITFIELD)
bit = NULL;
}
- if (kind != CTF_K_FUNCTION && kind != CTF_K_FORWARD)
+ size = ctf_type_size (fp, id);
+ if (kind != CTF_K_FUNCTION && size >= 0)
{
- if (asprintf (&bit, " (size 0x%lx)",
- (unsigned long) ctf_type_size (fp, id)) < 0)
+ if (asprintf (&bit, " (size 0x%lx)", (unsigned long int) size) < 0)
goto oom;
str = str_append (str, bit);
bit = NULL;
}
- if (kind != CTF_K_FORWARD)
+ align = ctf_type_align (fp, id);
+ if (align >= 0)
{
if (asprintf (&bit, " (aligned at 0x%lx)",
- (unsigned long) ctf_type_align (fp, id)) < 0)
+ (unsigned long int) align) < 0)
goto oom;
str = str_append (str, bit);
{
char *str;
char *indent;
- int err = 0;
ctf_dump_state_t *state = arg;
ctf_dump_membstate_t membstate = { &str, state->cds_fp, NULL };
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);
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. */