aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-string.c
diff options
context:
space:
mode:
Diffstat (limited to 'libctf/ctf-string.c')
-rw-r--r--libctf/ctf-string.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libctf/ctf-string.c b/libctf/ctf-string.c
index 58ebcd9..a16cd33 100644
--- a/libctf/ctf-string.c
+++ b/libctf/ctf-string.c
@@ -73,6 +73,30 @@ ctf_strptr (ctf_dict_t *fp, uint32_t name)
return (s != NULL ? s : "(?)");
}
+/* As above, but return info on what is wrong in more detail.
+ (Used for type lookups.) */
+
+const char *
+ctf_strptr_validate (ctf_dict_t *fp, uint32_t name)
+{
+ const char *str = ctf_strraw (fp, name);
+
+ if (str == NULL)
+ {
+ if (CTF_NAME_STID (name) == CTF_STRTAB_1
+ && fp->ctf_syn_ext_strtab == NULL
+ && fp->ctf_str[CTF_NAME_STID (name)].cts_strs == NULL)
+ {
+ ctf_set_errno (fp, ECTF_STRTAB);
+ return NULL;
+ }
+
+ ctf_set_errno (fp, ECTF_BADNAME);
+ return NULL;
+ }
+ return str;
+}
+
/* Remove all refs to a given atom. */
static void
ctf_str_purge_atom_refs (ctf_str_atom_t *atom)