1178481Sjb/*
2178481Sjb * CDDL HEADER START
3178481Sjb *
4178481Sjb * The contents of this file are subject to the terms of the
5178481Sjb * Common Development and Distribution License, Version 1.0 only
6178481Sjb * (the "License").  You may not use this file except in compliance
7178481Sjb * with the License.
8178481Sjb *
9178481Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10178481Sjb * or http://www.opensolaris.org/os/licensing.
11178481Sjb * See the License for the specific language governing permissions
12178481Sjb * and limitations under the License.
13178481Sjb *
14178481Sjb * When distributing Covered Code, include this CDDL HEADER in each
15178481Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16178481Sjb * If applicable, add the following below this CDDL HEADER, with the
17178481Sjb * fields enclosed by brackets "[]" replaced with your own identifying
18178481Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
19178481Sjb *
20178481Sjb * CDDL HEADER END
21178481Sjb */
22178481Sjb/*
23178481Sjb * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24178481Sjb * Use is subject to license terms.
25178481Sjb */
26178481Sjb
27178481Sjb#pragma ident	"%Z%%M%	%I%	%E% SMI"
28178481Sjb
29178481Sjb/*
30178481Sjb * This is a test program designed to catch mismerges and mistranslations from
31178481Sjb * stabs to CTF.
32178481Sjb *
33178481Sjb * Given a file with stabs data and a file with CTF data, determine whether
34178481Sjb * or not all of the data structures and objects described by the stabs data
35178481Sjb * are present in the CTF data.
36178481Sjb */
37178481Sjb
38178481Sjb#include <stdio.h>
39178481Sjb#include <stdlib.h>
40178481Sjb#include <assert.h>
41178481Sjb
42178481Sjb#include "ctftools.h"
43178481Sjb
44178481Sjbchar *progname;
45178481Sjbint debug_level = DEBUG_LEVEL;
46178481Sjb
47178481Sjbstatic void
48178481Sjbusage(void)
49178481Sjb{
50178481Sjb	fprintf(stderr, "Usage: %s ctf_file stab_file\n", progname);
51178481Sjb}
52178481Sjb
53178481Sjbint
54178481Sjbmain(int argc, char **argv)
55178481Sjb{
56178481Sjb	tdata_t *ctftd, *stabrtd, *stabtd, *difftd;
57178481Sjb	char *ctfname, *stabname;
58178481Sjb	int new;
59178481Sjb
60178481Sjb	progname = argv[0];
61178481Sjb
62178481Sjb	if (argc != 3) {
63178481Sjb		usage();
64178481Sjb		exit(2);
65178481Sjb	}
66178481Sjb
67178481Sjb	ctfname = argv[1];
68178481Sjb	stabname = argv[2];
69178481Sjb
70178481Sjb	stabrtd = tdata_new();
71178481Sjb	stabtd = tdata_new();
72178481Sjb	difftd = tdata_new();
73178481Sjb
74178481Sjb	if (read_stabs(stabrtd, stabname, 0) != 0)
75178481Sjb		merge_into_master(stabrtd, stabtd, NULL, 1);
76178481Sjb	else if (read_ctf(&stabname, 1, NULL, read_ctf_save_cb, &stabtd, 0)
77178481Sjb	    == 0)
78178481Sjb		terminate("%s doesn't have stabs or CTF\n", stabname);
79178481Sjb
80178481Sjb	if (read_ctf(&ctfname, 1, NULL, read_ctf_save_cb, &ctftd, 0) == 0)
81178481Sjb		terminate("%s doesn't contain CTF data\n", ctfname);
82178481Sjb
83178481Sjb	merge_into_master(stabtd, ctftd, difftd, 0);
84178481Sjb
85178481Sjb	if ((new = hash_count(difftd->td_iihash)) != 0) {
86178481Sjb		(void) hash_iter(difftd->td_iihash, (int (*)())iidesc_dump,
87178481Sjb		    NULL);
88178481Sjb		terminate("%s grew by %d\n", stabname, new);
89178481Sjb	}
90178481Sjb
91178481Sjb	return (0);
92178481Sjb}
93