ctf_lookup.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <ctf_impl.h>
/*
* Compare the given input string and length against a table of known C storage
* qualifier keywords. We just ignore these in ctf_lookup_by_name, below.
*/
static int
{
static const struct qual {
const char *q_name;
} q[] = {
{ "auto", 4 },
{ "const", 5 },
{ "extern", 6 },
{ "register", 8 },
{ "restrict", 8 },
{ "_Restrict", 9 },
{ "static", 6 },
{ "volatile", 8 },
{ NULL, 0 }
};
int i;
return (1);
}
return (0);
}
/*
* Attempt to convert the given C type name into the corresponding CTF type ID.
* It is not possible to do complete and proper conversion of type names
* without implementing a more full-fledged parser, which is necessary to
* handle things like types that are function pointers to functions that
* have arguments that are function pointers, and fun stuff like that.
* Instead, this function implements a very simple conversion algorithm that
* finds the things that we actually care about: structs, unions, enums,
* integers, floats, typedefs, and pointers to any of these named types.
*/
{
static const char delimiters[] = " \t\n\r\v\f*";
const ctf_lookup_t *lp;
const ctf_helem_t *hp;
const char *p, *q, *end;
while (isspace(*p))
p++; /* skip leading ws */
if (p == end)
break;
q = end; /* compare until end */
if (*p == '*') {
/*
* Find a pointer to type by looking in fp->ctf_ptrtab.
* If we can't find a pointer to the given type, see if
* we can compute a pointer to the type resulting from
* resolving the type down to its base type and use
* that instead. This helps with cases where the CTF
* data includes "struct foo *" but not "foo_t *" and
* the user tries to access "foo_t *" in the debugger.
*/
if (ntype == 0) {
CTF_TYPE_TO_INDEX(ntype)]) == 0) {
goto err;
}
}
q = p + 1;
continue;
}
if (isqualifier(p, (size_t)(q - p)))
continue; /* skip qualifier keyword */
continue; /* skip prefix and next ws */
q = end; /* compare until end */
while (isspace(q[-1]))
q--; /* exclude trailing ws */
goto err;
}
break;
}
}
goto err;
}
}
if (*p != '\0' || type == 0)
return (type);
err:
return (ptype);
return (CTF_ERR);
}
/*
* Given a symbol table index, return the type of the data object described
* by the corresponding entry in the symbol table.
*/
{
} else {
}
if (type == 0)
return (type);
}
/*
* Return the pointer to the internal CTF type data corresponding to the
* given type ID. If the ID is invalid, the function returns NULL.
* This function is not exported outside of the library.
*/
const ctf_type_t *
{
return (NULL);
}
}
return (NULL);
}
/*
* Given a symbol table index, return the info for the function described
* by the corresponding entry in the symbol table.
*/
int
{
} else {
}
if (kind == CTF_K_UNKNOWN && n == 0)
if (kind != CTF_K_FUNCTION)
if (n != 0 && dp[n - 1] == 0) {
}
return (0);
}
/*
* Given a symbol table index, return the arguments for the function described
* by the corresponding entry in the symbol table.
*/
int
{
return (CTF_ERR); /* errno is set for us */
/*
* The argument data is two ushort_t's past the translation table
* offset: one for the function info, and one for the return type.
*/
return (0);
}