/*
* 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
* 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.
*/
#include <libintl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <alist.h>
#include <debug.h>
#include <_debug.h>
#include <msg.h>
/*
* Define a debug descriptor. Note, although this provides the default
* definition to which most users bind, ld.so.1 must provide its own definition,
* and thus interposition is expected. This item should be defined NODIRECT.
*/
int _Dbg_cnt = 0;
/*
* Debugging initialization and processing. The dbg_options[] array defines
* a set of option strings that can be specified using the -D flag or from an
* environment variable. For each option, a class is enabled in the d_class
* bit mask, or an extra flag is enabled in the d_extra bit mask.
*/
{NULL, 0, 0},
};
{NULL, 0, 0},
};
{NULL, 0, 0},
};
/*
* Compare name to the options found in optarr. If one matches,
* update *dbp and return TRUE. Otherwise, FALSE.
*/
static Boolean
{
continue;
} else {
}
return (TRUE);
}
return (FALSE);
}
/*
* Provide a debugging usage message
*/
void
Dbg_help(void)
{
Dbg_util_nl(0, DBG_NL_STD);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
Dbg_util_nl(0, DBG_NL_FRC);
}
/*
* Provide a debugging message showing the version of the linker package
*/
void
Dbg_version(void)
{
Dbg_util_nl(0, DBG_NL_STD);
Dbg_util_nl(0, DBG_NL_STD);
}
/*
* Messaging support - funnel everything through dgettext() as this provides
* the real binding to libc.
*/
const char *
{
}
/*
* Given a name starting with "lmid", finish processing it. Return TRUE
* if a valid lmid token was seen, and FALSE for any error.
*
* exit:
* On failure, returns FALSE, indicating a syntax error
*
* On success:
* - Appropriate flags in dbg->d_extra have been set
* - Any link-map list names specified have been added to
* d_list, for the rtld dbg_print() to compare against
* link-map list names.
* - TRUE is returned.
*/
static Boolean
{
/*
* "lmid" can have an optional argument. Allowed values are "all",
* "alt[0-9]+", "base", or "ldso". Alt has a variable ending, but
* we can use process_options() to handle the other three.
*/
};
const char *lmid_opt;
/* If it's a plain "lmid", we can set the flag and return now */
return (TRUE);
}
/* If there's no value, its an error */
CONV_SPEXV_F_UCASE, &lmid_opt) == 0)
return (FALSE);
/*
* ALL, BASE, or LDSO?
*/
/*
* If BASE, and we haven't already seen it, add it to the
* rtld name matching list. For the others, setting the
* e_extra bit suffices.
*/
AL_CNT_DEBUG) == NULL))
return (FALSE);
/* Add the resulting flags into the callers descriptor */
return (TRUE);
}
/*
* ALT?
*/
MSG_TOK_LMID_ALT_SIZE) == 0) {
/* 'ALT' without a # means "all alternative link-map lists" */
if (*tail == '\0') {
return (TRUE);
}
/*
* It is ALT[0-9]+. Make sure the characters following 'ALT'
* are numbers, and then add it to the rtld name matching list.
*/
return (FALSE);
return (FALSE);
return (TRUE);
}
/* It's nothing we recognize */
return (FALSE);
}
/*
* Validate and enable the appropriate debugging classes.
*
* entry:
* string - String to be analyzed for debugging options
* dbp - Pointer to debug descriptor to be initialized
* outfile_ret - NULL, or pointer to receive result of 'output='
* token. A NULL value means that the 'output=' token
* is not accepted. A non-NULL value means that it is.
*
* exit:
* On failure, False (0) is returned.
*
* On success, string has been parsed, and the descriptor referenced
* by dbp has been initialized. If outfile is non-NULL, *outfile will
* be set to NULL if the 'output=' token is not present, and to the
* user supplied string otherwise. True (1) is returned.
*/
int
const char **outfile)
{
/* strtok_r() operations. */
char *lasts;
/*
* Clear the help flags --- these items only apply for a single
* call to Dbg_setup().
*/
return (0);
if (outfile)
/*
* The token should be of the form "-Dtok,tok,tok,...". Separate the
* pieces and build up the appropriate mask, unrecognized options are
* flagged.
*/
do {
/* Remove leading and trailing whitespace */
if (name[0] == '!') {
name++;
} else
if (*name == '\0')
continue; /* Skip null token */
/*
* First, determine if the token represents a class or
* extra.
*/
continue;
switch (caller) {
case DBG_CALLER_LD: /* ld only tokens */
continue;
break;
case DBG_CALLER_RTLD: /* rtld only tokens */
continue;
break;
}
/* The remaining options do not accept negation */
if (!set) {
continue;
}
/*
* Is it an 'output=' token? This item is a special
* case because it depends on the presence of
* a non-NULL outfile argument, and because the
* part following the '=' is variable.
*/
MSG_TOK_OUTFILE_SIZE) == 0) {
MSG_TOK_OUTFILE_SIZE, 0, outfile))
continue;
}
/*
* Only the rtld "lmid" token is left.
*/
continue;
/* If we make it here, the token is not understood */
}
/*
* If the debug help option was specified and this is the only debug
* class, return an indication that the user should exit.
*/
return (1);
}
/*
* Define our own printing routine. This provides a basic fallback, as ld(1)
* and ld.so.1(1) provide their own routines that augment their diagnostic
* output, and direct the output to stderr. This item should be defined
* NODIRECT.
*/
/* PRINTFLIKE2 */
void
{
#if defined(lint)
/*
* The lml argument is only meaningful for diagnostics sent to ld.so.1.
* Supress the lint error by making a dummy assignment.
*/
lml = 0;
#endif
}
/*
* Return an internationalized state transition string. These are used by
* various debugging output.
*/
const char *
{
MSG_STR_ADD, /* MSG_INTL(MSG_STR_ADD) */
MSG_STR_CURRENT, /* MSG_INTL(MSG_STR_CURRENT) */
MSG_STR_EXCLUDE, /* MSG_INTL(MSG_STR_EXCLUDE) */
MSG_STR_IGNORE, /* MSG_INTL(MSG_STR_IGNORE) */
MSG_STR_MOD_BEFORE, /* MSG_INTL(MSG_STR_MOD_BEFORE) */
MSG_STR_MOD_AFTER, /* MSG_INTL(MSG_STR_MOD_AFTER) */
MSG_STR_NEW, /* MSG_INTL(MSG_STR_NEW) */
MSG_STR_NEW_IMPLICIT, /* MSG_INTL(MSG_STR_NEW_IMPLICIT) */
MSG_STR_RESET, /* MSG_INTL(MSG_STR_RESET) */
MSG_STR_ORIGINAL, /* MSG_INTL(MSG_STR_ORIGINAL) */
MSG_STR_RESOLVED, /* MSG_INTL(MSG_STR_RESOLVED) */
};
#endif
}