diff options
Diffstat (limited to 'usr/src/common/ctf')
-rw-r--r-- | usr/src/common/ctf/ctf_create.c | 2 | ||||
-rw-r--r-- | usr/src/common/ctf/ctf_hash.c | 24 | ||||
-rw-r--r-- | usr/src/common/ctf/ctf_impl.h | 7 | ||||
-rw-r--r-- | usr/src/common/ctf/ctf_open.c | 5 | ||||
-rw-r--r-- | usr/src/common/ctf/ctf_types.c | 19 |
5 files changed, 56 insertions, 1 deletions
diff --git a/usr/src/common/ctf/ctf_create.c b/usr/src/common/ctf/ctf_create.c index c1027aa60e..abbfeddc76 100644 --- a/usr/src/common/ctf/ctf_create.c +++ b/usr/src/common/ctf/ctf_create.c @@ -26,6 +26,7 @@ */ /* * Copyright 2020 Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. */ #include <sys/sysmacros.h> @@ -671,6 +672,7 @@ ctf_update(ctf_file_t *fp) nfp->ctf_refcnt = fp->ctf_refcnt; nfp->ctf_flags |= fp->ctf_flags & ~LCTF_DIRTY; + nfp->ctf_flags |= LCTF_FREE; nfp->ctf_dthash = fp->ctf_dthash; nfp->ctf_dthashlen = fp->ctf_dthashlen; nfp->ctf_dtdefs = fp->ctf_dtdefs; diff --git a/usr/src/common/ctf/ctf_hash.c b/usr/src/common/ctf/ctf_hash.c index 0c5a71a5ac..f97115a791 100644 --- a/usr/src/common/ctf/ctf_hash.c +++ b/usr/src/common/ctf/ctf_hash.c @@ -23,6 +23,8 @@ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. */ #include <ctf_impl.h> @@ -175,3 +177,25 @@ ctf_hash_destroy(ctf_hash_t *hp) hp->h_chains = NULL; } } + +void +ctf_hash_dump(const char *tag, ctf_hash_t *hp, ctf_file_t *fp) +{ + ctf_dprintf("---------------\nHash dump - %s\n", tag); + + for (ushort_t h = 0; h < hp->h_nbuckets; h++) { + ctf_helem_t *hep; + + for (ushort_t i = hp->h_buckets[h]; i != 0; i = hep->h_next) { + ctf_strs_t *ctsp; + const char *str; + + hep = &hp->h_chains[i]; + ctsp = &fp->ctf_str[CTF_NAME_STID(hep->h_name)]; + str = ctsp->cts_strs + CTF_NAME_OFFSET(hep->h_name); + + ctf_dprintf(" - %3u/%3u - '%s' type %u\n", h, i, str, + hep->h_type); + } + } +} diff --git a/usr/src/common/ctf/ctf_impl.h b/usr/src/common/ctf/ctf_impl.h index 7064abad15..b208cfb486 100644 --- a/usr/src/common/ctf/ctf_impl.h +++ b/usr/src/common/ctf/ctf_impl.h @@ -26,6 +26,7 @@ */ /* * Copyright 2020 Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. */ #ifndef _CTF_IMPL_H @@ -248,6 +249,11 @@ struct ctf_file { #define LCTF_CHILD 0x0002 /* CTF container is a child */ #define LCTF_RDWR 0x0004 /* CTF container is writable */ #define LCTF_DIRTY 0x0008 /* CTF container has been modified */ +/* + * The storage for this CTF container was allocated via ctf_data_alloc() + * and libctf should free it with ctf_data_free() on close. + */ +#define LCTF_FREE 0x0010 #define CTF_ELF_SCN_NAME ".SUNW_ctf" @@ -267,6 +273,7 @@ extern ctf_helem_t *ctf_hash_lookup(ctf_hash_t *, ctf_file_t *, const char *, size_t); extern uint_t ctf_hash_size(const ctf_hash_t *); extern void ctf_hash_destroy(ctf_hash_t *); +extern void ctf_hash_dump(const char *, ctf_hash_t *, ctf_file_t *); #define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev)) #define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next)) diff --git a/usr/src/common/ctf/ctf_open.c b/usr/src/common/ctf/ctf_open.c index 82b396e825..fe0644b1b0 100644 --- a/usr/src/common/ctf/ctf_open.c +++ b/usr/src/common/ctf/ctf_open.c @@ -26,6 +26,7 @@ */ /* * Copyright (c) 2015, Joyent, Inc. All rights reserved. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. */ #include <ctf_impl.h> @@ -936,6 +937,10 @@ ctf_close(ctf_file_t *fp) if (fp->ctf_strtab.cts_data != NULL) ctf_sect_munmap(&fp->ctf_strtab); } + if (fp->ctf_flags & LCTF_FREE) { + ctf_data_free((void *)fp->ctf_data.cts_data, + fp->ctf_data.cts_size); + } if (fp->ctf_data.cts_name != _CTF_NULLSTR && fp->ctf_data.cts_name != NULL) { diff --git a/usr/src/common/ctf/ctf_types.c b/usr/src/common/ctf/ctf_types.c index 6456f8a042..1fad60ddd4 100644 --- a/usr/src/common/ctf/ctf_types.c +++ b/usr/src/common/ctf/ctf_types.c @@ -26,6 +26,7 @@ */ /* * Copyright 2020 Joyent, Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. */ #include <ctf_impl.h> @@ -369,8 +370,24 @@ ctf_type_qlname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len, cdp->cd_type, want_func_args); vname = NULL; break; - case CTF_K_STRUCT: case CTF_K_FORWARD: + switch (tp->ctt_type) { + case CTF_K_UNION: + ctf_decl_sprintf(&cd, "union "); + break; + case CTF_K_ENUM: + ctf_decl_sprintf(&cd, "enum "); + break; + case CTF_K_STRUCT: + default: + ctf_decl_sprintf(&cd, "struct "); + break; + } + if (qname != NULL) + ctf_decl_sprintf(&cd, "%s`", qname); + ctf_decl_sprintf(&cd, "%s", name); + break; + case CTF_K_STRUCT: ctf_decl_sprintf(&cd, "struct "); if (qname != NULL) ctf_decl_sprintf(&cd, "%s`", qname); |