summaryrefslogtreecommitdiff
path: root/usr/src/tools/ctf
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2020-12-04 11:41:39 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2020-12-17 21:18:56 +0000
commit88a08813800ed7ba7c927986421cee437f7f2233 (patch)
tree5ee2cc36e4a8aa6c6f35f47268f4912f1ab44b08 /usr/src/tools/ctf
parent3dd4cd56e7843e01a8ab147a0d102cd4f6d732c1 (diff)
downloadillumos-joyent-88a08813800ed7ba7c927986421cee437f7f2233.tar.gz
13363 ctfconvert could support more granular ignore for missing debug data
Reviewed by: Robert Mustacchi <rm@fingolfin.org> Approved by: Rich Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src/tools/ctf')
-rw-r--r--usr/src/tools/ctf/common/list.c228
-rw-r--r--usr/src/tools/ctf/common/list.h58
-rw-r--r--usr/src/tools/ctf/stabs/Makefile.com6
-rw-r--r--usr/src/tools/ctf/stabs/common/fth_struct.c39
4 files changed, 33 insertions, 298 deletions
diff --git a/usr/src/tools/ctf/common/list.c b/usr/src/tools/ctf/common/list.c
deleted file mode 100644
index c01de9b924..0000000000
--- a/usr/src/tools/ctf/common/list.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Routines for manipulating linked lists
- */
-
-#include <stdio.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#include "list.h"
-#include "memory.h"
-
-struct list {
- void *l_data;
- struct list *l_next;
-};
-
-/* Add an element to a list */
-void
-list_add(list_t **list, void *data)
-{
- list_t *le;
-
- le = xmalloc(sizeof (list_t));
- le->l_data = data;
- le->l_next = *list;
- *list = le;
-}
-
-/* Add an element to a sorted list */
-void
-slist_add(list_t **list, void *data, int (*cmp)(void *, void *))
-{
- list_t **nextp;
-
- for (nextp = list; *nextp; nextp = &((*nextp)->l_next)) {
- if (cmp((*nextp)->l_data, data) > 0)
- break;
- }
-
- list_add(nextp, data);
-}
-
-/*ARGSUSED2*/
-static int
-list_defcmp(void *d1, void *d2, void *private)
-{
- return (d1 != d2);
-}
-
-void *
-list_remove(list_t **list, void *data, int (*cmp)(void *, void *, void *),
- void *private)
-{
- list_t *le, **le2;
- void *led;
-
- if (!cmp)
- cmp = list_defcmp;
-
- for (le = *list, le2 = list; le; le2 = &le->l_next, le = le->l_next) {
- if (cmp(le->l_data, data, private) == 0) {
- *le2 = le->l_next;
- led = le->l_data;
- free(le);
- return (led);
- }
- }
-
- return (NULL);
-}
-
-void
-list_free(list_t *list, void (*datafree)(void *, void *), void *private)
-{
- list_t *le;
-
- while (list) {
- le = list;
- list = list->l_next;
- if (le->l_data && datafree)
- datafree(le->l_data, private);
- free(le);
- }
-}
-
-/*
- * This iterator is specifically designed to tolerate the deletion of the
- * node being iterated over.
- */
-int
-list_iter(list_t *list, int (*func)(void *, void *), void *private)
-{
- list_t *lnext;
- int cumrc = 0;
- int cbrc;
-
- while (list) {
- lnext = list->l_next;
- if ((cbrc = func(list->l_data, private)) < 0)
- return (cbrc);
- cumrc += cbrc;
- list = lnext;
- }
-
- return (cumrc);
-}
-
-/*ARGSUSED*/
-static int
-list_count_cb(void *data, void *private)
-{
- return (1);
-}
-
-int
-list_count(list_t *list)
-{
- return (list_iter(list, list_count_cb, NULL));
-}
-
-int
-list_empty(list_t *list)
-{
- return (list == NULL);
-}
-
-void *
-list_find(list_t *list, void *tmpl, int (*cmp)(void *, void *))
-{
- for (; list; list = list->l_next) {
- if (cmp(list->l_data, tmpl) == 0)
- return (list->l_data);
- }
-
- return (NULL);
-}
-
-void *
-list_first(list_t *list)
-{
- return (list ? list->l_data : NULL);
-}
-
-void
-list_concat(list_t **list1, list_t *list2)
-{
- list_t *l, *last;
-
- for (l = *list1, last = NULL; l; last = l, l = l->l_next)
- continue;
-
- if (last == NULL)
- *list1 = list2;
- else
- last->l_next = list2;
-}
-
-/*
- * Merges two sorted lists. Equal nodes (as determined by cmp) are retained.
- */
-void
-slist_merge(list_t **list1p, list_t *list2, int (*cmp)(void *, void *))
-{
- list_t *list1, *next2;
- list_t *last1 = NULL;
-
- if (*list1p == NULL) {
- *list1p = list2;
- return;
- }
-
- list1 = *list1p;
- while (list2 != NULL) {
- if (cmp(list1->l_data, list2->l_data) > 0) {
- next2 = list2->l_next;
-
- if (last1 == NULL) {
- /* Insert at beginning */
- *list1p = last1 = list2;
- list2->l_next = list1;
- } else {
- list2->l_next = list1;
- last1->l_next = list2;
- last1 = list2;
- }
-
- list2 = next2;
- } else {
-
- last1 = list1;
- list1 = list1->l_next;
-
- if (list1 == NULL) {
- /* Add the rest to the end of list1 */
- last1->l_next = list2;
- list2 = NULL;
- }
- }
- }
-}
diff --git a/usr/src/tools/ctf/common/list.h b/usr/src/tools/ctf/common/list.h
deleted file mode 100644
index 2e41271d0f..0000000000
--- a/usr/src/tools/ctf/common/list.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _LIST_H
-#define _LIST_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Routines for manipulating linked lists
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct list list_t;
-
-void list_add(list_t **, void *);
-void slist_add(list_t **, void *, int (*)(void *, void *));
-void *list_remove(list_t **, void *, int (*)(void *, void *, void *), void *);
-void list_free(list_t *, void (*)(void *, void *), void *);
-void *list_find(list_t *, void *, int (*)(void *, void *));
-void *list_first(list_t *);
-int list_iter(list_t *, int (*)(void *, void *), void *);
-int list_count(list_t *);
-int list_empty(list_t *);
-void list_concat(list_t **, list_t *);
-void slist_merge(list_t **, list_t *, int (*)(void *, void *));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIST_H */
diff --git a/usr/src/tools/ctf/stabs/Makefile.com b/usr/src/tools/ctf/stabs/Makefile.com
index 901acd2584..06a2622d18 100644
--- a/usr/src/tools/ctf/stabs/Makefile.com
+++ b/usr/src/tools/ctf/stabs/Makefile.com
@@ -32,7 +32,6 @@ SRCS = \
fth_enum.c \
fth_struct.c \
genassym.c \
- list.c \
memory.c \
utils.c
@@ -41,7 +40,7 @@ include ../../Makefile.ctf
LDLIBS += -lctf
NATIVE_LIBS += libctf.so
-OBJS = $(SRCS:%.c=%.o)
+OBJS = $(SRCS:%.c=%.o) list.o
CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused
@@ -58,6 +57,9 @@ $(PROG): $(OBJS)
%.o: ../common/%.c
$(COMPILE.c) $<
+%.o: $(SRC)/common/list/%.c
+ $(COMPILE.c) $<
+
$(ROOTONBLDMACHPROG): $(PROG)
install: $(ROOTONBLDMACHPROG)
diff --git a/usr/src/tools/ctf/stabs/common/fth_struct.c b/usr/src/tools/ctf/stabs/common/fth_struct.c
index d3bd2ef0d1..30e450e9d5 100644
--- a/usr/src/tools/ctf/stabs/common/fth_struct.c
+++ b/usr/src/tools/ctf/stabs/common/fth_struct.c
@@ -24,7 +24,9 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
+ */
/*
* Used to dump structures and unions in forth mode.
@@ -103,20 +105,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/list.h>
#include "ctf_headers.h"
#include "forth.h"
-#include "list.h"
#include "memory.h"
static ctf_id_t fth_str_curtid;
-static list_t *fth_str_curmems;
+static list_t fth_str_curmems;
/*
* Node type for the member-storage list (fth_str_curmems) built by
* fth_struct_members()
*/
typedef struct fth_str_mem {
+ list_node_t fsm_node;
char *fsm_memname;
char *fsm_format;
ctf_id_t fsm_tid;
@@ -147,6 +150,21 @@ fth_struct_memcmp(void *m1, void *m2)
}
static void
+fth_slist_add(fth_str_mem_t *mem)
+{
+ fth_str_mem_t *l;
+
+ for (l = list_head(&fth_str_curmems); l != NULL;
+ l = list_next(&fth_str_curmems, l)) {
+ if (fth_struct_memcmp(l, mem) > 0) {
+ list_insert_before(&fth_str_curmems, l, mem);
+ return;
+ }
+ }
+ list_insert_tail(&fth_str_curmems, mem);
+}
+
+static void
fth_free_str_mem(fth_str_mem_t *mem)
{
free(mem->fsm_memname);
@@ -161,7 +179,8 @@ fth_struct_header(ctf_id_t tid)
ssize_t sz;
fth_str_curtid = tid;
- fth_str_curmems = NULL;
+ list_create(&fth_str_curmems, sizeof (fth_str_mem_t),
+ offsetof(fth_str_mem_t, fsm_node));
if ((sz = ctf_type_size(ctf, fth_str_curtid)) == CTF_ERR)
return (parse_warn("Can't get size for %s", fth_curtype));
@@ -418,7 +437,7 @@ fth_struct_members_cb(const char *memname, ctf_id_t tid, ulong_t off, void *arg)
mem->fsm_tid = tid;
mem->fsm_off = off;
- slist_add(&fth_str_curmems, mem, fth_struct_memcmp);
+ fth_slist_add(mem);
return (0);
}
@@ -453,20 +472,20 @@ fth_struct_members(char *memfilter, char *format)
static int
fth_struct_trailer(void)
{
- if (list_count(fth_str_curmems) == 0) {
+ fth_str_mem_t *mem;
+
+ if (list_is_empty(&fth_str_curmems)) {
if (fth_struct_members(NULL, NULL) < 0)
return (-1);
}
- while (!list_empty(fth_str_curmems)) {
- fth_str_mem_t *mem = list_remove(&fth_str_curmems,
- list_first(fth_str_curmems), NULL, NULL);
-
+ while ((mem = list_remove_head(&fth_str_curmems)) != NULL) {
if (fth_print_member(mem, 0) < 0)
return (-1);
fth_free_str_mem(mem);
}
+ list_destroy(&fth_str_curmems);
(void) fprintf(out, "\n");
(void) fprintf(out, "kdbg-words definitions\n");