#include "msg.h"
#include "_debug.h"
#include "libld.h"
void
Dbg_dl_iphdr_enter(Rt_map *clmp, u_longlong_t cnt_map, u_longlong_t cnt_unmap)
{
Lm_list *lml = LIST(clmp);
if (DBG_NOTCLASS(DBG_C_DL))
return;
Dbg_util_nl(lml, DBG_NL_STD);
dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_ENTER), NAME(clmp));
dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_MAPCNT), cnt_map, cnt_unmap);
}
void
Dbg_dl_iphdr_callback(Lm_list *lml, struct dl_phdr_info *info)
{
if (DBG_NOTCLASS(DBG_C_DL))
return;
dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_CALLBACK));
dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_NAME), info->dlpi_name);
dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_ADDR), EC_ADDR(info->dlpi_addr));
dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_PHDR),
EC_ADDR(CAST_PTRINT(Addr, info->dlpi_phdr)),
EC_WORD(info->dlpi_phnum));
}
void
Dbg_dl_iphdr_mapchange(Lm_list *lml, u_longlong_t cnt_map,
u_longlong_t cnt_unmap)
{
if (DBG_NOTCLASS(DBG_C_DL))
return;
dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_MAPCNG));
dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_MAPCNT), cnt_map, cnt_unmap);
}
void
Dbg_dl_iphdr_unmap_ret(Lm_list *lml)
{
if (DBG_NOTCLASS(DBG_C_DL))
return;
dbg_print(lml, MSG_INTL(MSG_DL_IPHDR_UNMAP));
}
void
Dbg_dl_dlopen(Rt_map *clmp, const char *name, int *in_nfavl, int mode)
{
Conv_dl_mode_buf_t dl_mode_buf;
Lm_list *lml = LIST(clmp);
const char *retry;
if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_DL))
return;
if (in_nfavl)
retry = MSG_ORIG(MSG_STR_EMPTY);
else
retry = MSG_INTL(MSG_STR_RETRY);
Dbg_util_nl(lml, DBG_NL_STD);
dbg_print(lml, MSG_INTL(MSG_DL_DLOPEN), name, NAME(clmp), retry,
conv_dl_mode(mode, 0, &dl_mode_buf));
}
void
Dbg_dl_dlclose(Rt_map *clmp, const char *name, int flag)
{
const char *str;
Lm_list *lml = LIST(clmp);
if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_DL))
return;
if (flag == DBG_DLCLOSE_IGNORE)
str = MSG_INTL(MSG_STR_IGNORE);
else
str = MSG_ORIG(MSG_STR_EMPTY);
Dbg_util_nl(lml, DBG_NL_STD);
dbg_print(lml, MSG_INTL(MSG_DL_DLCLOSE), name, NAME(clmp), str);
}
void
Dbg_dl_dldump(Rt_map *clmp, const char *ipath, const char *opath, int flags)
{
Conv_dl_flag_buf_t dl_flag_buf;
Lm_list *lml = LIST(clmp);
if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_DL))
return;
Dbg_util_nl(lml, DBG_NL_STD);
dbg_print(lml, MSG_INTL(MSG_DL_DLDUMP), ipath, NAME(clmp),
opath ? opath : MSG_INTL(MSG_STR_NULL),
conv_dl_flag(flags, 0, &dl_flag_buf));
}
void
Dbg_dl_dlerror(Rt_map *clmp, const char *str)
{
Lm_list *lml = LIST(clmp);
if (DBG_NOTCLASS(DBG_C_DL))
return;
Dbg_util_nl(lml, DBG_NL_STD);
dbg_print(lml, MSG_INTL(MSG_DL_DLERROR), NAME(clmp),
str ? str : MSG_INTL(MSG_STR_NULL));
}
void
Dbg_dl_dladdr(Rt_map *clmp, void *addr)
{
Lm_list *lml = LIST(clmp);
if (DBG_NOTCLASS(DBG_C_DL))
return;
Dbg_util_nl(lml, DBG_NL_STD);
dbg_print(lml, MSG_INTL(MSG_DL_DLADDR), NAME(clmp), EC_NATPTR(addr));
}
void
Dbg_dl_dlsym(Rt_map *clmp, const char *sym, int *in_nfavl, const char *next,
int type)
{
const char *str, *retry, *from = NAME(clmp);
Lm_list *lml = LIST(clmp);
static const Msg dlsym_msg[DBG_DLSYM_NUM] = {
MSG_STR_EMPTY,
MSG_DLSYM_NEXT,
MSG_DLSYM_DEFAULT,
MSG_DLSYM_SELF,
MSG_DLSYM_PROBE,
MSG_DLSYM_SINGLETON
};
#if DBG_DLSYM_NUM != (DBG_DLSYM_SINGLETON + 1)
#error DBG_DLSYM_NUM has grown
#endif
if (DBG_NOTCLASS(DBG_C_SYMBOLS | DBG_C_DL))
return;
if (in_nfavl)
retry = MSG_ORIG(MSG_STR_EMPTY);
else
retry = MSG_INTL(MSG_STR_RETRY);
if (type >= DBG_DLSYM_NUM)
type = 0;
str = MSG_ORIG(dlsym_msg[type]);
Dbg_util_nl(lml, DBG_NL_STD);
if (next == 0)
dbg_print(lml, MSG_INTL(MSG_DLSYM_1), Dbg_demangle_name(sym),
from, retry, str);
else
dbg_print(lml, MSG_INTL(MSG_DLSYM_2), Dbg_demangle_name(sym),
from, next, retry, str);
}
void
Dbg_dl_dlinfo(Rt_map *clmp, const char *name, int request, void *addr)
{
Lm_list *lml = LIST(clmp);
if (DBG_NOTCLASS(DBG_C_DL))
return;
Dbg_util_nl(lml, DBG_NL_STD);
dbg_print(lml, MSG_INTL(MSG_DL_DLINFO), NAME(clmp), name,
conv_dl_info(request), EC_NATPTR(addr));
}