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	"@(#)compare.c	1.6	05/06/08 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
44#if defined(__APPLE__)
45extern const
46#endif /* __APPLE__ */
47char *progname;
48int debug_level = DEBUG_LEVEL;
49
50static void
51usage(void)
52{
53	fprintf(stderr, "Usage: %s ctf_file stab_file\n", progname);
54}
55
56int
57main(int argc, char **argv)
58{
59	tdata_t *ctftd, *stabrtd, *stabtd, *difftd;
60	char *ctfname, *stabname;
61	int new;
62
63	progname = argv[0];
64
65	if (argc != 3) {
66		usage();
67		exit(2);
68	}
69
70	ctfname = argv[1];
71	stabname = argv[2];
72
73	stabrtd = tdata_new();
74	stabtd = tdata_new();
75	difftd = tdata_new();
76
77	if (read_stabs(stabrtd, stabname, 0) != 0)
78		merge_into_master(stabrtd, stabtd, NULL, 1);
79	else if (read_ctf(&stabname, 1, NULL, read_ctf_save_cb, &stabtd, 0)
80	    == 0)
81		terminate("%s doesn't have stabs or CTF\n", stabname);
82
83	if (read_ctf(&ctfname, 1, NULL, read_ctf_save_cb, &ctftd, 0) == 0)
84		terminate("%s doesn't contain CTF data\n", ctfname);
85
86	merge_into_master(stabtd, ctftd, difftd, 0);
87
88	if ((new = hash_count(difftd->td_iihash)) != 0) {
89		(void) hash_iter(difftd->td_iihash, (int (*)())iidesc_dump,
90		    NULL);
91		terminate("%s grew by %d\n", stabname, new);
92	}
93
94	return (0);
95}
96