4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
32 Dbg_dl_iphdr_enter(Rt_map
*clmp
, u_longlong_t cnt_map
, u_longlong_t cnt_unmap
)
34 Lm_list
*lml
= LIST(clmp
);
36 if (DBG_NOTCLASS(DBG_C_DL
))
39 Dbg_util_nl(lml
, DBG_NL_STD
);
40 dbg_print(lml
, MSG_INTL(MSG_DL_IPHDR_ENTER
), NAME(clmp
));
41 dbg_print(lml
, MSG_INTL(MSG_DL_IPHDR_MAPCNT
), cnt_map
, cnt_unmap
);
45 Dbg_dl_iphdr_callback(Lm_list
*lml
, struct dl_phdr_info
*info
)
47 if (DBG_NOTCLASS(DBG_C_DL
))
50 dbg_print(lml
, MSG_INTL(MSG_DL_IPHDR_CALLBACK
));
51 dbg_print(lml
, MSG_INTL(MSG_DL_IPHDR_NAME
), info
->dlpi_name
);
52 dbg_print(lml
, MSG_INTL(MSG_DL_IPHDR_ADDR
), EC_ADDR(info
->dlpi_addr
));
53 dbg_print(lml
, MSG_INTL(MSG_DL_IPHDR_PHDR
),
54 EC_ADDR(CAST_PTRINT(Addr
, info
->dlpi_phdr
)),
55 EC_WORD(info
->dlpi_phnum
));
59 Dbg_dl_iphdr_mapchange(Lm_list
*lml
, u_longlong_t cnt_map
,
60 u_longlong_t cnt_unmap
)
62 if (DBG_NOTCLASS(DBG_C_DL
))
65 dbg_print(lml
, MSG_INTL(MSG_DL_IPHDR_MAPCNG
));
66 dbg_print(lml
, MSG_INTL(MSG_DL_IPHDR_MAPCNT
), cnt_map
, cnt_unmap
);
70 Dbg_dl_iphdr_unmap_ret(Lm_list
*lml
)
72 if (DBG_NOTCLASS(DBG_C_DL
))
75 dbg_print(lml
, MSG_INTL(MSG_DL_IPHDR_UNMAP
));
79 Dbg_dl_dlopen(Rt_map
*clmp
, const char *name
, int *in_nfavl
, int mode
)
81 Conv_dl_mode_buf_t dl_mode_buf
;
82 Lm_list
*lml
= LIST(clmp
);
85 if (DBG_NOTCLASS(DBG_C_FILES
| DBG_C_DL
))
89 * The core functionality of dlopen() can be called twice. The first
90 * attempt can be affected by path names that exist in the "not-found"
91 * AVL tree. Should a "not-found" path name be found, a second attempt
92 * is made to locate the required file (in_nfavl is NULL). This fall-
93 * back provides for file system changes while a process executes.
96 retry
= MSG_ORIG(MSG_STR_EMPTY
);
98 retry
= MSG_INTL(MSG_STR_RETRY
);
100 Dbg_util_nl(lml
, DBG_NL_STD
);
101 dbg_print(lml
, MSG_INTL(MSG_DL_DLOPEN
), name
, NAME(clmp
), retry
,
102 conv_dl_mode(mode
, 0, &dl_mode_buf
));
106 Dbg_dl_dlclose(Rt_map
*clmp
, const char *name
, int flag
)
109 Lm_list
*lml
= LIST(clmp
);
111 if (DBG_NOTCLASS(DBG_C_FILES
| DBG_C_DL
))
114 if (flag
== DBG_DLCLOSE_IGNORE
)
115 str
= MSG_INTL(MSG_STR_IGNORE
);
117 str
= MSG_ORIG(MSG_STR_EMPTY
);
119 Dbg_util_nl(lml
, DBG_NL_STD
);
120 dbg_print(lml
, MSG_INTL(MSG_DL_DLCLOSE
), name
, NAME(clmp
), str
);
124 Dbg_dl_dldump(Rt_map
*clmp
, const char *ipath
, const char *opath
, int flags
)
126 Conv_dl_flag_buf_t dl_flag_buf
;
127 Lm_list
*lml
= LIST(clmp
);
129 if (DBG_NOTCLASS(DBG_C_FILES
| DBG_C_DL
))
132 Dbg_util_nl(lml
, DBG_NL_STD
);
133 dbg_print(lml
, MSG_INTL(MSG_DL_DLDUMP
), ipath
, NAME(clmp
),
134 opath
? opath
: MSG_INTL(MSG_STR_NULL
),
135 conv_dl_flag(flags
, 0, &dl_flag_buf
));
139 Dbg_dl_dlerror(Rt_map
*clmp
, const char *str
)
141 Lm_list
*lml
= LIST(clmp
);
143 if (DBG_NOTCLASS(DBG_C_DL
))
146 Dbg_util_nl(lml
, DBG_NL_STD
);
147 dbg_print(lml
, MSG_INTL(MSG_DL_DLERROR
), NAME(clmp
),
148 str
? str
: MSG_INTL(MSG_STR_NULL
));
152 Dbg_dl_dladdr(Rt_map
*clmp
, void *addr
)
154 Lm_list
*lml
= LIST(clmp
);
156 if (DBG_NOTCLASS(DBG_C_DL
))
159 Dbg_util_nl(lml
, DBG_NL_STD
);
160 dbg_print(lml
, MSG_INTL(MSG_DL_DLADDR
), NAME(clmp
), EC_NATPTR(addr
));
164 Dbg_dl_dlsym(Rt_map
*clmp
, const char *sym
, int *in_nfavl
, const char *next
,
167 const char *str
, *retry
, *from
= NAME(clmp
);
168 Lm_list
*lml
= LIST(clmp
);
170 static const Msg dlsym_msg
[DBG_DLSYM_NUM
] = {
171 MSG_STR_EMPTY
, /* MSG_ORIG(MSG_STR_EMPTY) */
172 MSG_DLSYM_NEXT
, /* MSG_ORIG(MSG_DLSYM_NEXT) */
173 MSG_DLSYM_DEFAULT
, /* MSG_ORIG(MSG_DLSYM_DEFAULT) */
174 MSG_DLSYM_SELF
, /* MSG_ORIG(MSG_DLSYM_SELF) */
175 MSG_DLSYM_PROBE
, /* MSG_ORIG(MSG_DLSYM_PROBE) */
176 MSG_DLSYM_SINGLETON
/* MSG_ORIG(MSG_DLSYM_SINGLETON) */
178 #if DBG_DLSYM_NUM != (DBG_DLSYM_SINGLETON + 1)
179 #error DBG_DLSYM_NUM has grown
181 if (DBG_NOTCLASS(DBG_C_SYMBOLS
| DBG_C_DL
))
185 * The core functionality of dlsym() can be called twice. The first
186 * attempt can be affected by path names that exist in the "not-found"
187 * AVL tree. Should a "not-found" path name be found, a second attempt
188 * is made to locate the required file (in_nfavl is NULL). This fall-
189 * back provides for file system changes while a process executes.
192 retry
= MSG_ORIG(MSG_STR_EMPTY
);
194 retry
= MSG_INTL(MSG_STR_RETRY
);
196 if (type
>= DBG_DLSYM_NUM
)
198 str
= MSG_ORIG(dlsym_msg
[type
]);
200 Dbg_util_nl(lml
, DBG_NL_STD
);
202 dbg_print(lml
, MSG_INTL(MSG_DLSYM_1
), Dbg_demangle_name(sym
),
205 dbg_print(lml
, MSG_INTL(MSG_DLSYM_2
), Dbg_demangle_name(sym
),
206 from
, next
, retry
, str
);
210 Dbg_dl_dlinfo(Rt_map
*clmp
, const char *name
, int request
, void *addr
)
212 Lm_list
*lml
= LIST(clmp
);
214 if (DBG_NOTCLASS(DBG_C_DL
))
217 Dbg_util_nl(lml
, DBG_NL_STD
);
218 dbg_print(lml
, MSG_INTL(MSG_DL_DLINFO
), NAME(clmp
), name
,
219 conv_dl_info(request
), EC_NATPTR(addr
));