Rui Paulo e0ea83ebb1 Update DTrace userland code to the latest available.
Summary of changes:

- libdtrace

changeset:   12902:3bb859a7330c
user:        Bryan Cantrill <Bryan.Cantrill@Sun.COM>
date:        Fri Jul 23 17:34:02 2010 -0700
summary:     6679140 asymmetric alloc/dealloc activity can induce dynamic variable drops

changeset:   12692:4341b447c069
user:        Ali Bahrami <Ali.Bahrami@Oracle.COM>
date:        Thu Jun 24 18:16:42 2010 -0600
summary:     6916796 OSnet mapfiles should use version 2 link-editor syntax

changeset:   12507:501806a754d2
user:        Alan Maguire <Alan.Maguire@Sun.COM>
date:        Thu May 27 17:29:51 2010 -0400
summary:     PSARC 2010/106 DTrace TCP and UDP providers

changeset:   11798:1e7f1f154004
user:        Roger A. Faulkner <Roger.Faulkner@Sun.COM>
date:        Sun Feb 28 18:42:20 2010 -0800
summary:     PSARC 2009/657 delete obsolete system call traps

changeset:   11466:d60272412fb0
user:        Roger A. Faulkner <Roger.Faulkner@Sun.COM>
date:        Mon Jan 11 17:42:13 2010 -0800
summary:     6915578 MUTEX_HELD() and RW_LOCK_HELD() macros should be available to Posix threads

changeset:   11237:0d23e47ed228
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Dec 03 13:39:19 2009 +0000
summary:     6795386 macro arguments and globbing in DTrace probe descriptions don't mix

changeset:   10791:944abfb5b345
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Wed Oct 14 11:25:23 2009 +0100
summary:     6886953 large symbols lead to stack exhaustion

changeset:   10326:8e3fbeec2d76
user:        Siddheshwar Mahesh <Siddheshwar.Mahesh@Sun.COM>
date:        Mon Aug 17 13:26:49 2009 -0500
summary:     6868411 NFS provider generates error on ci_remote on RDMA operations

changeset:   10207:87c40ea3fc4b
user:        jmcp <James.McPherson@Sun.COM>
date:        Wed Jul 29 16:56:03 2009 -0700
summary:     6864230 hiho, hiho, it'ch chtime for CH to go

changeset:   10044:2643c1cd9e2a
user:        Priya Krishnan <Priya.Krishnan@Sun.COM>
date:        Mon Jul 06 21:19:41 2009 -0400
summary:     6855027 iscsit.d breaks dtrace in osol based on snv_117

changeset:   9900:1b86d65a4f9e
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Thu Jun 18 13:16:39 2009 -0600
summary:     6851224 elf_getshnum() and elf_getshstrndx() incompatible with 2002 ELF gABI agreement

changeset:   9885:a3d5e9d9e779
user:        Robert Mastors <Robert.Mastors@Sun.COM>
date:        Tue Jun 16 15:25:25 2009 -0500
summary:     6711844 assert: vp->v_shrlocks == 0L, file: ../../common/fs/vnode.c, line: 2333

changeset:   9881:741c9e4e094c
user:        Charles Ting <Charles.Ting@Sun.COM>
date:        Tue Jun 16 14:51:40 2009 -0400
summary:     6849606 SRP DTrace Probe for xfer-done misses completion of READ transfers

changeset:   9829:e8059fcaee97
user:        Charles Ting <Charles.Ting@Sun.COM>
date:        Tue Jun 09 10:11:35 2009 -0400
summary:     6804431 Add Dtrace probes to SRPT

changeset:   9812:a2990074321f
user:        Priya Krishnan <Priya.Krishnan@Sun.COM>
date:        Mon Jun 08 09:49:48 2009 -0400
summary:     6847237 The iscsit.d DTrace translator should include iscsi.d for the definition of iscsiinfo_t

changeset:   9721:4f7e194c7c37
user:        Priya Krishnan <Priya.Krishnan@Sun.COM>
date:        Tue May 26 10:40:43 2009 -0400
summary:     6809997 COMSTAR iscsi target DTrace Provider needed

changeset:   9625:8aa5731291b4
user:        Sam Cramer <Sam.Cramer@Sun.COM>
date:        Wed May 13 17:10:06 2009 -0700
summary:     6840354 "/usr/lib/dtrace/fc.d", line 59: syntax error near "fct_local_port_t"

changeset:   9609:8874cc8d5e3f
user:        Sam Cramer <Sam.Cramer@Sun.COM>
date:        Mon May 11 21:02:27 2009 -0700
summary:     6809580 fct DTrace providers needed for qlt

changeset:   9578:c4b38ec17f4e
user:        Sam Cramer <Sam.Cramer@Sun.COM>
date:        Fri May 08 12:12:40 2009 -0700
summary:     6809580 fct DTrace providers needed for qlt

changeset:   9531:dc8924ef7839
user:        Rafael Vanoni <rafael.vanoni@sun.com>
date:        Mon May 04 11:48:15 2009 -0700
summary:     6730130 dtrace missing printf handler for stdev

changeset:   9389:750ed3471e90
user:        Vamsi Nagineni <Vamsi.Krishna@Sun.COM>
date:        Fri Apr 17 06:26:47 2009 -0700
summary:     6812050 dtrace should translate curpsinfo->pr_contract

changeset:   9085:ff7eb0bace56
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Wed Mar 18 13:28:28 2009 -0600
summary:     6813909 generalize eh_frame support to non-amd64 platforms

changeset:   8803:8c01b39012c9
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Fri Feb 13 07:13:13 2009 +0000
summary:     PSARC 2008/480 DTrace CPC Provider

changeset:   8744:03d5725cda56
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Tue Feb 10 09:38:02 2009 -0700
summary:     6798660 Cadmium .NOT file processing problem with CWD relative file paths

changeset:   8337:079ecc003ca6
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Dec 11 11:26:47 2008 +0000
summary:     6750659 drti.o crashes app due to corrupt environment

changeset:   7991:d3b751ef3d85
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Mon Nov 03 10:26:23 2008 +0000
summary:     6738982 Representative thread after DTrace stop() action is incorrect

changeset:   7208:568549b138d8
user:        vv149972
date:        Mon Jul 28 23:14:31 2008 -0700
summary:     6696397 NFS v3 provider reports all UDP clients as 0.0.0.0

changeset:   6878:360e73ea6b0c
user:        brendan
date:        Fri Jun 13 19:06:55 2008 -0700
summary:     PSARC 2008/302 DTrace IP Provider

changeset:   6554:b5817e112852
user:        ahl
date:        Mon May 05 14:38:24 2008 -0700
summary:     6677812 race between dtrace activities in non-local zones

----

- ctf tools:

changeset:   12177:800b7f847f1e
user:        Surya Prakki <Surya.Prakki@Sun.COM>
date:        Sun Apr 18 23:59:57 2010 -0700
summary:     6941452 ctfconvert fails on VLAs with code generated by SS12u1

changeset:   11432:c1c450bf62f2
user:        John Levon <john.levon@sun.com>
date:        Tue Jan 05 06:57:53 2010 -0800
summary:     6905711 anonymous and empty SOUs crash ctfconvert

changeset:   11227:cd2ac59c39f2
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Wed Dec 02 15:37:55 2009 -0700
summary:     6900241 ld should track SHT_GROUP sections by symbol name, not section name

changeset:   10380:5394a7172e1f
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Tue Aug 25 13:51:43 2009 -0600
summary:     6866605 SUNWonbld ELF analysis tools need overhaul (fix ctfmerge/libc dependency)

changeset:   10207:87c40ea3fc4b
user:        jmcp <James.McPherson@Sun.COM>
date:        Wed Jul 29 16:56:03 2009 -0700
summary:     6864230 hiho, hiho, it'ch chtime for CH to go

changeset:   10206:51f52702df72
user:        John Levon <john.levon@sun.com>
date:        Wed Jul 29 14:36:30 2009 -0700
summary:     6854065 CTF tools should error out given 1024+-member structures

changeset:   7230:429b4f7acf1a
user:        sn199410
date:        Wed Jul 30 16:10:30 2008 -0700
summary:     6575435 ctf tools cannot handle C99 VLAs ("variable length arrays")

changeset:   6936:72189fcd99e4
user:        sommerfe
date:        Sun Jun 22 09:13:44 2008 -0700
summary:     6716983 left-for-dead ctfmerge worker threads awake to take out maker

----

- dtrace command utility:

changeset:   12507:501806a754d2
user:        Alan Maguire <Alan.Maguire@Sun.COM>
date:        Thu May 27 17:29:51 2010 -0400
summary:     PSARC 2010/106 DTrace TCP and UDP providers

changeset:   11838:32bb5d254240
user:        Liane Praza <Liane.Praza@Sun.COM>
date:        Tue Mar 02 19:29:26 2010 -0700
summary:     PSARC 2010/067 Interim modernization updates

changeset:   11270:47a962fe7b45
user:        Frank Van Der Linden <Frank.Vanderlinden@Sun.COM>
date:        Mon Dec 07 13:47:36 2009 -0800
summary:     6907170 fix for 6875656 left out updates to DTrace test suite

changeset:   11237:0d23e47ed228
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Dec 03 13:39:19 2009 +0000
summary:     6795386 macro arguments and globbing in DTrace probe descriptions don't mix

changeset:   11153:dec430d20576
user:        Frank Van Der Linden <Frank.Vanderlinden@Sun.COM>
date:        Sun Nov 22 19:22:26 2009 -0800
summary:     6875656 xdt needs to support more XenTrace probes

changeset:   11102:b91faef0c984
user:        Gavin Maltby <Gavin.Maltby@Sun.COM>
date:        Thu Nov 19 15:28:11 2009 +1100
summary:     PSARC/2009/554 door_xcreate - extended door creation interface for private doors

changeset:   11066:cebb50cbe4f9
user:        Rafael Vanoni <rafael.vanoni@sun.com>
date:        Fri Nov 13 01:32:32 2009 -0800
summary:     PSARC/2009/396 Tickless Kernel Architecture / lbolt decoupling

changeset:   10791:944abfb5b345
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Wed Oct 14 11:25:23 2009 +0100
summary:     6886953 large symbols lead to stack exhaustion

changeset:   10207:87c40ea3fc4b
user:        jmcp <James.McPherson@Sun.COM>
date:        Wed Jul 29 16:56:03 2009 -0700
summary:     6864230 hiho, hiho, it'ch chtime for CH to go

changeset:   9531:dc8924ef7839
user:        Rafael Vanoni <rafael.vanoni@sun.com>
date:        Mon May 04 11:48:15 2009 -0700
summary:     6730130 dtrace missing printf handler for stdev

changeset:   9397:e667d620a75c
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Mon Apr 20 07:58:44 2009 +0100
summary:     6806023 cpc provider event name validation needs to be a bit tighter

changeset:   8803:8c01b39012c9
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Fri Feb 13 07:13:13 2009 +0000
summary:     PSARC 2008/480 DTrace CPC Provider

changeset:   8605:0189cb9c5358
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Jan 22 12:09:13 2009 +0000
summary:     6749441 intrstat(1M) shows zeroed values after suspend/resume

changeset:   8337:079ecc003ca6
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Dec 11 11:26:47 2008 +0000
summary:     6750659 drti.o crashes app due to corrupt environment

changeset:   8287:771477e4b843
user:        John Sonnenschein <John.Sonnenschein@Sun.COM>
date:        Fri Dec 05 19:08:38 2008 -0800
summary:     PSARC 2005/462 Removal of Perl 5.6.1 from Solaris 11

changeset:   7991:d3b751ef3d85
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Mon Nov 03 10:26:23 2008 +0000
summary:     6738982 Representative thread after DTrace stop() action is incorrect

changeset:   7502:da077e5d991e
user:        Aruna Ramakrishna <aruna@cs.umn.edu>
date:        Sat Sep 06 05:36:02 2008 -0400
summary:     6706947 tcp_trace should be replaced with dtrace probes.

changeset:   7484:a48e950bad22
user:        Tom Erickson <tomee@eng.sun.com>
date:        Wed Sep 03 15:14:25 2008 -0700
summary:     6737926 getAggregate() method fails to specify anonymous aggregation explicitly

changeset:   7299:d9a056040774
user:        John Beck <John.Beck@Sun.COM>
date:        Thu Aug 07 12:44:26 2008 -0700
summary:     6734627 protocmp complains about opt/SUNWdtrt/README after TW -> Hg switch

changeset:   6998:58787ea78303
user:        brendan
date:        Tue Jul 01 18:28:22 2008 -0700
summary:     6721426 tst.sdtargs.d passes despite dtrace "invalid address" error

changeset:   6878:360e73ea6b0c
user:        brendan
date:        Fri Jun 13 19:06:55 2008 -0700
summary:     PSARC 2008/302 DTrace IP Provider

changeset:   6670:1961a43f2335
user:        tariq
date:        Tue May 20 15:08:16 2008 -0700
summary:     6685348 Hypervisor event provider for DTrace

changeset:   6554:b5817e112852
user:        ahl
date:        Mon May 05 14:38:24 2008 -0700
summary:     6677812 race between dtrace activities in non-local zones

changeset:   6543:465433824d87
user:        rie
date:        Fri May 02 15:01:06 2008 -0700
summary:     6683064 check_rtime could do with some spring cleaning
2010-08-02 12:13:33 +00:00

480 lines
9.5 KiB
C

/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Routines for manipulating tdesc and tdata structures
*/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <pthread.h>
#include "ctftools.h"
#include "memory.h"
#include "traverse.h"
/*
* The layout hash is used during the equivalency checking. We have a node in
* the child graph that may be equivalent to a node in the parent graph. To
* find the corresponding node (if any) in the parent, we need a quick way to
* get to all nodes in the parent that look like the node in the child. Since a
* large number of nodes don't have names, we need to incorporate the layout of
* the node into the hash. If we don't, we'll end up with the vast majority of
* nodes in bucket zero, with one or two nodes in each of the remaining buckets.
*
* There are a couple of constraints, both of which concern forward
* declarations. Recall that a forward declaration tdesc is equivalent to a
* tdesc that actually defines the structure or union. As such, we cannot
* incorporate anything into the hash for a named struct or union node that
* couldn't be found by looking at the forward, and vice versa.
*/
int
tdesc_layouthash(int nbuckets, void *node)
{
tdesc_t *tdp = node;
char *name = NULL;
ulong_t h = 0;
if (tdp->t_name)
name = tdp->t_name;
else {
switch (tdp->t_type) {
case POINTER:
case TYPEDEF:
case VOLATILE:
case CONST:
case RESTRICT:
name = tdp->t_tdesc->t_name;
break;
case FUNCTION:
h = tdp->t_fndef->fn_nargs +
tdp->t_fndef->fn_vargs;
name = tdp->t_fndef->fn_ret->t_name;
break;
case ARRAY:
h = tdp->t_ardef->ad_nelems;
name = tdp->t_ardef->ad_contents->t_name;
break;
case STRUCT:
case UNION:
/*
* Unnamed structures, which cannot have forward
* declarations pointing to them. We can therefore
* incorporate the name of the first member into
* the hash value, assuming there are any.
*/
if (tdp->t_members != NULL)
name = tdp->t_members->ml_name;
break;
case ENUM:
/* Use the first element in the hash value */
name = tdp->t_emem->el_name;
break;
default:
/*
* Intrinsics, forwards, and typedefs all have
* names.
*/
warning("Unexpected unnamed %d tdesc (ID %d)\n",
tdp->t_type, tdp->t_id);
}
}
if (name)
return (hash_name(nbuckets, name));
return (h % nbuckets);
}
int
tdesc_layoutcmp(void *arg1, void *arg2)
{
tdesc_t *tdp1 = arg1, *tdp2 = arg2;
if (tdp1->t_name == NULL) {
if (tdp2->t_name == NULL)
return (0);
else
return (-1);
} else if (tdp2->t_name == NULL)
return (1);
else
return (strcmp(tdp1->t_name, tdp2->t_name));
}
int
tdesc_idhash(int nbuckets, void *data)
{
tdesc_t *tdp = data;
return (tdp->t_id % nbuckets);
}
int
tdesc_idcmp(void *arg1, void *arg2)
{
tdesc_t *tdp1 = arg1, *tdp2 = arg2;
if (tdp1->t_id == tdp2->t_id)
return (0);
else
return (tdp1->t_id > tdp2->t_id ? 1 : -1);
}
int
tdesc_namehash(int nbuckets, void *data)
{
tdesc_t *tdp = data;
ulong_t h, g;
char *c;
if (tdp->t_name == NULL)
return (0);
for (h = 0, c = tdp->t_name; *c; c++) {
h = (h << 4) + *c;
if ((g = (h & 0xf0000000)) != 0) {
h ^= (g >> 24);
h ^= g;
}
}
return (h % nbuckets);
}
int
tdesc_namecmp(void *arg1, void *arg2)
{
tdesc_t *tdp1 = arg1, *tdp2 = arg2;
return (!streq(tdp1->t_name, tdp2->t_name));
}
/*ARGSUSED1*/
int
tdesc_print(void *data, void *private)
{
tdesc_t *tdp = data;
printf("%7d %s\n", tdp->t_id, tdesc_name(tdp));
return (1);
}
static void
free_intr(tdesc_t *tdp)
{
free(tdp->t_intr);
}
static void
free_ardef(tdesc_t *tdp)
{
free(tdp->t_ardef);
}
static void
free_mlist(tdesc_t *tdp)
{
mlist_t *ml = tdp->t_members;
mlist_t *oml;
while (ml) {
oml = ml;
ml = ml->ml_next;
if (oml->ml_name)
free(oml->ml_name);
free(oml);
}
}
static void
free_elist(tdesc_t *tdp)
{
elist_t *el = tdp->t_emem;
elist_t *oel;
while (el) {
oel = el;
el = el->el_next;
if (oel->el_name)
free(oel->el_name);
free(oel);
}
}
static void (*free_cbs[])(tdesc_t *) = {
NULL,
free_intr,
NULL,
free_ardef,
NULL,
free_mlist,
free_mlist,
free_elist,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
/*ARGSUSED1*/
static int
tdesc_free_cb(tdesc_t *tdp, void *private)
{
if (tdp->t_name)
free(tdp->t_name);
if (free_cbs[tdp->t_type])
free_cbs[tdp->t_type](tdp);
free(tdp);
return (1);
}
void
tdesc_free(tdesc_t *tdp)
{
(void) tdesc_free_cb(tdp, NULL);
}
static int
tdata_label_cmp(labelent_t *le1, labelent_t *le2)
{
return (le1->le_idx - le2->le_idx);
}
void
tdata_label_add(tdata_t *td, char *label, int idx)
{
labelent_t *le = xmalloc(sizeof (*le));
le->le_name = xstrdup(label);
le->le_idx = (idx == -1 ? td->td_nextid - 1 : idx);
slist_add(&td->td_labels, le, (int (*)())tdata_label_cmp);
}
static int
tdata_label_top_cb(void *data, void *arg)
{
labelent_t *le = data;
labelent_t **topp = arg;
*topp = le;
return (1);
}
labelent_t *
tdata_label_top(tdata_t *td)
{
labelent_t *top = NULL;
(void) list_iter(td->td_labels, tdata_label_top_cb, &top);
return (top);
}
static int
tdata_label_find_cb(labelent_t *le, labelent_t *tmpl)
{
return (streq(le->le_name, tmpl->le_name));
}
int
tdata_label_find(tdata_t *td, char *label)
{
labelent_t let;
labelent_t *ret;
if (streq(label, "BASE")) {
ret = (labelent_t *)list_first(td->td_labels);
return (ret ? ret->le_idx : -1);
}
let.le_name = label;
if (!(ret = (labelent_t *)list_find(td->td_labels, &let,
(int (*)())tdata_label_find_cb)))
return (-1);
return (ret->le_idx);
}
static int
tdata_label_newmax_cb(void *data, void *arg)
{
labelent_t *le = data;
int *newmaxp = arg;
if (le->le_idx > *newmaxp) {
le->le_idx = *newmaxp;
return (1);
}
return (0);
}
void
tdata_label_newmax(tdata_t *td, int newmax)
{
(void) list_iter(td->td_labels, tdata_label_newmax_cb, &newmax);
}
/*ARGSUSED1*/
static void
tdata_label_free_cb(labelent_t *le, void *private)
{
if (le->le_name)
free(le->le_name);
free(le);
}
void
tdata_label_free(tdata_t *td)
{
list_free(td->td_labels, (void (*)())tdata_label_free_cb, NULL);
td->td_labels = NULL;
}
tdata_t *
tdata_new(void)
{
tdata_t *new = xcalloc(sizeof (tdata_t));
new->td_layouthash = hash_new(TDATA_LAYOUT_HASH_SIZE, tdesc_layouthash,
tdesc_layoutcmp);
new->td_idhash = hash_new(TDATA_ID_HASH_SIZE, tdesc_idhash,
tdesc_idcmp);
/*
* This is also traversed as a list, but amortized O(1)
* lookup massively impacts part of the merge phase, so
* we store the iidescs as a hash.
*/
new->td_iihash = hash_new(IIDESC_HASH_SIZE, iidesc_hash, NULL);
new->td_nextid = 1;
new->td_curvgen = 1;
pthread_mutex_init(&new->td_mergelock, NULL);
return (new);
}
void
tdata_free(tdata_t *td)
{
hash_free(td->td_iihash, (void (*)())iidesc_free, NULL);
hash_free(td->td_layouthash, (void (*)())tdesc_free_cb, NULL);
hash_free(td->td_idhash, NULL, NULL);
list_free(td->td_fwdlist, NULL, NULL);
tdata_label_free(td);
free(td->td_parlabel);
free(td->td_parname);
pthread_mutex_destroy(&td->td_mergelock);
free(td);
}
/*ARGSUSED1*/
static int
build_hashes(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
{
tdata_t *td = private;
hash_add(td->td_idhash, ctdp);
hash_add(td->td_layouthash, ctdp);
return (1);
}
static tdtrav_cb_f build_hashes_cbs[] = {
NULL,
build_hashes, /* intrinsic */
build_hashes, /* pointer */
build_hashes, /* array */
build_hashes, /* function */
build_hashes, /* struct */
build_hashes, /* union */
build_hashes, /* enum */
build_hashes, /* forward */
build_hashes, /* typedef */
tdtrav_assert, /* typedef_unres */
build_hashes, /* volatile */
build_hashes, /* const */
build_hashes /* restrict */
};
static void
tdata_build_hashes_common(tdata_t *td, hash_t *hash)
{
(void) iitraverse_hash(hash, &td->td_curvgen, NULL, NULL,
build_hashes_cbs, td);
}
void
tdata_build_hashes(tdata_t *td)
{
tdata_build_hashes_common(td, td->td_iihash);
}
/* Merge td2 into td1. td2 is destroyed by the merge */
void
tdata_merge(tdata_t *td1, tdata_t *td2)
{
td1->td_curemark = MAX(td1->td_curemark, td2->td_curemark);
td1->td_curvgen = MAX(td1->td_curvgen, td2->td_curvgen);
td1->td_nextid = MAX(td1->td_nextid, td2->td_nextid);
hash_merge(td1->td_iihash, td2->td_iihash);
/* Add td2's type tree to the hashes */
tdata_build_hashes_common(td1, td2->td_iihash);
list_concat(&td1->td_fwdlist, td2->td_fwdlist);
td2->td_fwdlist = NULL;
slist_merge(&td1->td_labels, td2->td_labels,
(int (*)())tdata_label_cmp);
td2->td_labels = NULL;
/* free the td2 hashes (data is now part of td1) */
hash_free(td2->td_layouthash, NULL, NULL);
td2->td_layouthash = NULL;
hash_free(td2->td_iihash, NULL, NULL);
td2->td_iihash = NULL;
tdata_free(td2);
}