summaryrefslogtreecommitdiff
path: root/usr/src/cmd/sgs/liblddbg/common/tls.c
blob: bd4250ef6c8bbf7ea6bf921a0094d87a53e151de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * 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 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#include	<link.h>
#include	<libc_int.h>
#include	<rtld.h>
#include	<strings.h>
#include	<debug.h>
#include	"msg.h"
#include	"_debug.h"

#define	FLAGSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
		MSG_TLS_FLAG_STATIC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE

static void
Dbg_tls_modent(Lm_list *lml, TLS_modinfo * tmodent)
{
	/*
	 * MSG_ORIG(MSG_TLS_FLAG_STATIC)
	 */
	static char	flagstr[FLAGSZ];
	static Val_desc	vda[] = {
		{ TM_FLG_STATICTLS,	MSG_TLS_FLAG_STATIC },
		{ 0,			0 }
	};
	static CONV_EXPN_FIELD_ARG conv_arg = { flagstr, sizeof (flagstr) };

	ulong_t	flags;

	if ((flags = tmodent->tm_flags) != 0) {
		conv_arg.oflags = conv_arg.rflags = flags;
		(void) conv_expn_field(&conv_arg, vda, 0);
	} else {
		flagstr[0] = '\0';
	}

	dbg_print(lml, MSG_INTL(MSG_TLS_MODENT1),
	    EC_XWORD((uintptr_t)tmodent->tm_tlsblock),
	    EC_XWORD(tmodent->tm_stattlsoffset), EC_XWORD(tmodent->tm_flags),
	    flagstr);
	dbg_print(lml, MSG_INTL(MSG_TLS_MODENT2),
	    EC_XWORD(tmodent->tm_filesz), EC_XWORD(tmodent->tm_memsz),
	    EC_XWORD(tmodent->tm_modid));
}

void
Dbg_tls_static_block(Lm_list *lml, void *list, ulong_t size, ulong_t resv)
{
	if (DBG_NOTCLASS(DBG_C_TLS))
		return;

	Dbg_util_nl(lml, DBG_NL_STD);

	if (list) {
		ulong_t		ndx;
		TLS_modinfo	**tlsmodlist;

		tlsmodlist = (TLS_modinfo **)list;

		for (ndx = 0; tlsmodlist[ndx]; ndx++) {
			dbg_print(lml, MSG_INTL(MSG_TLS_STATBLOCK1), ndx,
			    tlsmodlist[ndx]->tm_modname);
			Dbg_tls_modent(lml, tlsmodlist[ndx]);
			Dbg_util_nl(lml, DBG_NL_STD);
		}
	}
	dbg_print(lml, MSG_INTL(MSG_TLS_STATBLOCK2), EC_XWORD(size),
	    EC_XWORD(resv));
}

void
Dbg_tls_static_resv(Rt_map *lmp, ulong_t size, ulong_t resv)
{
	Lm_list	*lml = LIST(lmp);

	if (DBG_NOTCLASS(DBG_C_TLS))
		return;

	Dbg_util_nl(lml, DBG_NL_STD);
	dbg_print(lml, MSG_INTL(MSG_TLS_STATBLOCK3), TLSMODID(lmp), NAME(lmp),
	    EC_XWORD(size), EC_XWORD(resv));
}

void
Dbg_tls_modactivity(Lm_list *lml, void *vtlsmodent, uint_t flag)
{
	const char	*str;
	TLS_modinfo	*tlsmodent;

	if (DBG_NOTCLASS(DBG_C_TLS))
		return;

	if (flag == TM_FLG_MODADD)
		str = MSG_INTL(MSG_TLS_ADD);
	else
		str = MSG_INTL(MSG_TLS_REMOVE);

	tlsmodent = (TLS_modinfo *)vtlsmodent;
	Dbg_util_nl(lml, DBG_NL_STD);
	dbg_print(lml, MSG_INTL(MSG_TLS_MODACT), str, tlsmodent->tm_modname);
	Dbg_tls_modent(lml, tlsmodent);
}