1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29/*
30 * This is a test program designed to catch mismerges and mistranslations from
31 * stabs to CTF.
32 *
33 * Given a file with stabs data and a file with CTF data, determine whether
34 * or not all of the data structures and objects described by the stabs data
35 * are present in the CTF data.
36 */
37
38#include <stdio.h>
39#include <stdlib.h>
40#include <assert.h>
41
42#include "ctftools.h"
43
44char *progname;
45int debug_level = DEBUG_LEVEL;
46
47static void
48usage(void)
49{
50	fprintf(stderr, "Usage: %s ctf_file stab_file\n", progname);
51}
52
53int
54main(int argc, char **argv)
55{
56	tdata_t *ctftd, *stabrtd, *stabtd, *difftd;
57	char *ctfname, *stabname;
58	int new;
59
60	progname = argv[0];
61
62	if (argc != 3) {
63		usage();
64		exit(2);
65	}
66
67	ctfname = argv[1];
68	stabname = argv[2];
69
70	stabrtd = tdata_new();
71	stabtd = tdata_new();
72	difftd = tdata_new();
73
74	if (read_stabs(stabrtd, stabname, 0) != 0)
75		merge_into_master(stabrtd, stabtd, NULL, 1);
76	else if (read_ctf(&stabname, 1, NULL, read_ctf_save_cb, &stabtd, 0)
77	    == 0)
78		terminate("%s doesn't have stabs or CTF\n", stabname);
79
80	if (read_ctf(&ctfname, 1, NULL, read_ctf_save_cb, &ctftd, 0) == 0)
81		terminate("%s doesn't contain CTF data\n", ctfname);
82
83	merge_into_master(stabtd, ctftd, difftd, 0);
84
85	if ((new = hash_count(difftd->td_iihash)) != 0) {
86		(void) hash_iter(difftd->td_iihash, (int (*)())iidesc_dump,
87		    NULL);
88		terminate("%s grew by %d\n", stabname, new);
89	}
90
91	return (0);
92}
93