summaryrefslogtreecommitdiff
path: root/usr/src/common/ctf
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/common/ctf')
-rw-r--r--usr/src/common/ctf/ctf_impl.h5
-rw-r--r--usr/src/common/ctf/ctf_lookup.c51
2 files changed, 54 insertions, 2 deletions
diff --git a/usr/src/common/ctf/ctf_impl.h b/usr/src/common/ctf/ctf_impl.h
index 93a85a8b4f..b82fb7e36e 100644
--- a/usr/src/common/ctf/ctf_impl.h
+++ b/usr/src/common/ctf/ctf_impl.h
@@ -25,7 +25,7 @@
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2015, Joyent, Inc. All rights reserved.
+ * Copyright 2019, Joyent, Inc.
*/
#ifndef _CTF_IMPL_H
@@ -315,6 +315,9 @@ extern ctf_id_t ctf_add_reftype(ctf_file_t *, uint_t, const char *, ctf_id_t,
extern boolean_t ctf_sym_valid(uintptr_t, int, uint16_t, uint64_t,
uint32_t);
+extern const ctf_type_t *ctf_dyn_lookup_by_id(ctf_file_t *, ctf_id_t);
+extern int ctf_dyn_array_info(ctf_file_t *, ctf_id_t, ctf_arinfo_t *);
+
extern const char _CTF_SECTION[]; /* name of CTF ELF section */
extern const char _CTF_NULLSTR[]; /* empty string */
diff --git a/usr/src/common/ctf/ctf_lookup.c b/usr/src/common/ctf/ctf_lookup.c
index f8fa724355..05aa54d6cb 100644
--- a/usr/src/common/ctf/ctf_lookup.c
+++ b/usr/src/common/ctf/ctf_lookup.c
@@ -25,7 +25,9 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright 2019, Joyent, Inc.
+ */
#include <sys/sysmacros.h>
#include <ctf_impl.h>
@@ -311,3 +313,50 @@ ctf_func_args(ctf_file_t *fp, ulong_t symidx, uint_t argc, ctf_id_t *argv)
return (0);
}
+
+/*
+ * Unlike the normal lookup routines, ctf_dyn_*() variants consult both the
+ * processed CTF contents of a ctf_file_t as well as the dynamic types in the
+ * dtdef list.
+ */
+
+const ctf_type_t *
+ctf_dyn_lookup_by_id(ctf_file_t *fp, ctf_id_t id)
+{
+ ctf_file_t **fpp = &fp;
+ const ctf_type_t *t;
+ ctf_dtdef_t *dtd;
+
+ if ((t = ctf_lookup_by_id(fpp, id)) != NULL)
+ return (t);
+
+ if ((dtd = ctf_dtd_lookup(fp, id)) == NULL)
+ return (NULL);
+
+ return (&dtd->dtd_data);
+}
+
+int
+ctf_dyn_array_info(ctf_file_t *infp, ctf_id_t id, ctf_arinfo_t *arinfop)
+{
+ ctf_file_t *fp = infp;
+ const ctf_type_t *t;
+ ctf_dtdef_t *dtd;
+
+ if ((t = ctf_lookup_by_id(&fp, id)) != NULL) {
+
+ if (LCTF_INFO_KIND(fp, t->ctt_info) != CTF_K_ARRAY)
+ return (ctf_set_errno(infp, ECTF_NOTARRAY));
+
+ return (ctf_array_info(fp, id, arinfop));
+ }
+
+ if ((dtd = ctf_dtd_lookup(fp, id)) == NULL)
+ return (ctf_set_errno(infp, ENOENT));
+
+ if (LCTF_INFO_KIND(fp, dtd->dtd_data.ctt_info) != CTF_K_ARRAY)
+ return (ctf_set_errno(infp, ECTF_NOTARRAY));
+
+ bcopy(&dtd->dtd_u.dtu_arr, arinfop, sizeof (*arinfop));
+ return (0);
+}