git: 1dd57c72a469 - stable/13 - ctfconvert: Rip out STABS support

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 21 Feb 2022 14:58:08 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=1dd57c72a46948403175ffa991608ac1f64bcd90

commit 1dd57c72a46948403175ffa991608ac1f64bcd90
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-02-10 20:36:19 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-02-21 14:57:14 +0000

    ctfconvert: Rip out STABS support
    
    It is unused on FreeBSD and complicates some efforts to modify the CTF
    format to permit wider type IDs, so remove it.  No functional change
    intended.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 7be9a3b45356747f9fcb6d69a722c1c95f8060bf)
---
 cddl/contrib/opensolaris/tools/ctf/cvt/compare.c   |   92 --
 .../contrib/opensolaris/tools/ctf/cvt/ctfconvert.c |    3 -
 cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h  |   16 -
 .../opensolaris/tools/ctf/cvt/fixup_tdescs.c       |  119 --
 cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c  | 1214 --------------------
 cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c     |  381 ------
 cddl/usr.bin/ctfconvert/Makefile                   |    2 -
 7 files changed, 1827 deletions(-)

diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/compare.c b/cddl/contrib/opensolaris/tools/ctf/cvt/compare.c
deleted file mode 100644
index 26037f8a537a..000000000000
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/compare.c
+++ /dev/null
@@ -1,92 +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 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-/*
- * This is a test program designed to catch mismerges and mistranslations from
- * stabs to CTF.
- *
- * Given a file with stabs data and a file with CTF data, determine whether
- * or not all of the data structures and objects described by the stabs data
- * are present in the CTF data.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "ctftools.h"
-
-char *progname;
-int debug_level = DEBUG_LEVEL;
-
-static void
-usage(void)
-{
-	fprintf(stderr, "Usage: %s ctf_file stab_file\n", progname);
-}
-
-int
-main(int argc, char **argv)
-{
-	tdata_t *ctftd, *stabrtd, *stabtd, *difftd;
-	char *ctfname, *stabname;
-	int new;
-
-	progname = argv[0];
-
-	if (argc != 3) {
-		usage();
-		exit(2);
-	}
-
-	ctfname = argv[1];
-	stabname = argv[2];
-
-	stabrtd = tdata_new();
-	stabtd = tdata_new();
-	difftd = tdata_new();
-
-	if (read_stabs(stabrtd, stabname, 0) != 0)
-		merge_into_master(stabrtd, stabtd, NULL, 1);
-	else if (read_ctf(&stabname, 1, NULL, read_ctf_save_cb, &stabtd, 0)
-	    == 0)
-		terminate("%s doesn't have stabs or CTF\n", stabname);
-
-	if (read_ctf(&ctfname, 1, NULL, read_ctf_save_cb, &ctftd, 0) == 0)
-		terminate("%s doesn't contain CTF data\n", ctfname);
-
-	merge_into_master(stabtd, ctftd, difftd, 0);
-
-	if ((new = hash_count(difftd->td_iihash)) != 0) {
-		(void) hash_iter(difftd->td_iihash, (int (*)())iidesc_dump,
-		    NULL);
-		terminate("%s grew by %d\n", stabname, new);
-	}
-
-	return (0);
-}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
index d40be25da27f..68969356e75e 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
@@ -83,7 +83,6 @@ file_read(tdata_t *td, char *filename, int ignore_non_c)
 {
 	typedef int (*reader_f)(tdata_t *, Elf *, char *);
 	static reader_f readers[] = {
-		stabs_read,
 		dw_read,
 		NULL
 	};
@@ -165,8 +164,6 @@ main(int argc, char **argv)
 
 	if (getenv("CTFCONVERT_DEBUG_LEVEL"))
 		debug_level = atoi(getenv("CTFCONVERT_DEBUG_LEVEL"));
-	if (getenv("CTFCONVERT_DEBUG_PARSE"))
-		debug_parse = atoi(getenv("CTFCONVERT_DEBUG_PARSE"));
 
 	while ((c = getopt(argc, argv, ":l:L:o:givs")) != EOF) {
 		switch (c) {
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h b/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
index b7da16ac3ddd..974d22459991 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
@@ -50,9 +50,6 @@ extern "C" {
 #ifndef DEBUG_LEVEL
 #define	DEBUG_LEVEL 0
 #endif
-#ifndef DEBUG_PARSE
-#define	DEBUG_PARSE 0
-#endif
 
 #ifndef DEBUG_STREAM
 #define	DEBUG_STREAM stderr
@@ -100,7 +97,6 @@ extern "C" {
 
 extern const char *progname;
 extern int debug_level;
-extern int debug_parse;
 extern char *curhdr;
 
 /*
@@ -405,18 +401,6 @@ void merge_into_master(tdata_t *, tdata_t *, tdata_t *, int);
 
 void write_ctf(tdata_t *, const char *, const char *, int);
 
-/* parse.c */
-void parse_init(tdata_t *);
-void parse_finish(tdata_t *);
-int parse_stab(stab_t *, char *, iidesc_t **);
-tdesc_t *lookup(int);
-tdesc_t *lookupname(const char *);
-void check_hash(void);
-void resolve_typed_bitfields(void);
-
-/* stabs.c */
-int stabs_read(tdata_t *, Elf *, char *);
-
 /* dwarf.c */
 int dw_read(tdata_t *, Elf *, char *);
 const char *dw_tag2str(uint_t);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c b/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
index b239a62dc53b..ea4f4ee64625 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
@@ -38,125 +38,6 @@
 #include "hash.h"
 #include "memory.h"
 
-/*
- * Due to 4432619, the 6.1 compiler will sometimes incorrectly generate pointer
- * stabs.  Given a struct foo, and a corresponding typedef struct foo foo_t.
- * In some cases, when faced with a pointer to a foo_t, the compiler will
- * sometimes generate a stab that describes a pointer to a struct foo.
- * Regardless of correctness, this breaks merges, as it occurs inconsistently
- * by file.  The following two routines know how to recognize and repair foo_t *
- * and foo_t ** bugs in a specific set of cases.  There is no general way to
- * solve this problem without a fix to the compiler.  In general, cases should
- * only be added to these routines to fix merging problems in genunix.
- */
-static void
-fix_ptrptr_to_struct(tdata_t *td)
-{
-	const char *strs[2] = { "as", "fdbuffer" };
-	const char *mems[2] = { "a_objectdir", "fd_shadow" };
-	const char *acts[2] = { "vnode", "page" };
-	const char *tgts[2] = { "vnode_t", "page_t" };
-	tdesc_t *str;
-	tdesc_t *act, *tgt;
-	tdesc_t *p1, *p2;
-	mlist_t *ml;
-	int i;
-
-	for (i = 0; i < (int) (sizeof (strs) / sizeof (strs[0])); i++) {
-		if (!(str = lookupname(strs[i])) || str->t_type != STRUCT)
-			continue;
-
-		for (ml = str->t_members; ml; ml = ml->ml_next) {
-			if (streq(ml->ml_name, mems[i]))
-				break;
-		}
-		if (!ml)
-			continue;
-
-		if (ml->ml_type->t_type != POINTER || ml->ml_type->t_name ||
-		    ml->ml_type->t_tdesc->t_type != POINTER ||
-		    ml->ml_type->t_tdesc->t_name)
-			continue;
-
-		act = ml->ml_type->t_tdesc->t_tdesc;
-		if (act->t_type != STRUCT || !streq(act->t_name, acts[i]))
-			continue;
-
-		if (!(tgt = lookupname(tgts[i])) || tgt->t_type != TYPEDEF)
-			continue;
-
-		/* We have an instance of the bug */
-		p2 = xcalloc(sizeof (*p2));
-		p2->t_type = POINTER;
-		p2->t_id = td->td_nextid++;
-		p2->t_tdesc = tgt;
-
-		p1 = xcalloc(sizeof (*p1));
-		p1->t_type = POINTER;
-		p1->t_id = td->td_nextid++;
-		p1->t_tdesc = p2;
-
-		ml->ml_type = p1;
-
-		debug(3, "Fixed %s->%s => ptrptr struct %s bug\n",
-		    strs[i], mems[i], acts[i]);
-	}
-}
-
-static void
-fix_ptr_to_struct(tdata_t *td)
-{
-	const char *strs[2] = { "vmem", "id_space" };
-	const char *mems[2] = { NULL, "is_vmem" };
-	tdesc_t *ptr = NULL;
-	tdesc_t *str, *vmt;
-	mlist_t *ml;
-	int i;
-
-	if ((vmt = lookupname("vmem_t")) == NULL || vmt->t_type != TYPEDEF)
-		return;
-
-	for (i = 0; i < (int) (sizeof (strs) / sizeof (strs[0])); i++) {
-		if (!(str = lookupname(strs[i])) || str->t_type != STRUCT)
-			continue;
-
-		for (ml = str->t_members; ml; ml = ml->ml_next) {
-			if (mems[i] && !streq(ml->ml_name, mems[i]))
-				continue;
-
-			if (ml->ml_type->t_type != POINTER ||
-			    ml->ml_type->t_name ||
-			    (ml->ml_type->t_tdesc->t_type != STRUCT &&
-			    ml->ml_type->t_tdesc->t_type != FORWARD) ||
-			    !streq(ml->ml_type->t_tdesc->t_name, "vmem"))
-				continue;
-
-			debug(3, "Fixed %s->%s => ptr struct vmem bug\n",
-			    strs[i], ml->ml_name);
-
-			if (!ptr) {
-				ptr = xcalloc(sizeof (*ptr));
-				ptr->t_type = POINTER;
-				ptr->t_id = td->td_nextid++;
-				ptr->t_tdesc = vmt;
-			}
-
-			ml->ml_type = ptr;
-		}
-	}
-}
-
-/*
- * Fix stabs generation bugs.  These routines must be run before the
- * post-conversion merge
- */
-void
-cvt_fixstabs(tdata_t *td)
-{
-	fix_ptrptr_to_struct(td);
-	fix_ptr_to_struct(td);
-}
-
 struct match {
 	tdesc_t *m_ret;
 	const char *m_name;
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c b/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
deleted file mode 100644
index a452ca5960a7..000000000000
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
+++ /dev/null
@@ -1,1214 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (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 (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
- */
-
-/*
- * This file is a sewer.
- */
-
-#include <limits.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <assert.h>
-#include <strings.h>
-#include <setjmp.h>
-#include <ctype.h>
-#include <uts/common/sys/ctf.h>
-
-#include "ctftools.h"
-#include "memory.h"
-#include "list.h"
-
-#define	HASH(NUM)	((int)(NUM & (BUCKETS - 1)))
-#define	BUCKETS		128
-
-#define	TYPEPAIRMULT	10000
-#define	MAKETYPEID(file, num)	((file) * TYPEPAIRMULT + num)
-#define	TYPEFILE(tid)		((tid) / TYPEPAIRMULT)
-#define	TYPENUM(tid)		((tid) % TYPEPAIRMULT)
-
-#define	expected(a, b, c) _expected(a, b, c, __LINE__)
-
-static int faketypenumber = 100000000;
-
-static tdesc_t *hash_table[BUCKETS];
-static tdesc_t *name_table[BUCKETS];
-
-static list_t *typedbitfldmems;
-
-static void reset(void);
-static jmp_buf	resetbuf;
-
-static char *soudef(char *cp, stabtype_t type, tdesc_t **rtdp);
-static void enumdef(char *cp, tdesc_t **rtdp);
-static int compute_sum(const char *w);
-
-static char *number(char *cp, int *n);
-static char *name(char *cp, char **w);
-static char *id(char *cp, int *h);
-static char *whitesp(char *cp);
-static void addhash(tdesc_t *tdp, int num);
-static int tagadd(char *w, int h, tdesc_t *tdp);
-static char *tdefdecl(char *cp, int h, tdesc_t **rtdp);
-static char *intrinsic(char *cp, tdesc_t **rtdp);
-static char *arraydef(char *cp, tdesc_t **rtdp);
-
-int debug_parse = DEBUG_PARSE;
-
-/*PRINTFLIKE3*/
-static void
-parse_debug(int level, char *cp, const char *fmt, ...)
-{
-	va_list ap;
-	char buf[1024];
-	char tmp[32];
-	int i;
-
-	if (level > debug_level || !debug_parse)
-		return;
-
-	if (cp != NULL) {
-		for (i = 0; i < 30; i++) {
-			if (cp[i] == '\0')
-				break;
-			if (!iscntrl(cp[i]))
-				tmp[i] = cp[i];
-		}
-		tmp[i] = '\0';
-		(void) snprintf(buf, sizeof (buf), "%s [cp='%s']\n", fmt, tmp);
-	} else {
-		strcpy(buf, fmt);
-		strcat(buf, "\n");
-	}
-
-	va_start(ap, fmt);
-	vadebug(level, buf, ap);
-	va_end(ap);
-}
-
-/* Report unexpected syntax in stabs. */
-static void
-_expected(
-	const char *who,	/* what function, or part thereof, is reporting */
-	const char *what,	/* what was expected */
-	const char *where,	/* where we were in the line of input */
-	int line)
-{
-	fprintf(stderr, "%s, expecting \"%s\" at \"%s\"\n", who, what, where);
-	fprintf(stderr, "code line: %d, file %s\n", line,
-	    (curhdr ? curhdr : "NO FILE"));
-	reset();
-}
-
-/*ARGSUSED*/
-void
-parse_init(tdata_t *td __unused)
-{
-	int i;
-
-	for (i = 0; i < BUCKETS; i++) {
-		hash_table[i] = NULL;
-		name_table[i] = NULL;
-	}
-
-	if (typedbitfldmems != NULL) {
-		list_free(typedbitfldmems, NULL, NULL);
-		typedbitfldmems = NULL;
-	}
-}
-
-void
-parse_finish(tdata_t *td)
-{
-	td->td_nextid = ++faketypenumber;
-}
-
-static tdesc_t *
-unres_new(int tid)
-{
-	tdesc_t *tdp;
-
-	tdp = xcalloc(sizeof (*tdp));
-	tdp->t_type = TYPEDEF_UNRES;
-	tdp->t_id = tid;
-
-	return (tdp);
-}
-
-static char *
-read_tid(char *cp, tdesc_t **tdpp)
-{
-	tdesc_t *tdp;
-	int tid;
-
-	cp = id(cp, &tid);
-
-	assert(tid != 0);
-
-	if (*cp == '=') {
-		if (!(cp = tdefdecl(cp + 1, tid, &tdp)))
-			return (NULL);
-		if (tdp->t_id && tdp->t_id != tid) {
-			tdesc_t *ntdp = xcalloc(sizeof (*ntdp));
-
-			ntdp->t_type = TYPEDEF;
-			ntdp->t_tdesc = tdp;
-			tdp = ntdp;
-		}
-		addhash(tdp, tid);
-	} else if ((tdp = lookup(tid)) == NULL)
-		tdp = unres_new(tid);
-
-	*tdpp = tdp;
-	return (cp);
-}
-
-static iitype_t
-parse_fun(char *cp, iidesc_t *ii)
-{
-	iitype_t iitype = 0;
-	tdesc_t *tdp;
-	tdesc_t **args = NULL;
-	int nargs = 0;
-	int va = 0;
-
-	/*
-	 * name:P		prototype
-	 * name:F		global function
-	 * name:f		static function
-	 */
-	switch (*cp++) {
-	case 'P':
-		iitype = II_NOT; /* not interesting */
-		break;
-
-	case 'F':
-		iitype = II_GFUN;
-		break;
-
-	case 'f':
-		iitype = II_SFUN;
-		break;
-
-	default:
-		expected("parse_nfun", "[PfF]", cp - 1);
-	}
-
-	if (!(cp = read_tid(cp, &tdp)))
-		return (-1);
-
-	if (*cp)
-		args = xmalloc(sizeof (tdesc_t *) * FUNCARG_DEF);
-
-	while (*cp && *++cp) {
-		if (*cp == '0') {
-			va = 1;
-			continue;
-		}
-
-		nargs++;
-		if (nargs > FUNCARG_DEF)
-			args = xrealloc(args, sizeof (tdesc_t *) * nargs);
-		if (!(cp = read_tid(cp, &args[nargs - 1]))) {
-			if (tdp->t_type == TYPEDEF_UNRES)
-				free(tdp);
-			free(args);
-			return (-1);
-		}
-	}
-
-	ii->ii_type = iitype;
-	ii->ii_dtype = tdp;
-	ii->ii_nargs = nargs;
-	ii->ii_args = args;
-	ii->ii_vargs = va;
-
-	return (iitype);
-}
-
-static iitype_t
-parse_sym(char *cp, iidesc_t *ii)
-{
-	tdesc_t *tdp;
-	iitype_t iitype = 0;
-
-	/*
-	 * name:G		global variable
-	 * name:S		static variable
-	 */
-	switch (*cp++) {
-	case 'G':
-		iitype = II_GVAR;
-		break;
-	case 'S':
-		iitype = II_SVAR;
-		break;
-	case 'p':
-		iitype = II_PSYM;
-		break;
-	case '(':
-		cp--;
-		/*FALLTHROUGH*/
-	case 'r':
-	case 'V':
-		iitype = II_NOT; /* not interesting */
-		break;
-	default:
-		expected("parse_sym", "[GprSV(]", cp - 1);
-	}
-
-	if (!(cp = read_tid(cp, &tdp)))
-		return (-1);
-
-	ii->ii_type = iitype;
-	ii->ii_dtype = tdp;
-
-	return (iitype);
-}
-
-static iitype_t
-parse_type(char *cp, iidesc_t *ii)
-{
-	tdesc_t *tdp, *ntdp;
-	int tid;
-
-	if (*cp++ != 't')
-		expected("parse_type", "t (type)", cp - 1);
-
-	cp = id(cp, &tid);
-	if ((tdp = lookup(tid)) == NULL) {
-		if (*cp++ != '=')
-			expected("parse_type", "= (definition)", cp - 1);
-
-		(void) tdefdecl(cp, tid, &tdp);
-
-		if (tdp->t_id == tid) {
-			assert(tdp->t_type != TYPEDEF);
-			assert(!lookup(tdp->t_id));
-
-			if (!streq(tdp->t_name, ii->ii_name)) {
-				ntdp = xcalloc(sizeof (*ntdp));
-				ntdp->t_name = xstrdup(ii->ii_name);
-				ntdp->t_type = TYPEDEF;
-				ntdp->t_tdesc = tdp;
-				tdp->t_id = faketypenumber++;
-				tdp = ntdp;
-			}
-		} else if (tdp->t_id == 0) {
-			assert(tdp->t_type == FORWARD ||
-			    tdp->t_type == INTRINSIC);
-
-			if (tdp->t_name && !streq(tdp->t_name, ii->ii_name)) {
-				ntdp = xcalloc(sizeof (*ntdp));
-				ntdp->t_name = xstrdup(ii->ii_name);
-				ntdp->t_type = TYPEDEF;
-				ntdp->t_tdesc = tdp;
-				tdp->t_id = faketypenumber++;
-				tdp = ntdp;
-			}
-		} else if (tdp->t_id != tid) {
-			ntdp = xcalloc(sizeof (*ntdp));
-			ntdp->t_name = xstrdup(ii->ii_name);
-			ntdp->t_type = TYPEDEF;
-			ntdp->t_tdesc = tdp;
-			tdp = ntdp;
-		}
-
-		if (tagadd(ii->ii_name, tid, tdp) < 0)
-			return (-1);
-	}
-
-	ii->ii_type = II_TYPE;
-	ii->ii_dtype = tdp;
-	return (II_TYPE);
-}
-
-static iitype_t
-parse_sou(char *cp, iidesc_t *idp)
-{
-	tdesc_t *rtdp;
-	int tid;
-
-	if (*cp++ != 'T')
-		expected("parse_sou", "T (sou)", cp - 1);
-
-	cp = id(cp, &tid);
-	if (*cp++ != '=')
-		expected("parse_sou", "= (definition)", cp - 1);
-
-	parse_debug(1, NULL, "parse_sou: declaring '%s'", idp->ii_name ?
-	    idp->ii_name : "(anon)");
-	if ((rtdp = lookup(tid)) != NULL) {
-		if (idp->ii_name != NULL) {
-			if (rtdp->t_name != NULL &&
-			    strcmp(rtdp->t_name, idp->ii_name) != 0) {
-				tdesc_t *tdp;
-
-				tdp = xcalloc(sizeof (*tdp));
-				tdp->t_name = xstrdup(idp->ii_name);
-				tdp->t_type = TYPEDEF;
-				tdp->t_tdesc = rtdp;
-				addhash(tdp, tid); /* for *(x,y) types */
-				parse_debug(3, NULL, "    %s defined as %s(%d)",
-				    idp->ii_name, tdesc_name(rtdp), tid);
-			} else if (rtdp->t_name == NULL) {
-				rtdp->t_name = xstrdup(idp->ii_name);
-				addhash(rtdp, tid);
-			}
-		}
-	} else {
-		rtdp = xcalloc(sizeof (*rtdp));
-		rtdp->t_name = idp->ii_name ? xstrdup(idp->ii_name) : NULL;
-		addhash(rtdp, tid);
-	}
-
-	switch (*cp++) {
-	case 's':
-		(void) soudef(cp, STRUCT, &rtdp);
-		break;
-	case 'u':
-		(void) soudef(cp, UNION, &rtdp);
-		break;
-	case 'e':
-		enumdef(cp, &rtdp);
-		break;
-	default:
-		expected("parse_sou", "<tag type s/u/e>", cp - 1);
-		break;
-	}
-
-	idp->ii_type = II_SOU;
-	idp->ii_dtype = rtdp;
-	return (II_SOU);
-}
-
-int
-parse_stab(stab_t *stab, char *cp, iidesc_t **iidescp)
-{
-	iidesc_t *ii = NULL;
-	iitype_t (*parse)(char *, iidesc_t *);
-	int rc;
-
-	/*
-	 * set up for reset()
-	 */
-	if (setjmp(resetbuf))
-		return (-1);
-
-	cp = whitesp(cp);
-	ii = iidesc_new(NULL);
-	cp = name(cp, &ii->ii_name);
-
-	switch (stab->n_type) {
-	case N_FUN:
-		parse = parse_fun;
-		break;
-
-	case N_LSYM:
-		if (*cp == 't')
-			parse = parse_type;
-		else if (*cp == 'T')
-			parse = parse_sou;
-		else
-			parse = parse_sym;
-		break;
-
-	case N_GSYM:
-	case N_LCSYM:
-	case N_PSYM:
-	case N_ROSYM:
-	case N_RSYM:
-	case N_STSYM:
-		parse = parse_sym;
-		break;
-	default:
-		parse_debug(1, cp, "Unknown stab type %#x", stab->n_type);
-		bzero(&resetbuf, sizeof (resetbuf));
-		return (-1);
-	}
-
-	rc = parse(cp, ii);
-	bzero(&resetbuf, sizeof (resetbuf));
-
-	if (rc < 0 || ii->ii_type == II_NOT) {
-		iidesc_free(ii, NULL);
-		return (rc);
-	}
-
-	*iidescp = ii;
-
-	return (1);
-}
-
-/*
- * Check if we have this node in the hash table already
- */
-tdesc_t *
-lookup(int h)
-{
-	int bucket = HASH(h);
-	tdesc_t *tdp = hash_table[bucket];
-
-	while (tdp != NULL) {
-		if (tdp->t_id == h)
-			return (tdp);
-		tdp = tdp->t_hash;
-	}
-	return (NULL);
-}
-
-static char *
-whitesp(char *cp)
-{
-	char c;
-
-	for (c = *cp++; isspace(c); c = *cp++)
-		;
-	--cp;
-	return (cp);
-}
-
-static char *
-name(char *cp, char **w)
-{
-	char *new, *orig, c;
-	int len;
-
-	orig = cp;
-	c = *cp++;
-	if (c == ':')
-		*w = NULL;
-	else if (isalpha(c) || strchr("_.$#", c)) {
-		for (c = *cp++; isalnum(c) || strchr(" _.$#", c); c = *cp++)
-			;
-		if (c != ':')
-			reset();
-		len = cp - orig;
-		new = xmalloc(len);
-		while (orig < cp - 1)
-			*new++ = *orig++;
-		*new = '\0';
-		*w = new - (len - 1);
-	} else
-		reset();
-
-	return (cp);
-}
-
-static char *
-number(char *cp, int *n)
-{
-	char *next;
-
-	*n = (int)strtol(cp, &next, 10);
-	if (next == cp)
-		expected("number", "<number>", cp);
-	return (next);
-}
-
-static char *
-id(char *cp, int *h)
-{
-	int n1, n2;
-
-	if (*cp == '(') {	/* SunPro style */
-		cp++;
-		cp = number(cp, &n1);
-		if (*cp++ != ',')
-			expected("id", ",", cp - 1);
-		cp = number(cp, &n2);
-		if (*cp++ != ')')
-			expected("id", ")", cp - 1);
-		*h = MAKETYPEID(n1, n2);
-	} else if (isdigit(*cp)) { /* gcc style */
-		cp = number(cp, &n1);
-		*h = n1;
-	} else {
-		expected("id", "(/0-9", cp);
-	}
-	return (cp);
-}
-
-static int
-tagadd(char *w, int h, tdesc_t *tdp)
-{
-	tdesc_t *otdp;
-
-	tdp->t_name = w;
-	if (!(otdp = lookup(h)))
-		addhash(tdp, h);
-	else if (otdp != tdp) {
-		warning("duplicate entry\n");
-		warning("  old: %s %d (%d,%d)\n", tdesc_name(otdp),
-		    otdp->t_type, TYPEFILE(otdp->t_id), TYPENUM(otdp->t_id));
-		warning("  new: %s %d (%d,%d)\n", tdesc_name(tdp),
-		    tdp->t_type, TYPEFILE(tdp->t_id), TYPENUM(tdp->t_id));
-		return (-1);
-	}
-
-	return (0);
-}
-
-static char *
-tdefdecl(char *cp, int h, tdesc_t **rtdp)
-{
-	tdesc_t *ntdp;
-	char *w;
-	int c, h2;
-	char type;
-
-	parse_debug(3, cp, "tdefdecl h=%d", h);
-
-	/* Type codes */
-	switch (type = *cp) {
-	case 'b': /* integer */
-	case 'R': /* fp */
-		cp = intrinsic(cp, rtdp);
-		break;
-	case '(': /* equiv to another type */
-		cp = id(cp, &h2);
-		ntdp = lookup(h2);
-
-		if (ntdp != NULL && *cp == '=') {
-			if (ntdp->t_type == FORWARD && *(cp + 1) == 'x') {
-				/*
-				 * The 6.2 compiler, and possibly others, will
-				 * sometimes emit the same stab for a forward
-				 * declaration twice.  That is, "(1,2)=xsfoo:"
-				 * will sometimes show up in two different
-				 * places.  This is, of course, quite fun.  We
-				 * want CTF to work in spite of the compiler,
-				 * so we'll let this one through.
-				 */
-				char *c2 = cp + 2;
-				char *nm;
-
-				if (!strchr("sue", *c2++)) {
-					expected("tdefdecl/x-redefine", "[sue]",
-					    c2 - 1);
-				}
-
-				c2 = name(c2, &nm);
-				if (strcmp(nm, ntdp->t_name) != 0) {
-					terminate("Stabs error: Attempt to "
-					    "redefine type (%d,%d) as "
-					    "something else: %s\n",
-					    TYPEFILE(h2), TYPENUM(h2),
-					    c2 - 1);
-				}
-				free(nm);
-
-				h2 = faketypenumber++;
-				ntdp = NULL;
-			} else {
-				terminate("Stabs error: Attempting to "
-				    "redefine type (%d,%d)\n", TYPEFILE(h2),
-				    TYPENUM(h2));
-			}
-		}
-
-		if (ntdp == NULL) {  /* if that type isn't defined yet */
-			if (*cp != '=') {
-				/* record it as unresolved */
-				parse_debug(3, NULL, "tdefdecl unres type %d",
-				    h2);
-				*rtdp = calloc(sizeof (**rtdp), 1);
-				(*rtdp)->t_type = TYPEDEF_UNRES;
-				(*rtdp)->t_id = h2;
-				break;
-			} else
-				cp++;
-
-			/* define a new type */
-			cp = tdefdecl(cp, h2, rtdp);
-			if ((*rtdp)->t_id && (*rtdp)->t_id != h2) {
-				ntdp = calloc(sizeof (*ntdp), 1);
-				ntdp->t_type = TYPEDEF;
-				ntdp->t_tdesc = *rtdp;
-				*rtdp = ntdp;
-			}
-
-			addhash(*rtdp, h2);
-
-		} else { /* that type is already defined */
-			if (ntdp->t_type != TYPEDEF || ntdp->t_name != NULL) {
-				*rtdp = ntdp;
-			} else {
-				parse_debug(3, NULL,
-				    "No duplicate typedef anon for ref");
-				*rtdp = ntdp;
-			}
-		}
-		break;
*** 952 LINES SKIPPED ***